Repository navigation
SQL: add a PostgreSQL dialect chosen by content over db2_sql/sqlite (Part of #5622) - #5642
Merged
Merged
Conversation
…Part of #5622) postgresql registers before db2_sql so its internal_discriminator (dollar-quoted bodies, LANGUAGE plpgsql, RETURNS SETOF, ::casts, ON CONFLICT, CREATE EXTENSION, ...) is tried first; db2's `LANGUAGE SQL` also matches a Postgres function. It owns .sql/.ddl/.dml only on proof (extensions_needing_discriminator) and is dropped from the neighbourhood-gravity candidate pool, so a third claimant cannot dilute sqlite's dominance. Mode E tracks $$/$tag$ so a function body is one routine; CREATE TYPE/DOMAIN/TABLE/VIEW are named classes. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Owner
Author
|
No description provided. |
squid-protocol
marked this pull request as ready for review
October 19, 2026 14:49
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #5622 (slice 1: engine + tests; see Remaining slices).
What changed
postgresqlprofile (languages/postgresql.py), registered beforedb2_sql, so itsinternal_discriminatorruns first at Tier 2 (db2'sLANGUAGE SQLalso matches a Postgres function). No db2/sqlite edit needed..sql/.ddl/.dmlonly on proof (extensions_needing_discriminator), andlanguage_lens._evaluate_ecosystem_gravitynow drops proof-only languages from its candidate pool (mirrors the Tier 3 filter, Plain C headers (SDL GL, Vulkan) classified as Objective-C #4546). Without that, a third.sqlclaimant diluted sqlite's neighbourhood dominance below the threshold and 26 plain sqlite files fell to a lexical vote (first golden run: 1658 diffs).detector._slice_by_terminator:$$/$tag$tracking, so a dollar-quoted body is one routine instead of being cut at inner;.CREATE TYPE/DOMAIN/TABLE/VIEWare named classes;DOis a closure;CREATE PROCEDURE/FUNCTION/TRIGGERare routines.POSITIONAL_LANGUAGES(the language-addition audit requires it for any Mode E slicer),_EXPECTED_CLAIMANTS/_ORDER_CRITICAL_EXTENSIONSfor the new.sql/.ddl/.dmlclaimant.Class table (shapes)
CREATE [OR REPLACE] FUNCTION ... LANGUAGE plpgsql$$LANGUAGE sqlwith$tag$;RETURNS TABLE(...)CREATE PROCEDUREDO $$ ... $$CREATE TYPEenum/compositedb2_sql/sqliteGolden drift (explained)
Differential scan of the language-crucible corpus: exactly 2 files change label, both genuine Postgres:
sql/mediawiki_postgresql/tables.sql(sqlite -> postgresql, 4 routines now found) andsql/sqlmap_postgresql/dns_request.sql(sqlite -> postgresql). All 78 other sqlite-labelled files are unchanged (labels, counts, mass). The rest of the 188-diff re-bless is knock-on:composition(sqlite 80 -> 78 files, newpostgresqlrow), directory-group aggregates, health averages, and spatial coordinates. No timeouts in the bless run;crucible_check.pypasses both legs after it.Gates run
pr_gates.py --fast6/6;tests/core_engine+ new strict file +test_source_reads.py3791 passed; db2/sqlite strict tests pass;language_addition_audit.py --lang postgresqlOK (soft warnings only: no docs index row, no rosetta checkout);crucible_check.pyPASS after bless.Sibling gaps
dns_request.sql(sqlmap template) uses%RANDSTR3%placeholders as routine names, so its function is not extracted; needs a placeholder-tolerant name class. No burned-estate program needs it..sql(plain DDL) beside Postgres files stays sqlite/db2_sql: the dialect is chosen by content, not neighbourhood. sqldoom "one dialect for all files" needs a sibling-content vote that counts postgresql siblings. No burned-estate program depends on it..psql/.pgsqldiscriminator audit (extensions are owned outright, so the discriminator is never consulted for them).Remaining slices
data/postgresqlcorpus folder + ledger entries.docs/language_status/README.mdrow; fidelity table /FIDELITY_PROVENANCE.\iimport support.Cross-repo
No companion PRs. Merge order: none. After merge, re-run the rosetta sweep when its postgresql corpus slice lands.
🤖 Generated with Claude Code