Skip to content

PostgreSQL: add support for CREATE TEXT SEARCH CONFIGURATION/DICTIONARY/PARSER/TEMPLATE#2315

Open
fmguerreiro wants to merge 6 commits intoapache:mainfrom
fmguerreiro:upstream/text-search
Open

PostgreSQL: add support for CREATE TEXT SEARCH CONFIGURATION/DICTIONARY/PARSER/TEMPLATE#2315
fmguerreiro wants to merge 6 commits intoapache:mainfrom
fmguerreiro:upstream/text-search

Conversation

@fmguerreiro
Copy link
Copy Markdown
Contributor

@fmguerreiro fmguerreiro commented Apr 18, 2026

Summary

Adds PostgreSQL grammar for the four CREATE TEXT SEARCH variants:

  • CREATE TEXT SEARCH CONFIGURATION name (PARSER = parser_name)
  • CREATE TEXT SEARCH DICTIONARY name (TEMPLATE = template_name, ...)
  • CREATE TEXT SEARCH PARSER name (START = fn, GETTOKEN = fn, END = fn, LEXTYPES = fn[, HEADLINE = fn])
  • CREATE TEXT SEARCH TEMPLATE name (LEXIZE = fn[, INIT = fn])

Reference: https://www.postgresql.org/docs/current/textsearch-dictionaries.html

Changes

  • Four new structs in src/ast/ddl.rs (CreateTextSearchConfiguration, CreateTextSearchDictionary, CreateTextSearchParser, CreateTextSearchTemplate) with fmt::Display + From<T> for Statement.
  • Four new Statement variants and re-exports.
  • Spanned arms using Span::empty().
  • parse_create_text_search dispatcher in src/parser/mod.rs.
  • Four round-trip tests in tests/sqlparser_postgres.rs covering each variant plus optional-clause combinations.

Out of scope

ALTER TEXT SEARCH variants. Scope kept small for reviewability.

Notes

Originally shipped via the pgmold-sqlparser fork; tested against PostgreSQL 13–17 schemas in pgmold.

- Collapse the four near-identical parse arms in
  parse_create_text_search; parse the subtype keyword once, then
  parse name and options once, then map the subtype to the
  Statement variant.
- Spanned impls now return the name's span instead of Span::empty(),
  matching sibling Create* statements.
- Doc comments on each `options: Vec<SqlOption>` no longer claim
  the parser enforces required keys; they note PostgreSQL's
  requirements and clarify that enforcement is left to the engine.
- Add a test exercising schema-qualified option values
  (e.g. PARSER = pg_catalog.default) to guard the round-trip.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant