Commit 4114ff0
committed
PostgreSQL: Parse optimizer hints in leading comments
Enable comment-based optimizer hint parsing for the PostgreSQL dialect
by overriding `supports_comment_optimizer_hint` to return `true`.
PostgreSQL itself does not ship a built-in hint system, but the widely
used `pg_hint_plan` extension (https://github.com/ossc-db/pg_hint_plan)
introduces hints using the exact same `/*+ ... */` block-comment and
`--+ ...` single-line-comment syntax already supported for MySQL and
Oracle (#2162). Without this flag, parsing a `pg_hint_plan` statement
such as:
SELECT /*+ SeqScan(t) */ * FROM t;
discards the hint as an ordinary comment, making it impossible for
downstream tools (query rewriters, proxies, planners) built on
`sqlparser-rs` to preserve or act on hints when targeting PostgreSQL.
The parser side already handles this via `maybe_parse_optimizer_hint`
across SELECT / INSERT / UPDATE / DELETE / MERGE, so no parser or AST
changes are required — this is purely a dialect opt-in. The default
remains `false`, so no other dialect is affected.1 parent fa1dae1 commit 4114ff0
1 file changed
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
318 | 318 | | |
319 | 319 | | |
320 | 320 | | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
321 | 329 | | |
0 commit comments