Skip to content

Keep pg_catalog on functions named after column name keywords - #230

Closed
R3gardless wants to merge 1 commit into
lelit:v8from
R3gardless:fix-remove-pg-catalog-keyword-functions
Closed

R3gardless wants to merge 1 commit into
lelit:v8from
R3gardless:fix-remove-pg-catalog-keyword-functions

Conversation

@R3gardless

Copy link
Copy Markdown
Contributor

With remove_pg_catalog_from_functions=True, the schema is kept only for extract, position and xmlexists. The other functions named after a column name keyword lose it as well:

SELECT pg_catalog.coalesce(1, 2)           ->  SELECT coalesce(1, 2)            -- different statement
SELECT pg_catalog.normalize('abc', 'NFC')  ->  SELECT normalize('abc', 'NFC')   -- syntax error
SELECT pg_catalog.int(1)                   ->  SELECT int(1)                    -- syntax error

This replaces the hardcoded list with a check against COL_NAME_KEYWORDS, except overlay and substring, which work unqualified. I added the new cases to the existing test.

With remove_pg_catalog_from_functions only extract, position and xmlexists
kept their schema: pg_catalog.coalesce(1, 2) became the COALESCE expression
and pg_catalog.normalize('abc', 'NFC') was emitted as invalid SQL.
@R3gardless R3gardless closed this Oct 19, 2026
@R3gardless R3gardless reopened this Oct 21, 2026
@lelit

lelit commented Oct 25, 2026

Copy link
Copy Markdown
Owner

Thanks, apparently this is already ok in both v7 (where I applied a backport of your #229) and v8 (after #224). Reopen should that not be the case.

@lelit lelit closed this Oct 25, 2026
@R3gardless

Copy link
Copy Markdown
Contributor Author

Hi @lelit, thanks for checking! If I'm not mistaken, with remove_pg_catalog_from_functions=True these still come out wrong on the current v7 and v8 heads:

SELECT pg_catalog.coalesce(1, 2)          -> SELECT coalesce(1, 2)           (parsed back as a COALESCE expression)
SELECT pg_catalog.normalize('abc', 'NFC') -> SELECT normalize('abc', 'NFC')  (syntax error)
SELECT pg_catalog.int(1)                  -> SELECT int(1)                   (syntax error)

I think it's because _is_pg_catalog_func() still keeps the schema only for extract, position and xmlexists. If I got something wrong, please just ignore this.

@lelit lelit reopened this Oct 26, 2026
@lelit

lelit commented Oct 26, 2026

Copy link
Copy Markdown
Owner

Ok, it seems I conflated two different problems, sorry. As the others, I'm going to transplant this on v7 first.

lelit added a commit that referenced this pull request Oct 26, 2026
@lelit lelit closed this Oct 26, 2026
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.

2 participants