@intentius/chant-lexicon-sql 0.124.46 → 0.124.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/change-set.d.ts +1 -1
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +2 -1
- package/dist/clickhouse/apply/statements.d.ts +9 -0
- package/dist/clickhouse/apply/statements.d.ts.map +1 -1
- package/dist/clickhouse/apply/statements.js +24 -0
- package/dist/clickhouse/import/live-export.d.ts +7 -3
- package/dist/clickhouse/import/live-export.d.ts.map +1 -1
- package/dist/clickhouse/import/live-export.js +21 -5
- package/dist/clickhouse/live/named-collections.d.ts +27 -0
- package/dist/clickhouse/live/named-collections.d.ts.map +1 -0
- package/dist/clickhouse/live/named-collections.js +53 -0
- package/dist/clickhouse/live/undeclarable.d.ts +15 -3
- package/dist/clickhouse/live/undeclarable.d.ts.map +1 -1
- package/dist/clickhouse/live/undeclarable.js +18 -4
- package/dist/clickhouse/named-collections.d.ts +83 -0
- package/dist/clickhouse/named-collections.d.ts.map +1 -0
- package/dist/clickhouse/named-collections.js +203 -0
- package/dist/clickhouse/parser.d.ts.map +1 -1
- package/dist/clickhouse/parser.js +1 -1
- package/dist/clickhouse/plan/commands.d.ts +2 -1
- package/dist/clickhouse/plan/commands.d.ts.map +1 -1
- package/dist/clickhouse/plan/commands.js +17 -2
- package/dist/clickhouse/plan/diff.d.ts +15 -0
- package/dist/clickhouse/plan/diff.d.ts.map +1 -1
- package/dist/clickhouse/plan/diff.js +43 -1
- package/dist/clickhouse/plan/disruption.d.ts.map +1 -1
- package/dist/clickhouse/plan/disruption.js +5 -0
- package/dist/clickhouse/plan/rebuild-handoff.d.ts.map +1 -1
- package/dist/clickhouse/plan/rebuild-handoff.js +4 -0
- package/dist/clickhouse/plan/report.d.ts.map +1 -1
- package/dist/clickhouse/plan/report.js +6 -1
- package/dist/clickhouse/plan/rules.d.ts +5 -1
- package/dist/clickhouse/plan/rules.d.ts.map +1 -1
- package/dist/clickhouse/plan/rules.js +7 -3
- package/dist/clickhouse/plan/statements.d.ts +29 -0
- package/dist/clickhouse/plan/statements.d.ts.map +1 -0
- package/dist/clickhouse/plan/statements.js +334 -0
- package/dist/clickhouse/plan/stream.d.ts +40 -0
- package/dist/clickhouse/plan/stream.d.ts.map +1 -0
- package/dist/clickhouse/plan/stream.js +107 -0
- package/dist/clickhouse/rebuild/observe.d.ts +3 -1
- package/dist/clickhouse/rebuild/observe.d.ts.map +1 -1
- package/dist/clickhouse/rebuild/observe.js +14 -1
- package/dist/clickhouse/review-catalog.d.ts +213 -0
- package/dist/clickhouse/review-catalog.d.ts.map +1 -0
- package/dist/clickhouse/review-catalog.js +330 -0
- package/dist/codegen/classifier-page.d.ts.map +1 -1
- package/dist/codegen/classifier-page.js +44 -4
- package/dist/codegen/clickhouse-module.d.ts.map +1 -1
- package/dist/codegen/clickhouse-module.js +3 -0
- package/dist/codegen/coverage-page.d.ts.map +1 -1
- package/dist/codegen/coverage-page.js +5 -3
- package/dist/codegen/docs.js +1 -1
- package/dist/codegen/postgres-classifier-page.js +2 -2
- package/dist/codegen/registry.d.ts.map +1 -1
- package/dist/codegen/registry.js +10 -0
- package/dist/composites/catalog.d.ts.map +1 -1
- package/dist/composites/catalog.js +100 -0
- package/dist/composites/clickhouse.d.ts +2 -0
- package/dist/composites/clickhouse.d.ts.map +1 -1
- package/dist/composites/clickhouse.js +2 -0
- package/dist/composites/otel-tables.d.ts +100 -0
- package/dist/composites/otel-tables.d.ts.map +1 -0
- package/dist/composites/otel-tables.js +282 -0
- package/dist/composites/stream-ingest.d.ts +63 -0
- package/dist/composites/stream-ingest.d.ts.map +1 -0
- package/dist/composites/stream-ingest.js +39 -0
- package/dist/core/statement-class.d.ts +55 -0
- package/dist/core/statement-class.d.ts.map +1 -0
- package/dist/core/statement-class.js +43 -0
- package/dist/coverage/clickhouse.json +1 -1
- package/dist/coverage/postgres.json +12 -12
- package/dist/coverage.d.ts +16 -6
- package/dist/coverage.d.ts.map +1 -1
- package/dist/coverage.js +10 -5
- package/dist/drizzle-command.d.ts +17 -0
- package/dist/drizzle-command.d.ts.map +1 -0
- package/dist/drizzle-command.js +91 -0
- package/dist/drizzle.d.ts +70 -0
- package/dist/drizzle.d.ts.map +1 -0
- package/dist/drizzle.js +689 -0
- package/dist/files/clickhouse.d.ts.map +1 -1
- package/dist/files/clickhouse.js +8 -1
- package/dist/files/common.d.ts +13 -0
- package/dist/files/common.d.ts.map +1 -1
- package/dist/files/common.js +5 -0
- package/dist/files/postgres.d.ts.map +1 -1
- package/dist/files/postgres.js +35 -3
- package/dist/generated/clickhouse.d.ts +2 -0
- package/dist/generated/clickhouse.d.ts.map +1 -1
- package/dist/generated/clickhouse.js +2 -0
- package/dist/import-parser.d.ts +21 -1
- package/dist/import-parser.d.ts.map +1 -1
- package/dist/import-parser.js +79 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/integrity.json +7 -6
- package/dist/lint/post-synth/audit-entries.d.ts.map +1 -1
- package/dist/lint/post-synth/audit-entries.js +1 -0
- package/dist/lint/post-synth/index.d.ts.map +1 -1
- package/dist/lint/post-synth/index.js +2 -0
- package/dist/lint/post-synth/postgres-names.d.ts.map +1 -1
- package/dist/lint/post-synth/postgres-names.js +3 -0
- package/dist/lint/post-synth/sqlch128.d.ts +18 -0
- package/dist/lint/post-synth/sqlch128.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch128.js +222 -0
- package/dist/lint/rules/postgres-templates.js +2 -2
- package/dist/lsp/postgres-template.d.ts.map +1 -1
- package/dist/lsp/postgres-template.js +21 -0
- package/dist/manifest.json +1 -1
- package/dist/mcp/postgres.js +1 -1
- package/dist/meta.json +50 -0
- package/dist/migrate/from-postgres/detect.d.ts +4 -0
- package/dist/migrate/from-postgres/detect.d.ts.map +1 -0
- package/dist/migrate/from-postgres/detect.js +7 -0
- package/dist/migrate/from-postgres/emit.d.ts +26 -0
- package/dist/migrate/from-postgres/emit.d.ts.map +1 -0
- package/dist/migrate/from-postgres/emit.js +86 -0
- package/dist/migrate/from-postgres/index.d.ts +51 -0
- package/dist/migrate/from-postgres/index.d.ts.map +1 -0
- package/dist/migrate/from-postgres/index.js +115 -0
- package/dist/migrate/from-postgres/translate.d.ts +73 -0
- package/dist/migrate/from-postgres/translate.d.ts.map +1 -0
- package/dist/migrate/from-postgres/translate.js +261 -0
- package/dist/migrate/from-postgres/types.d.ts +51 -0
- package/dist/migrate/from-postgres/types.d.ts.map +1 -0
- package/dist/migrate/from-postgres/types.js +211 -0
- package/dist/migration-classify.d.ts +23 -0
- package/dist/migration-classify.d.ts.map +1 -0
- package/dist/migration-classify.js +44 -0
- package/dist/migration-replay.d.ts +73 -0
- package/dist/migration-replay.d.ts.map +1 -0
- package/dist/migration-replay.js +294 -0
- package/dist/okf/index.md +11 -0
- package/dist/okf/rules/SQLCH128.md +11 -0
- package/dist/okf/types/PostgresForeignDataWrapper.md +9 -0
- package/dist/okf/types/PostgresForeignServer.md +9 -0
- package/dist/okf/types/PostgresForeignTable.md +9 -0
- package/dist/okf/types/PostgresOperator.md +9 -0
- package/dist/okf/types/PostgresOperatorClass.md +9 -0
- package/dist/okf/types/PostgresOperatorFamily.md +9 -0
- package/dist/okf/types/PostgresPublication.md +9 -0
- package/dist/okf/types/PostgresStatistics.md +9 -0
- package/dist/okf/types/PostgresTextSearchConfiguration.md +9 -0
- package/dist/okf/types/PostgresTextSearchDictionary.md +9 -0
- package/dist/op/activities/postgres-migration.d.ts.map +1 -1
- package/dist/op/activities/postgres-migration.js +4 -0
- package/dist/op/activity-contracts.d.ts +20 -0
- package/dist/op/activity-contracts.d.ts.map +1 -1
- package/dist/op/activity-contracts.js +2 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +49 -2
- package/dist/postgres/access/acl.js +1 -1
- package/dist/postgres/access/import.js +1 -1
- package/dist/postgres/apply/apply.js +13 -1
- package/dist/postgres/apply/statements.d.ts.map +1 -1
- package/dist/postgres/apply/statements.js +243 -4
- package/dist/postgres/constraint-names.d.ts +30 -0
- package/dist/postgres/constraint-names.d.ts.map +1 -0
- package/dist/postgres/constraint-names.js +72 -0
- package/dist/postgres/entities.d.ts +229 -2
- package/dist/postgres/entities.d.ts.map +1 -1
- package/dist/postgres/entities.js +326 -5
- package/dist/postgres/entity-types.d.ts +10 -0
- package/dist/postgres/entity-types.d.ts.map +1 -1
- package/dist/postgres/entity-types.js +10 -0
- package/dist/postgres/import/generator.d.ts.map +1 -1
- package/dist/postgres/import/generator.js +65 -2
- package/dist/postgres/import/live-export.d.ts.map +1 -1
- package/dist/postgres/import/live-export.js +2 -0
- package/dist/postgres/live/catalog-kinds.d.ts +20 -0
- package/dist/postgres/live/catalog-kinds.d.ts.map +1 -1
- package/dist/postgres/live/catalog-kinds.js +452 -0
- package/dist/postgres/live/catalog.d.ts +2 -0
- package/dist/postgres/live/catalog.d.ts.map +1 -1
- package/dist/postgres/live/catalog.js +3 -1
- package/dist/postgres/live/describe-resources.d.ts.map +1 -1
- package/dist/postgres/live/describe-resources.js +12 -2
- package/dist/postgres/migrate/backfill.d.ts +2 -0
- package/dist/postgres/migrate/backfill.d.ts.map +1 -1
- package/dist/postgres/migrate/backfill.js +7 -1
- package/dist/postgres/migrate/carry.d.ts +45 -1
- package/dist/postgres/migrate/carry.d.ts.map +1 -1
- package/dist/postgres/migrate/carry.js +72 -8
- package/dist/postgres/migrate/observe.d.ts +28 -4
- package/dist/postgres/migrate/observe.d.ts.map +1 -1
- package/dist/postgres/migrate/observe.js +45 -13
- package/dist/postgres/migrate/op.d.ts +26 -1
- package/dist/postgres/migrate/op.d.ts.map +1 -1
- package/dist/postgres/migrate/op.js +3 -1
- package/dist/postgres/migrate/replication.d.ts +42 -0
- package/dist/postgres/migrate/replication.d.ts.map +1 -1
- package/dist/postgres/migrate/replication.js +53 -0
- package/dist/postgres/migrate/steps.d.ts +35 -2
- package/dist/postgres/migrate/steps.d.ts.map +1 -1
- package/dist/postgres/migrate/steps.js +158 -12
- package/dist/postgres/parser.d.ts +144 -1
- package/dist/postgres/parser.d.ts.map +1 -1
- package/dist/postgres/parser.js +370 -4
- package/dist/postgres/plan/deep.d.ts.map +1 -1
- package/dist/postgres/plan/deep.js +43 -4
- package/dist/postgres/plan/diff.d.ts.map +1 -1
- package/dist/postgres/plan/diff.js +154 -1
- package/dist/postgres/plan/normalize.d.ts +28 -2
- package/dist/postgres/plan/normalize.d.ts.map +1 -1
- package/dist/postgres/plan/normalize.js +260 -1
- package/dist/postgres/plan/rules.d.ts +4 -0
- package/dist/postgres/plan/rules.d.ts.map +1 -1
- package/dist/postgres/plan/rules.js +6 -2
- package/dist/postgres/plan/schema.js +1 -1
- package/dist/postgres/plan/statements.d.ts +26 -0
- package/dist/postgres/plan/statements.d.ts.map +1 -0
- package/dist/postgres/plan/statements.js +364 -0
- package/dist/postgres/secret-options.d.ts +10 -0
- package/dist/postgres/secret-options.d.ts.map +1 -0
- package/dist/postgres/secret-options.js +9 -0
- package/dist/postgres/testing/roundtrip-schema.d.ts +4 -2
- package/dist/postgres/testing/roundtrip-schema.d.ts.map +1 -1
- package/dist/postgres/testing/roundtrip-schema.js +24 -1
- package/dist/postgres.d.ts +1 -1
- package/dist/postgres.d.ts.map +1 -1
- package/dist/postgres.js +1 -1
- package/dist/rules/audit-entries.ts +1 -0
- package/dist/rules/postgres-names.ts +2 -0
- package/dist/rules/postgres-templates.ts +2 -2
- package/dist/rules/sqlch128.ts +230 -0
- package/dist/serializer.d.ts +5 -0
- package/dist/serializer.d.ts.map +1 -1
- package/dist/serializer.js +13 -2
- package/dist/sql-types-command.d.ts +13 -0
- package/dist/sql-types-command.d.ts.map +1 -1
- package/dist/sql-types-command.js +31 -16
- package/dist/sql-types.d.ts +22 -0
- package/dist/sql-types.d.ts.map +1 -1
- package/dist/sql-types.js +10 -6
- package/dist/sqlserver/lexer.d.ts +37 -0
- package/dist/sqlserver/lexer.d.ts.map +1 -0
- package/dist/sqlserver/lexer.js +254 -0
- package/dist/sqlserver/parse.d.ts +185 -0
- package/dist/sqlserver/parse.d.ts.map +1 -0
- package/dist/sqlserver/parse.js +767 -0
- package/dist/sqlserver/translate.d.ts +34 -0
- package/dist/sqlserver/translate.d.ts.map +1 -0
- package/dist/sqlserver/translate.js +495 -0
- package/dist/sqlserver/types.d.ts +44 -0
- package/dist/sqlserver/types.d.ts.map +1 -0
- package/dist/sqlserver/types.js +133 -0
- package/dist/sqlserver/validate.d.ts +31 -0
- package/dist/sqlserver/validate.d.ts.map +1 -0
- package/dist/sqlserver/validate.js +67 -0
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +10 -0
- package/package.json +2 -2
- package/src/change-set.ts +2 -1
- package/src/clickhouse/apply/statements.ts +25 -0
- package/src/clickhouse/import/live-export.ts +20 -5
- package/src/clickhouse/live/named-collections.e2e.test.ts +88 -0
- package/src/clickhouse/live/named-collections.ts +61 -0
- package/src/clickhouse/live/undeclarable.e2e.test.ts +5 -3
- package/src/clickhouse/live/undeclarable.ts +20 -4
- package/src/clickhouse/named-collections.test.ts +187 -0
- package/src/clickhouse/named-collections.ts +224 -0
- package/src/clickhouse/parser.ts +2 -1
- package/src/clickhouse/plan/commands.ts +17 -2
- package/src/clickhouse/plan/diff.ts +57 -1
- package/src/clickhouse/plan/disruption.ts +5 -0
- package/src/clickhouse/plan/rebuild-handoff.ts +3 -0
- package/src/clickhouse/plan/report.ts +6 -1
- package/src/clickhouse/plan/rules.ts +14 -4
- package/src/clickhouse/plan/statements.test.ts +61 -0
- package/src/clickhouse/plan/statements.ts +306 -0
- package/src/clickhouse/plan/stream-s3queue.e2e.test.ts +148 -0
- package/src/clickhouse/plan/stream.test.ts +237 -0
- package/src/clickhouse/plan/stream.ts +111 -0
- package/src/clickhouse/rebuild/observe.ts +15 -1
- package/src/clickhouse/review-catalog.test.ts +181 -0
- package/src/clickhouse/review-catalog.ts +489 -0
- package/src/codegen/classifier-page.ts +44 -4
- package/src/codegen/clickhouse-module.ts +3 -0
- package/src/codegen/coverage-page.ts +5 -3
- package/src/codegen/docs.ts +1 -1
- package/src/codegen/postgres-classifier-page.ts +2 -2
- package/src/codegen/registry.ts +10 -0
- package/src/composites/catalog.test.ts +6 -1
- package/src/composites/catalog.ts +100 -0
- package/src/composites/clickhouse.ts +2 -0
- package/src/composites/composites.test.ts +1 -1
- package/src/composites/otel-tables.test.ts +118 -0
- package/src/composites/otel-tables.ts +339 -0
- package/src/composites/stream-ingest.test.ts +114 -0
- package/src/composites/stream-ingest.ts +82 -0
- package/src/core/statement-class.ts +88 -0
- package/src/core/undeclarable.test.ts +6 -5
- package/src/coverage/clickhouse.json +1 -1
- package/src/coverage/postgres.json +12 -12
- package/src/coverage.test.ts +27 -2
- package/src/coverage.ts +18 -7
- package/src/drizzle-command.ts +94 -0
- package/src/drizzle-kit.e2e.test.ts +89 -0
- package/src/drizzle-types.e2e.test.ts +67 -0
- package/src/drizzle.test.ts +358 -0
- package/src/drizzle.ts +742 -0
- package/src/files/clickhouse.ts +8 -1
- package/src/files/common.ts +14 -1
- package/src/files/postgres.ts +34 -3
- package/src/generated/clickhouse.ts +3 -0
- package/src/generated/lexicon-sql.json +50 -0
- package/src/import-parser.sqlserver.test.ts +92 -0
- package/src/import-parser.ts +79 -5
- package/src/index.ts +1 -1
- package/src/lint/post-synth/audit-entries.ts +1 -0
- package/src/lint/post-synth/index.ts +2 -0
- package/src/lint/post-synth/postgres-checks.test.ts +8 -1
- package/src/lint/post-synth/postgres-names.ts +2 -0
- package/src/lint/post-synth/sqlch128.test.ts +107 -0
- package/src/lint/post-synth/sqlch128.ts +230 -0
- package/src/lint/rules/postgres-templates.ts +2 -2
- package/src/lsp/postgres-template.ts +20 -0
- package/src/mcp/postgres.ts +1 -1
- package/src/migrate/from-postgres/cli.test.ts +165 -0
- package/src/migrate/from-postgres/detect.ts +7 -0
- package/src/migrate/from-postgres/emit.ts +96 -0
- package/src/migrate/from-postgres/example.test.ts +205 -0
- package/src/migrate/from-postgres/index.ts +122 -0
- package/src/migrate/from-postgres/translate.test.ts +242 -0
- package/src/migrate/from-postgres/translate.ts +359 -0
- package/src/migrate/from-postgres/types.test.ts +116 -0
- package/src/migrate/from-postgres/types.ts +236 -0
- package/src/migrate/from-postgres/validate.e2e.test.ts +44 -0
- package/src/migrate/from-postgres/workspace.e2e.test.ts +114 -0
- package/src/migration-classify.test.ts +150 -0
- package/src/migration-classify.ts +45 -0
- package/src/migration-replay.e2e.test.ts +155 -0
- package/src/migration-replay.test.ts +173 -0
- package/src/migration-replay.ts +289 -0
- package/src/op/__snapshots__/watch-pipeline.test.ts.snap +2 -2
- package/src/op/activities/postgres-migration.ts +4 -0
- package/src/op/activity-contracts.ts +2 -0
- package/src/op/watch-pipeline.test.ts +8 -1
- package/src/plugin.ts +51 -2
- package/src/postgres/access/acl.ts +1 -1
- package/src/postgres/access/import.ts +1 -1
- package/src/postgres/apply/apply.ts +14 -1
- package/src/postgres/apply/statements.ts +225 -4
- package/src/postgres/constraint-names.ts +71 -0
- package/src/postgres/database-kinds.test.ts +865 -0
- package/src/postgres/entities.ts +541 -5
- package/src/postgres/entity-types.ts +10 -0
- package/src/postgres/import/generator.ts +54 -2
- package/src/postgres/import/live-export.ts +1 -0
- package/src/postgres/live/catalog-kinds.ts +494 -0
- package/src/postgres/live/catalog.ts +6 -1
- package/src/postgres/live/database-kinds.e2e.test.ts +164 -0
- package/src/postgres/live/describe-resources.ts +13 -2
- package/src/postgres/live/undeclarable.e2e.test.ts +13 -6
- package/src/postgres/migrate/backfill.ts +13 -1
- package/src/postgres/migrate/carry.ts +103 -8
- package/src/postgres/migrate/followups.e2e.test.ts +218 -0
- package/src/postgres/migrate/followups.test.ts +199 -0
- package/src/postgres/migrate/kinds.e2e.test.ts +5 -5
- package/src/postgres/migrate/observe.ts +56 -15
- package/src/postgres/migrate/op.ts +28 -1
- package/src/postgres/migrate/partition.e2e.test.ts +129 -0
- package/src/postgres/migrate/partition.test.ts +206 -0
- package/src/postgres/migrate/replication.ts +66 -0
- package/src/postgres/migrate/steps.ts +157 -12
- package/src/postgres/migrate/subscriber.e2e.test.ts +141 -0
- package/src/postgres/migrate/subscriber.test.ts +59 -0
- package/src/postgres/parser.ts +455 -4
- package/src/postgres/plan/deep.ts +42 -4
- package/src/postgres/plan/diff.ts +137 -1
- package/src/postgres/plan/normalize.ts +277 -1
- package/src/postgres/plan/rules.ts +32 -4
- package/src/postgres/plan/schema.ts +1 -1
- package/src/postgres/plan/statements.test.ts +78 -0
- package/src/postgres/plan/statements.ts +299 -0
- package/src/postgres/secret-options.ts +10 -0
- package/src/postgres/testing/roundtrip-schema.ts +24 -1
- package/src/postgres.ts +33 -0
- package/src/serializer.ts +13 -2
- package/src/skills/chant-sql-postgres-migration.md +4 -3
- package/src/skills/chant-sql-postgres.md +11 -1
- package/src/skills/chant-sql.md +2 -1
- package/src/sql-files.test.ts +33 -0
- package/src/sql-types-command.ts +38 -16
- package/src/sql-types.ts +11 -6
- package/src/sqlserver/fixture.test.ts +186 -0
- package/src/sqlserver/import-cli.test.ts +61 -0
- package/src/sqlserver/lexer.ts +260 -0
- package/src/sqlserver/parse.ts +865 -0
- package/src/sqlserver/translate.test.ts +396 -0
- package/src/sqlserver/translate.ts +558 -0
- package/src/sqlserver/types.test.ts +102 -0
- package/src/sqlserver/types.ts +154 -0
- package/src/sqlserver/validate.e2e.test.ts +32 -0
- package/src/sqlserver/validate.test.ts +49 -0
- package/src/sqlserver/validate.ts +76 -0
- package/src/validate.ts +10 -0
- package/src/workspace-kinds.test.ts +11 -0
- package/workspace-kinds.json +100 -2
package/dist/postgres/parser.js
CHANGED
|
@@ -116,6 +116,12 @@ export const AGGREGATE_OPTIONS = [
|
|
|
116
116
|
];
|
|
117
117
|
/** `CREATE COLLATION`'s options (sql-createcollation). */
|
|
118
118
|
export const COLLATION_OPTIONS = ["locale", "lc_collate", "lc_ctype", "provider", "deterministic", "rules", "version"];
|
|
119
|
+
/** `CREATE OPERATOR`'s options (sql-createoperator); `procedure` is the old spelling of `function`. */
|
|
120
|
+
export const OPERATOR_OPTIONS = ["function", "procedure", "leftarg", "rightarg", "commutator", "negator", "restrict", "join", "hashes", "merges"];
|
|
121
|
+
/** `CREATE STATISTICS`'s kinds (sql-createstatistics). */
|
|
122
|
+
export const STATISTICS_KINDS = ["ndistinct", "dependencies", "mcv"];
|
|
123
|
+
/** `CREATE PUBLICATION ... WITH (...)`'s options (sql-createpublication); `publish_generated_columns` is 18's. */
|
|
124
|
+
export const PUBLICATION_OPTIONS = ["publish", "publish_via_partition_root", "publish_generated_columns"];
|
|
119
125
|
/** What may follow `IS` inside a `b_expr`. */
|
|
120
126
|
const B_EXPR_IS = [["DISTINCT", "FROM"], ["NOT", "DISTINCT", "FROM"], ["DOCUMENT"], ["NOT", "DOCUMENT"]];
|
|
121
127
|
class PgParser extends SqlCursor {
|
|
@@ -414,7 +420,7 @@ class PgParser extends SqlCursor {
|
|
|
414
420
|
node.span = this.span(from, []);
|
|
415
421
|
return node;
|
|
416
422
|
}
|
|
417
|
-
column(typed) {
|
|
423
|
+
column(typed, foreign = false) {
|
|
418
424
|
const { text, span } = this.nameTok("a column name");
|
|
419
425
|
const col = { name: text, nameSpan: span, constraints: [] };
|
|
420
426
|
if (!typed)
|
|
@@ -426,7 +432,11 @@ class PgParser extends SqlCursor {
|
|
|
426
432
|
else if (typed)
|
|
427
433
|
this.fail("expected a column type");
|
|
428
434
|
for (;;) {
|
|
429
|
-
if (this.
|
|
435
|
+
if (foreign && kw(this.peek(), "OPTIONS") && this.isPunct("(", 1)) {
|
|
436
|
+
this.p++;
|
|
437
|
+
col.options = this.genericOptions();
|
|
438
|
+
}
|
|
439
|
+
else if (this.accept("COMPRESSION"))
|
|
430
440
|
col.compression = this.expr(COLUMN_CLAUSE);
|
|
431
441
|
else if (this.accept("STORAGE"))
|
|
432
442
|
col.storage = this.expr(COLUMN_CLAUSE);
|
|
@@ -690,6 +700,8 @@ class PgParser extends SqlCursor {
|
|
|
690
700
|
return this.grant(true, false);
|
|
691
701
|
if (this.acceptSeq("ALTER", "DEFAULT", "PRIVILEGES"))
|
|
692
702
|
return this.defaultPrivileges();
|
|
703
|
+
if (this.acceptSeq("ALTER", "TEXT", "SEARCH", "CONFIGURATION"))
|
|
704
|
+
return this.textSearchMapping();
|
|
693
705
|
if (this.acceptSeq("ALTER", "TABLE"))
|
|
694
706
|
return this.rowSecurity();
|
|
695
707
|
this.expect("CREATE");
|
|
@@ -725,6 +737,30 @@ class PgParser extends SqlCursor {
|
|
|
725
737
|
return this.cast();
|
|
726
738
|
if (this.acceptSeq("EVENT", "TRIGGER"))
|
|
727
739
|
return this.eventTrigger();
|
|
740
|
+
if (this.accept("OPERATOR")) {
|
|
741
|
+
// CLASS and FAMILY are words an operator's schema may be named: `class.+` is still an operator.
|
|
742
|
+
if (kw(this.peek(), "CLASS") && !this.isPunct(".", 1)) {
|
|
743
|
+
this.p++;
|
|
744
|
+
return this.operatorClass();
|
|
745
|
+
}
|
|
746
|
+
if (kw(this.peek(), "FAMILY") && !this.isPunct(".", 1)) {
|
|
747
|
+
this.p++;
|
|
748
|
+
return this.operatorFamily();
|
|
749
|
+
}
|
|
750
|
+
return this.operator();
|
|
751
|
+
}
|
|
752
|
+
if (this.acceptSeq("TEXT", "SEARCH"))
|
|
753
|
+
return this.textSearch();
|
|
754
|
+
if (this.accept("STATISTICS"))
|
|
755
|
+
return this.statistics();
|
|
756
|
+
if (this.acceptSeq("FOREIGN", "TABLE"))
|
|
757
|
+
return this.foreignTable();
|
|
758
|
+
if (this.acceptSeq("FOREIGN", "DATA", "WRAPPER"))
|
|
759
|
+
return this.foreignDataWrapper();
|
|
760
|
+
if (this.accept("SERVER"))
|
|
761
|
+
return this.foreignServer();
|
|
762
|
+
if (this.accept("PUBLICATION"))
|
|
763
|
+
return this.publication();
|
|
728
764
|
if (kw(this.peek(), "UNIQUE", "INDEX"))
|
|
729
765
|
return this.index();
|
|
730
766
|
}
|
|
@@ -740,7 +776,7 @@ class PgParser extends SqlCursor {
|
|
|
740
776
|
return this.view(true, false, false, false);
|
|
741
777
|
if (this.accept("VIEW"))
|
|
742
778
|
return this.view(false, orReplace, persistence === "temporary", recursive);
|
|
743
|
-
return this.fail("expected SCHEMA, TABLE, INDEX, VIEW, MATERIALIZED VIEW, SEQUENCE, TYPE, DOMAIN, EXTENSION, FUNCTION, PROCEDURE, AGGREGATE, TRIGGER, EVENT TRIGGER, COLLATION, CAST, POLICY or ROLE");
|
|
779
|
+
return this.fail("expected SCHEMA, TABLE, INDEX, VIEW, MATERIALIZED VIEW, SEQUENCE, TYPE, DOMAIN, EXTENSION, FUNCTION, PROCEDURE, AGGREGATE, TRIGGER, EVENT TRIGGER, COLLATION, CAST, OPERATOR, OPERATOR CLASS, OPERATOR FAMILY, TEXT SEARCH CONFIGURATION, TEXT SEARCH DICTIONARY, STATISTICS, FOREIGN TABLE, FOREIGN DATA WRAPPER, SERVER, PUBLICATION, POLICY or ROLE");
|
|
744
780
|
}
|
|
745
781
|
schema() {
|
|
746
782
|
const node = { statement: "schema", ifNotExists: this.ifNotExists() };
|
|
@@ -993,6 +1029,299 @@ class PgParser extends SqlCursor {
|
|
|
993
1029
|
this.expectPunct(")");
|
|
994
1030
|
return node;
|
|
995
1031
|
}
|
|
1032
|
+
/** An unqualified, database-wide object's name (a wrapper, a server, a publication). */
|
|
1033
|
+
databaseName(what) {
|
|
1034
|
+
const { text, span } = this.nameTok(what);
|
|
1035
|
+
if (this.isPunct("."))
|
|
1036
|
+
this.fail(`expected ${what} without a schema (it belongs to the database)`);
|
|
1037
|
+
return { pieces: [text], span };
|
|
1038
|
+
}
|
|
1039
|
+
/** `( name 'value' [, ...] )`: a foreign data wrapper's or server's options. */
|
|
1040
|
+
genericOptions() {
|
|
1041
|
+
this.expectPunct("(");
|
|
1042
|
+
const out = [];
|
|
1043
|
+
const seen = new Set();
|
|
1044
|
+
for (;;) {
|
|
1045
|
+
const t = this.next();
|
|
1046
|
+
if (t.kind !== "ident" && t.kind !== "qident")
|
|
1047
|
+
this.fail("expected an option name", t);
|
|
1048
|
+
const nameSpan = this.span(this.idx(-1), []);
|
|
1049
|
+
const name = identValue(t);
|
|
1050
|
+
if (seen.has(name))
|
|
1051
|
+
this.fail(`${name} is given twice`, t);
|
|
1052
|
+
seen.add(name);
|
|
1053
|
+
const v = this.next();
|
|
1054
|
+
if (v.kind !== "string" && v.kind !== "ref")
|
|
1055
|
+
this.fail("expected the option's value, a string", v);
|
|
1056
|
+
out.push({ name, nameSpan, value: this.span(this.idx(-1), v.kind === "ref" ? [v.part] : []) });
|
|
1057
|
+
if (this.acceptPunct(","))
|
|
1058
|
+
continue;
|
|
1059
|
+
this.expectPunct(")");
|
|
1060
|
+
return out;
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
/** `[schema.]symbol`: an operator's name, its symbol made of operator characters. */
|
|
1064
|
+
operatorName() {
|
|
1065
|
+
const from = this.idx();
|
|
1066
|
+
const refs = [];
|
|
1067
|
+
const pieces = [];
|
|
1068
|
+
const symbol = () => {
|
|
1069
|
+
const t = this.next();
|
|
1070
|
+
if (t.kind !== "op")
|
|
1071
|
+
this.fail("expected the operator's symbol (operator characters, such as ===)", t);
|
|
1072
|
+
pieces.push(t.text);
|
|
1073
|
+
};
|
|
1074
|
+
if (this.peek()?.kind === "op")
|
|
1075
|
+
symbol();
|
|
1076
|
+
else {
|
|
1077
|
+
const t = this.next();
|
|
1078
|
+
this.colId(t, "a schema name");
|
|
1079
|
+
if (t.kind === "ref")
|
|
1080
|
+
refs.push(t.part);
|
|
1081
|
+
pieces.push(t.kind === "ref" ? "" : identValue(t));
|
|
1082
|
+
this.expectPunct(".");
|
|
1083
|
+
symbol();
|
|
1084
|
+
}
|
|
1085
|
+
return { pieces, span: this.span(from, refs) };
|
|
1086
|
+
}
|
|
1087
|
+
operator() {
|
|
1088
|
+
const name = this.operatorName();
|
|
1089
|
+
const options = this.definition("an operator option");
|
|
1090
|
+
this.checkDefinition(options, OPERATOR_OPTIONS, [], "an operator");
|
|
1091
|
+
if (!options.some((o) => o.name === "function" || o.name === "procedure"))
|
|
1092
|
+
this.fail("expected FUNCTION (an operator needs the function it calls)", this.lastSeen());
|
|
1093
|
+
return { statement: "operator", name, options };
|
|
1094
|
+
}
|
|
1095
|
+
/** The member list of `CREATE OPERATOR CLASS ... AS`: an operator, a support function or the storage type. */
|
|
1096
|
+
operatorClassItem() {
|
|
1097
|
+
const number = () => {
|
|
1098
|
+
const t = this.next();
|
|
1099
|
+
if (t.kind !== "number" && t.kind !== "ref")
|
|
1100
|
+
this.fail("expected the strategy or support number", t);
|
|
1101
|
+
return this.span(this.idx(-1), t.kind === "ref" ? [t.part] : []);
|
|
1102
|
+
};
|
|
1103
|
+
if (this.accept("OPERATOR")) {
|
|
1104
|
+
const item = { kind: "operator", number: number(), operator: this.operatorName() };
|
|
1105
|
+
if (this.isPunct("("))
|
|
1106
|
+
item.types = this.parenthesized();
|
|
1107
|
+
if (this.accept("FOR")) {
|
|
1108
|
+
if (this.accept("SEARCH"))
|
|
1109
|
+
return item;
|
|
1110
|
+
if (!this.acceptSeq("ORDER", "BY"))
|
|
1111
|
+
this.fail("expected SEARCH or ORDER BY");
|
|
1112
|
+
item.orderBy = this.qualifiedName("a sort operator family");
|
|
1113
|
+
}
|
|
1114
|
+
return item;
|
|
1115
|
+
}
|
|
1116
|
+
if (this.accept("FUNCTION")) {
|
|
1117
|
+
const n = number();
|
|
1118
|
+
const types = this.isPunct("(") ? this.parenthesized() : undefined;
|
|
1119
|
+
const fn = this.qualifiedName("a function name");
|
|
1120
|
+
if (!this.isPunct("("))
|
|
1121
|
+
this.fail("expected '(' and the function's argument types");
|
|
1122
|
+
return { kind: "function", number: n, ...(types ? { types } : {}), function: fn, args: this.parenthesized() };
|
|
1123
|
+
}
|
|
1124
|
+
if (this.accept("STORAGE"))
|
|
1125
|
+
return { kind: "storage", type: this.typeName() };
|
|
1126
|
+
return this.fail("expected OPERATOR, FUNCTION or STORAGE");
|
|
1127
|
+
}
|
|
1128
|
+
operatorClass() {
|
|
1129
|
+
const name = this.qualifiedName("an operator class name");
|
|
1130
|
+
const isDefault = this.accept("DEFAULT");
|
|
1131
|
+
this.expect("FOR");
|
|
1132
|
+
this.expect("TYPE");
|
|
1133
|
+
const type = this.typeName();
|
|
1134
|
+
this.expect("USING");
|
|
1135
|
+
const method = this.nameTok("an index access method").text;
|
|
1136
|
+
const node = { statement: "operatorClass", name, default: isDefault, type, method, items: [] };
|
|
1137
|
+
if (this.accept("FAMILY"))
|
|
1138
|
+
node.family = this.qualifiedName("an operator family name");
|
|
1139
|
+
this.expect("AS");
|
|
1140
|
+
do
|
|
1141
|
+
node.items.push(this.operatorClassItem());
|
|
1142
|
+
while (this.acceptPunct(","));
|
|
1143
|
+
return node;
|
|
1144
|
+
}
|
|
1145
|
+
operatorFamily() {
|
|
1146
|
+
const name = this.qualifiedName("an operator family name");
|
|
1147
|
+
this.expect("USING");
|
|
1148
|
+
return { statement: "operatorFamily", name, method: this.nameTok("an index access method").text };
|
|
1149
|
+
}
|
|
1150
|
+
/** After `CREATE TEXT SEARCH`: a dictionary or a configuration. A parser and a template are C code. */
|
|
1151
|
+
textSearch() {
|
|
1152
|
+
if (this.accept("DICTIONARY")) {
|
|
1153
|
+
const name = this.qualifiedName("a text search dictionary name");
|
|
1154
|
+
const options = this.definition("a dictionary option");
|
|
1155
|
+
// The options past TEMPLATE belong to the template; a name given twice is still wrong.
|
|
1156
|
+
this.checkDefinition(options, options.map((o) => o.name), ["template"], "a text search dictionary");
|
|
1157
|
+
return { statement: "textSearchDictionary", name, options };
|
|
1158
|
+
}
|
|
1159
|
+
if (this.accept("CONFIGURATION")) {
|
|
1160
|
+
const name = this.qualifiedName("a text search configuration name");
|
|
1161
|
+
const options = this.definition("a configuration option");
|
|
1162
|
+
this.checkDefinition(options, ["parser", "copy"], [], "a text search configuration");
|
|
1163
|
+
if (options.some((o) => o.name === "copy"))
|
|
1164
|
+
this.fail("expected PARSER (COPY copies mappings chant does not read; name the parser and write the mappings)", this.tokens[options.find((o) => o.name === "copy").nameSpan.from]);
|
|
1165
|
+
if (!options.some((o) => o.name === "parser"))
|
|
1166
|
+
this.fail("expected PARSER (a configuration needs the parser that splits text into tokens)", this.lastSeen());
|
|
1167
|
+
return { statement: "textSearchConfiguration", name, options };
|
|
1168
|
+
}
|
|
1169
|
+
return this.fail("expected DICTIONARY or CONFIGURATION (a text search parser and a text search template are C code an extension installs)");
|
|
1170
|
+
}
|
|
1171
|
+
/** `ALTER TEXT SEARCH CONFIGURATION name ADD MAPPING FOR token_type [, ...] WITH dictionary [, ...]`. */
|
|
1172
|
+
textSearchMapping() {
|
|
1173
|
+
const name = this.qualifiedName("a text search configuration name");
|
|
1174
|
+
if (!this.acceptSeq("ADD", "MAPPING"))
|
|
1175
|
+
this.fail("expected ADD MAPPING (a configuration's mappings are declared with ADD MAPPING after its CREATE)");
|
|
1176
|
+
this.expect("FOR");
|
|
1177
|
+
const node = { statement: "textSearchMapping", name, tokens: [], dictionaries: [] };
|
|
1178
|
+
do
|
|
1179
|
+
node.tokens.push((({ text, span }) => ({ name: text, span }))(this.nameTok("a token type")));
|
|
1180
|
+
while (this.acceptPunct(","));
|
|
1181
|
+
this.expect("WITH");
|
|
1182
|
+
do
|
|
1183
|
+
node.dictionaries.push(this.qualifiedName("a text search dictionary name"));
|
|
1184
|
+
while (this.acceptPunct(","));
|
|
1185
|
+
return node;
|
|
1186
|
+
}
|
|
1187
|
+
/** `CREATE FOREIGN TABLE`: the column list form. A key, a generated column, INHERITS and PARTITION OF are not declared. */
|
|
1188
|
+
foreignTable() {
|
|
1189
|
+
const ifNotExists = this.ifNotExists();
|
|
1190
|
+
const name = this.qualifiedName("a foreign table name");
|
|
1191
|
+
if (kw(this.peek(), "PARTITION"))
|
|
1192
|
+
this.fail("expected the column list (a foreign table that is a partition, PARTITION OF, is not declared here)");
|
|
1193
|
+
const node = { statement: "foreignTable", ifNotExists, name, columns: [], constraints: [], server: { pieces: [], span: this.span(this.idx(), []) }, options: [] };
|
|
1194
|
+
this.expectPunct("(");
|
|
1195
|
+
if (!this.acceptPunct(")")) {
|
|
1196
|
+
for (;;) {
|
|
1197
|
+
if (kw(this.peek(), "LIKE"))
|
|
1198
|
+
this.fail("LIKE is not declared on a foreign table; write its columns");
|
|
1199
|
+
const c = this.tableConstraint();
|
|
1200
|
+
if (c)
|
|
1201
|
+
node.constraints.push(c);
|
|
1202
|
+
else
|
|
1203
|
+
node.columns.push(this.column(true, true));
|
|
1204
|
+
if (this.acceptPunct(","))
|
|
1205
|
+
continue;
|
|
1206
|
+
this.expectPunct(")");
|
|
1207
|
+
break;
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
if (kw(this.peek(), "INHERITS"))
|
|
1211
|
+
this.fail("expected SERVER (INHERITS is not declared on a foreign table)");
|
|
1212
|
+
this.expect("SERVER");
|
|
1213
|
+
node.server = this.databaseName("a server name");
|
|
1214
|
+
if (this.accept("OPTIONS"))
|
|
1215
|
+
node.options = this.genericOptions();
|
|
1216
|
+
// A foreign table has CHECK and NOT NULL constraints and a default; Postgres refuses the rest, and a generated column is not read.
|
|
1217
|
+
const bad = (c, what) => this.fail(`${what} (a foreign table holds CHECK and NOT NULL constraints only; the remote server keeps the rest)`, this.tokens[c.span.from]);
|
|
1218
|
+
for (const c of [...node.constraints, ...node.columns.flatMap((x) => x.constraints)]) {
|
|
1219
|
+
if (c.kind !== "CHECK" && c.kind !== "NOT NULL")
|
|
1220
|
+
bad(c, `expected CHECK or NOT NULL, not ${c.kind}`);
|
|
1221
|
+
if (c.notEnforced !== undefined)
|
|
1222
|
+
bad(c, "ENFORCED and NOT ENFORCED are 18's and are not declared on a foreign table");
|
|
1223
|
+
}
|
|
1224
|
+
for (const col of node.columns)
|
|
1225
|
+
if (col.generated)
|
|
1226
|
+
this.fail(`expected no generated column (${col.name} is GENERATED ${col.generated.kind.toUpperCase()}; a foreign table's generated columns are not declared)`, this.tokens[col.nameSpan.from]);
|
|
1227
|
+
return node;
|
|
1228
|
+
}
|
|
1229
|
+
statistics() {
|
|
1230
|
+
const ifNotExists = this.ifNotExists();
|
|
1231
|
+
const name = this.qualifiedName("a statistics name");
|
|
1232
|
+
const kinds = [];
|
|
1233
|
+
if (this.isPunct("(")) {
|
|
1234
|
+
for (const k of this.nameList("a statistics kind")) {
|
|
1235
|
+
if (!STATISTICS_KINDS.includes(k.name))
|
|
1236
|
+
this.fail(`expected a statistics kind (${STATISTICS_KINDS.join(", ")})`, this.tokens[k.span.from]);
|
|
1237
|
+
kinds.push(k.name);
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
this.expect("ON");
|
|
1241
|
+
const targets = [];
|
|
1242
|
+
do
|
|
1243
|
+
targets.push(this.expr(["FROM"]));
|
|
1244
|
+
while (this.acceptPunct(","));
|
|
1245
|
+
this.expect("FROM");
|
|
1246
|
+
const table = this.qualifiedName("a table name");
|
|
1247
|
+
return { statement: "statistics", ifNotExists, name, kinds, targets, table };
|
|
1248
|
+
}
|
|
1249
|
+
foreignDataWrapper() {
|
|
1250
|
+
const node = { statement: "foreignDataWrapper", name: this.databaseName("a foreign data wrapper name"), options: [] };
|
|
1251
|
+
for (;;) {
|
|
1252
|
+
if (this.accept("HANDLER"))
|
|
1253
|
+
node.handler = this.qualifiedName("a handler function");
|
|
1254
|
+
else if (this.acceptSeq("NO", "HANDLER"))
|
|
1255
|
+
node.handler = null;
|
|
1256
|
+
else if (this.accept("VALIDATOR"))
|
|
1257
|
+
node.validator = this.qualifiedName("a validator function");
|
|
1258
|
+
else if (this.acceptSeq("NO", "VALIDATOR"))
|
|
1259
|
+
node.validator = null;
|
|
1260
|
+
else if (this.accept("OPTIONS"))
|
|
1261
|
+
node.options = this.genericOptions();
|
|
1262
|
+
else
|
|
1263
|
+
return node;
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
foreignServer() {
|
|
1267
|
+
const ifNotExists = this.ifNotExists();
|
|
1268
|
+
const name = this.databaseName("a server name");
|
|
1269
|
+
const node = { statement: "foreignServer", ifNotExists, name, options: [] };
|
|
1270
|
+
const string = (what) => {
|
|
1271
|
+
const t = this.next();
|
|
1272
|
+
if (t.kind !== "string" && t.kind !== "ref")
|
|
1273
|
+
this.fail(`expected ${what} as a string`, t);
|
|
1274
|
+
return this.span(this.idx(-1), t.kind === "ref" ? [t.part] : []);
|
|
1275
|
+
};
|
|
1276
|
+
if (this.accept("TYPE"))
|
|
1277
|
+
node.type = string("the server type");
|
|
1278
|
+
if (this.accept("VERSION"))
|
|
1279
|
+
node.version = string("the server version");
|
|
1280
|
+
if (!this.acceptSeq("FOREIGN", "DATA", "WRAPPER"))
|
|
1281
|
+
this.fail("expected FOREIGN DATA WRAPPER (a server names the wrapper it is for)");
|
|
1282
|
+
node.wrapper = this.qualifiedName("a foreign data wrapper name");
|
|
1283
|
+
if (this.accept("OPTIONS"))
|
|
1284
|
+
node.options = this.genericOptions();
|
|
1285
|
+
return node;
|
|
1286
|
+
}
|
|
1287
|
+
publication() {
|
|
1288
|
+
const node = { statement: "publication", name: this.databaseName("a publication name"), allTables: false, items: [], options: [] };
|
|
1289
|
+
if (this.accept("FOR")) {
|
|
1290
|
+
if (this.acceptSeq("ALL", "TABLES"))
|
|
1291
|
+
node.allTables = true;
|
|
1292
|
+
else {
|
|
1293
|
+
let mode;
|
|
1294
|
+
do {
|
|
1295
|
+
if (this.accept("TABLE"))
|
|
1296
|
+
mode = "table";
|
|
1297
|
+
else if (this.acceptSeq("TABLES", "IN", "SCHEMA"))
|
|
1298
|
+
mode = "schema";
|
|
1299
|
+
else if (mode === undefined)
|
|
1300
|
+
this.fail("expected ALL TABLES, TABLE or TABLES IN SCHEMA");
|
|
1301
|
+
if (mode === "schema") {
|
|
1302
|
+
node.items.push({ kind: "schema", schema: this.qualifiedName("a schema name") });
|
|
1303
|
+
continue;
|
|
1304
|
+
}
|
|
1305
|
+
this.accept("ONLY");
|
|
1306
|
+
const table = this.qualifiedName("a table name");
|
|
1307
|
+
if (this.isOp("*"))
|
|
1308
|
+
this.p++;
|
|
1309
|
+
const item = { kind: "table", table };
|
|
1310
|
+
if (this.isPunct("("))
|
|
1311
|
+
item.columns = this.nameList("a column name");
|
|
1312
|
+
if (this.accept("WHERE"))
|
|
1313
|
+
item.where = this.checkedParens();
|
|
1314
|
+
node.items.push(item);
|
|
1315
|
+
} while (this.acceptPunct(","));
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
if (kw(this.peek(), "WITH") && this.isPunct("(", 1)) {
|
|
1319
|
+
this.p++;
|
|
1320
|
+
node.options = this.definition("a publication option");
|
|
1321
|
+
this.checkDefinition(node.options, PUBLICATION_OPTIONS, [], "a publication");
|
|
1322
|
+
}
|
|
1323
|
+
return node;
|
|
1324
|
+
}
|
|
996
1325
|
table(persistence) {
|
|
997
1326
|
const ifNotExists = this.ifNotExists();
|
|
998
1327
|
const node = { statement: "table", persistence, ifNotExists, name: this.qualifiedName("a table name"), columns: [], constraints: [], like: [] };
|
|
@@ -1747,6 +2076,43 @@ class PgParser extends SqlCursor {
|
|
|
1747
2076
|
node.text = this.commentText();
|
|
1748
2077
|
return node;
|
|
1749
2078
|
}
|
|
2079
|
+
else if (this.acceptSeq("FOREIGN", "DATA", "WRAPPER")) {
|
|
2080
|
+
objectType = "FOREIGN DATA WRAPPER";
|
|
2081
|
+
target = this.qualifiedName("a foreign data wrapper name");
|
|
2082
|
+
}
|
|
2083
|
+
else if (kw(this.peek(), "OPERATOR") && kw(this.peek(1), "CLASS", "FAMILY") && !this.isPunct(".", 2)) {
|
|
2084
|
+
this.p++;
|
|
2085
|
+
objectType = `OPERATOR ${this.next().text.toUpperCase()}`;
|
|
2086
|
+
target = this.qualifiedName(`an ${objectType.toLowerCase()} name`);
|
|
2087
|
+
this.expect("USING");
|
|
2088
|
+
const using = this.nameTok("an index access method").text;
|
|
2089
|
+
this.expect("IS");
|
|
2090
|
+
const node = { statement: "comment", objectType, target, using };
|
|
2091
|
+
if (!this.accept("NULL"))
|
|
2092
|
+
node.text = this.commentText();
|
|
2093
|
+
return node;
|
|
2094
|
+
}
|
|
2095
|
+
else if (this.acceptSeq("TEXT", "SEARCH")) {
|
|
2096
|
+
if (!this.accept("CONFIGURATION", "DICTIONARY"))
|
|
2097
|
+
this.fail("expected CONFIGURATION or DICTIONARY");
|
|
2098
|
+
objectType = `TEXT SEARCH ${this.lastSeen().text.toUpperCase()}`;
|
|
2099
|
+
target = this.qualifiedName(`a ${objectType.toLowerCase()} name`);
|
|
2100
|
+
}
|
|
2101
|
+
else if (this.acceptSeq("FOREIGN", "TABLE")) {
|
|
2102
|
+
objectType = "FOREIGN TABLE";
|
|
2103
|
+
target = this.qualifiedName("a foreign table name");
|
|
2104
|
+
}
|
|
2105
|
+
else if (this.accept("OPERATOR")) {
|
|
2106
|
+
objectType = "OPERATOR";
|
|
2107
|
+
target = this.operatorName();
|
|
2108
|
+
if (!this.isPunct("("))
|
|
2109
|
+
this.fail("expected '(' and the operator's operand types");
|
|
2110
|
+
args = this.parenthesized();
|
|
2111
|
+
}
|
|
2112
|
+
else if (this.accept("SERVER", "PUBLICATION", "STATISTICS")) {
|
|
2113
|
+
objectType = this.lastSeen().text.toUpperCase();
|
|
2114
|
+
target = this.qualifiedName(`a ${objectType.toLowerCase()} name`);
|
|
2115
|
+
}
|
|
1750
2116
|
else if (this.accept("AGGREGATE", "COLLATION")) {
|
|
1751
2117
|
objectType = this.lastSeen().text.toUpperCase();
|
|
1752
2118
|
target = this.qualifiedName(`an ${objectType.toLowerCase()} name`);
|
|
@@ -1763,7 +2129,7 @@ class PgParser extends SqlCursor {
|
|
|
1763
2129
|
objectType = this.tokens[this.idx(-1)].text.toUpperCase();
|
|
1764
2130
|
}
|
|
1765
2131
|
else
|
|
1766
|
-
return this.fail("expected TABLE, COLUMN, INDEX, VIEW, MATERIALIZED VIEW, SEQUENCE, TYPE, DOMAIN, SCHEMA, EXTENSION, FUNCTION, PROCEDURE, AGGREGATE, COLLATION, CAST, TRIGGER, EVENT TRIGGER, POLICY, ROLE or CONSTRAINT");
|
|
2132
|
+
return this.fail("expected TABLE, COLUMN, INDEX, VIEW, MATERIALIZED VIEW, SEQUENCE, TYPE, DOMAIN, SCHEMA, EXTENSION, FUNCTION, PROCEDURE, AGGREGATE, COLLATION, CAST, OPERATOR, TRIGGER, EVENT TRIGGER, STATISTICS, FOREIGN TABLE, FOREIGN DATA WRAPPER, SERVER, PUBLICATION, OPERATOR CLASS, OPERATOR FAMILY, TEXT SEARCH CONFIGURATION, TEXT SEARCH DICTIONARY, POLICY, ROLE or CONSTRAINT");
|
|
1767
2133
|
target = this.qualifiedName("an object name");
|
|
1768
2134
|
if ((objectType === "FUNCTION" || objectType === "PROCEDURE") && this.isPunct("("))
|
|
1769
2135
|
args = this.parenthesized();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deep.d.ts","sourceRoot":"","sources":["../../../src/postgres/plan/deep.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAmB,KAAK,qBAAqB,EAAwD,MAAM,mCAAmC,CAAC;AAEtJ,OAAO,EAAyC,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AACvF,OAAO,EAA2B,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAI7E,OAAO,EAAkD,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAMrG,KAAK,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"deep.d.ts","sourceRoot":"","sources":["../../../src/postgres/plan/deep.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAmB,KAAK,qBAAqB,EAAwD,MAAM,mCAAmC,CAAC;AAEtJ,OAAO,EAAyC,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AACvF,OAAO,EAA2B,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAI7E,OAAO,EAAkD,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAMrG,KAAK,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAqCrC,+EAA+E;AAC/E,wBAAgB,SAAS,CAAC,CAAC,EAAE,YAAY,GAAG,KAAK,CAGhD;AA6GD,uGAAuG;AACvG,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC,EAAE,iBAAiB,GAAG,KAAK,CA4EpH;AAED,wBAAsB,oBAAoB,CACxC,OAAO,EAAE;IACP,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;CAC/E,GAAG,IAAI,CAAC,WAAW,EAAE,aAAa,CAAC,GACnC,OAAO,CAAC,qBAAqB,CAAC,CAyEhC"}
|
|
@@ -37,6 +37,16 @@ const TAG = {
|
|
|
37
37
|
[POSTGRES_ENTITY_TYPES.collation]: tags.collation,
|
|
38
38
|
[POSTGRES_ENTITY_TYPES.cast]: tags.cast,
|
|
39
39
|
[POSTGRES_ENTITY_TYPES.eventTrigger]: tags.eventTrigger,
|
|
40
|
+
[POSTGRES_ENTITY_TYPES.operator]: tags.operator,
|
|
41
|
+
[POSTGRES_ENTITY_TYPES.operatorClass]: tags.operatorClass,
|
|
42
|
+
[POSTGRES_ENTITY_TYPES.operatorFamily]: tags.operatorFamily,
|
|
43
|
+
[POSTGRES_ENTITY_TYPES.foreignTable]: tags.foreignTable,
|
|
44
|
+
[POSTGRES_ENTITY_TYPES.textSearchConfiguration]: tags.textSearchConfiguration,
|
|
45
|
+
[POSTGRES_ENTITY_TYPES.textSearchDictionary]: tags.textSearchDictionary,
|
|
46
|
+
[POSTGRES_ENTITY_TYPES.statistics]: tags.statistics,
|
|
47
|
+
[POSTGRES_ENTITY_TYPES.foreignDataWrapper]: tags.foreignDataWrapper,
|
|
48
|
+
[POSTGRES_ENTITY_TYPES.foreignServer]: tags.foreignServer,
|
|
49
|
+
[POSTGRES_ENTITY_TYPES.publication]: tags.publication,
|
|
40
50
|
[POSTGRES_ENTITY_TYPES.extension]: tags.extension,
|
|
41
51
|
[POSTGRES_ENTITY_TYPES.function]: tags.func,
|
|
42
52
|
[POSTGRES_ENTITY_TYPES.procedure]: tags.procedure,
|
|
@@ -129,6 +139,24 @@ const PROP_OF_FIELD = {
|
|
|
129
139
|
context: ["context"],
|
|
130
140
|
event: ["event"],
|
|
131
141
|
tags: ["tags"],
|
|
142
|
+
targets: ["targets"],
|
|
143
|
+
kinds: ["kinds"],
|
|
144
|
+
handler: ["handler", "handlerName", "noHandler"],
|
|
145
|
+
validator: ["validator", "validatorName", "noValidator"],
|
|
146
|
+
serverType: ["serverType"],
|
|
147
|
+
wrapper: ["wrapper", "wrapperName"],
|
|
148
|
+
server: ["serverName"],
|
|
149
|
+
family: ["family"],
|
|
150
|
+
items: ["items"],
|
|
151
|
+
template: ["template"],
|
|
152
|
+
parser: ["parser"],
|
|
153
|
+
mappings: ["mappings"],
|
|
154
|
+
allTables: ["allTables"],
|
|
155
|
+
tables: ["tables"],
|
|
156
|
+
schemas: ["schemas"],
|
|
157
|
+
publish: [],
|
|
158
|
+
viaRoot: [],
|
|
159
|
+
generatedColumns: [],
|
|
132
160
|
};
|
|
133
161
|
/** Props keys that hold constraints, by constraint kind. */
|
|
134
162
|
const CONSTRAINT_PROPS = {
|
|
@@ -155,6 +183,9 @@ export function inDeclaredVocabulary(declared, live, d, l) {
|
|
|
155
183
|
if (d.kind === "aggregate" && d.signature === l.signature)
|
|
156
184
|
for (const key of ["args", "orderBy"])
|
|
157
185
|
adopt(key);
|
|
186
|
+
if (d.kind === "operator" && d.signature === l.signature)
|
|
187
|
+
for (const key of ["leftArg", "rightArg"])
|
|
188
|
+
adopt(key);
|
|
158
189
|
if (d.kind === "cast" && d.name === l.name)
|
|
159
190
|
for (const key of ["sourceType", "targetType"])
|
|
160
191
|
adopt(key);
|
|
@@ -174,7 +205,7 @@ export function inDeclaredVocabulary(declared, live, d, l) {
|
|
|
174
205
|
if (f !== "schema" || d.kind === "extension")
|
|
175
206
|
adopt(key);
|
|
176
207
|
}
|
|
177
|
-
if (d.kind === "table") {
|
|
208
|
+
if (d.kind === "table" || d.kind === "foreignTable") {
|
|
178
209
|
const declaredColumns = declared.columns ?? [];
|
|
179
210
|
const liveColumns = live.columns ?? [];
|
|
180
211
|
// Columns are matched by name and listed in the declaration's order, the
|
|
@@ -195,7 +226,15 @@ export function inDeclaredVocabulary(declared, live, d, l) {
|
|
|
195
226
|
].map((c) => c.value);
|
|
196
227
|
}
|
|
197
228
|
// An aggregate's or a collation's `options` is the declaration's only when every field read from it is the same (a role's `options` shares the key).
|
|
198
|
-
const optionFields = d.kind === "aggregate"
|
|
229
|
+
const optionFields = d.kind === "aggregate" || d.kind === "operator"
|
|
230
|
+
? ["definition"]
|
|
231
|
+
: d.kind === "collation"
|
|
232
|
+
? ["provider", "lcCollate", "lcCtype", "locale", "nondeterministic", "rules"]
|
|
233
|
+
: d.kind === "foreignDataWrapper" || d.kind === "foreignServer" || d.kind === "foreignTable" || d.kind === "textSearchDictionary"
|
|
234
|
+
? ["options"]
|
|
235
|
+
: d.kind === "publication"
|
|
236
|
+
? ["publish", "viaRoot", "generatedColumns"]
|
|
237
|
+
: undefined;
|
|
199
238
|
if (optionFields) {
|
|
200
239
|
if (optionFields.every((f) => JSON.stringify(d.fields[f]) === JSON.stringify(l.fields[f])))
|
|
201
240
|
adopt("options");
|
|
@@ -207,9 +246,9 @@ export function inDeclaredVocabulary(declared, live, d, l) {
|
|
|
207
246
|
out.method = live.method;
|
|
208
247
|
out.functionArgs = live.functionArgs;
|
|
209
248
|
}
|
|
210
|
-
if (d.kind === "table" || d.kind === "domain") {
|
|
249
|
+
if (d.kind === "table" || d.kind === "domain" || d.kind === "foreignTable") {
|
|
211
250
|
// A constraint the declaration says the same as the server is the declaration's (its name included or left out).
|
|
212
|
-
const kinds = d.kind === "
|
|
251
|
+
const kinds = d.kind === "table" ? Object.keys(CONSTRAINT_PROPS) : ["CHECK"];
|
|
213
252
|
for (const kind of kinds) {
|
|
214
253
|
const key = CONSTRAINT_PROPS[kind];
|
|
215
254
|
const dl = d.constraints.filter((c) => c.kind === kind);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../src/postgres/plan/diff.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAoB,KAAK,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAChG,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAuB,KAAK,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC3F,OAAO,EAAkE,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvH,OAAO,EAAmE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AACnH,OAAO,EAAe,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/E,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AAExE,4HAA4H;AAC5H,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,MAAM,QAAQ,GAAG,gBAAgB,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAC;AAE3E,MAAM,WAAW,YAAa,SAAQ,SAAS,CAAC,QAAQ,CAAC;IACvD,6EAA6E;IAC7E,OAAO,EAAE,QAAQ,EAAE,CAAC;IACpB,8FAA8F;IAC9F,YAAY,CAAC,EAAE,6BAA6B,EAAE,CAAC;IAC/C,sHAAsH;IACtH,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC;CACzB;AAqHD,gDAAgD;AAChD,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,mBAAmB,GAAG,kBAAkB,CAa5E;
|
|
1
|
+
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../src/postgres/plan/diff.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAoB,KAAK,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAChG,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAuB,KAAK,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC3F,OAAO,EAAkE,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvH,OAAO,EAAmE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AACnH,OAAO,EAAe,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/E,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AAExE,4HAA4H;AAC5H,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,MAAM,QAAQ,GAAG,gBAAgB,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAC;AAE3E,MAAM,WAAW,YAAa,SAAQ,SAAS,CAAC,QAAQ,CAAC;IACvD,6EAA6E;IAC7E,OAAO,EAAE,QAAQ,EAAE,CAAC;IACpB,8FAA8F;IAC9F,YAAY,CAAC,EAAE,6BAA6B,EAAE,CAAC;IAC/C,sHAAsH;IACtH,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC;CACzB;AAqHD,gDAAgD;AAChD,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,mBAAmB,GAAG,kBAAkB,CAa5E;AAoXD;;;GAGG;AACH;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,EAAE,KAAK,EAAE,SAAS,cAAc,EAAE,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,YAAY,CAAC,CAAC,CAUpJ;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,SAAS,cAAc,EAAE,EAAE,QAAQ,EAAE,SAAS,cAAc,EAAE,EAAE,OAAO,GAAE,aAAkB,GAAG,YAAY,CAqClJ"}
|