Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow affixing SQLCommenter comment if comment already exists in statement #107

Open
jschaf opened this issue Apr 5, 2022 · 0 comments
Open

Comments

@jschaf
Copy link

jschaf commented Apr 5, 2022

There's certain comments that are necessary to include in a SQL statement. The use case I have in mind in Postgres hints 1.

  /*+
    HashJoin(a b)
    SeqScan(a)
  */
 EXPLAIN SELECT *
    FROM pgbench_branches b
    JOIN pgbench_accounts a ON b.bid = a.bid
   ORDER BY a.aid;

The spec states:

If a comment already exists within a SQL statement, we MUST NOT mutate that statement.

That means we can never use SQLCommenter with pg hint comments.

Proposal: modify spec to optionally allow affixing a comment. Alternately, narrow the spec to "if a comment already exists as the last token in a sql statement". When parsing choose the last comment if there's more than one.

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

No branches or pull requests

1 participant