Skip to content

SQL: add a PostgreSQL dialect chosen by content over db2_sql/sqlite (Part of #5622) - #5642

Merged
squid-protocol merged 1 commit into
mainfrom
churn/5622-20261019T1251Z
Oct 19, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
churn/5622-20261019T1251Z

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Part of #5622 (slice 1: engine + tests; see Remaining slices).

What changed

  • New postgresql profile (languages/postgresql.py), registered before db2_sql, so its internal_discriminator runs first at Tier 2 (db2's LANGUAGE SQL also matches a Postgres function). No db2/sqlite edit needed.
  • It owns .sql/.ddl/.dml only on proof (extensions_needing_discriminator), and language_lens._evaluate_ecosystem_gravity now 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 .sql claimant 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/VIEW are named classes; DO is a closure; CREATE PROCEDURE/FUNCTION/TRIGGER are routines.
  • Pins updated: POSITIONAL_LANGUAGES (the language-addition audit requires it for any Mode E slicer), _EXPECTED_CLAIMANTS / _ORDER_CRITICAL_EXTENSIONS for the new .sql/.ddl/.dml claimant.

Class table (shapes)

Shape Result
CREATE [OR REPLACE] FUNCTION ... LANGUAGE plpgsql $$ one function, spans body
LANGUAGE sql with $tag$ one function, not cut at inner ;
RETURNS TABLE(...) one function
CREATE PROCEDURE function
DO $$ ... $$ closure, not a named function
CREATE TYPE enum/composite named class
db2 procedure / sqlite script still db2_sql / sqlite

Golden 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) and sql/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, new postgresql row), directory-group aggregates, health averages, and spatial coordinates. No timeouts in the bless run; crucible_check.py passes both legs after it.

Gates run

pr_gates.py --fast 6/6; tests/core_engine + new strict file + test_source_reads.py 3791 passed; db2/sqlite strict tests pass; language_addition_audit.py --lang postgresql OK (soft warnings only: no docs index row, no rosetta checkout); crucible_check.py PASS 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.
  • An evidence-free .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/.pgsql discriminator audit (extensions are owned outright, so the discriminator is never consulted for them).

Remaining slices

  • Rescan sqldoom for 110/110 functions and one dialect (clone absent on this box, so not measured).
  • keyword-rosetta data/postgresql corpus folder + ledger entries.
  • docs/language_status/README.md row; fidelity table / FIDELITY_PROVENANCE.
  • Sibling-content vote for evidence-free files (above); \i import 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

…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]>
@squid-protocol squid-protocol added the shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md label Oct 19, 2026
@squid-protocol

Copy link
Copy Markdown
Owner Author

No description provided.

@squid-protocol
squid-protocol marked this pull request as ready for review October 19, 2026 14:49
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant