Skip to content

Schema-qualify hypopg_reset() and hypopg_get_indexdef() calls (stacked on #13) - #14

Merged
utkarash2991 merged 3 commits into
mainfrom
utkarashsingh/psqlext-1773-schema-qualify-hypopg-calls-v2
Oct 8, 2026
Merged

utkarash2991 merged 3 commits into
mainfrom
utkarashsingh/psqlext-1773-schema-qualify-hypopg-calls-v2

Conversation

@utkarash2991

@utkarash2991 utkarash2991 commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #13

This targets utkarashsingh/psqlext-1773-force-upgrade-chain (#13), not main - merge #13 first.

Supersedes #12, which used a standalone index_advisor--0.2.1.sql script. With #13 merged, every version past 0.1.0 is reachable only via incremental upgrade scripts, so this just adds index_advisor--0.2.0--0.2.1.sql - no standalone "latest" script.

Summary

Two hypopg calls in index_advisor() were unqualified instead of schema-qualified like the rest of the function:

  • hypopg_reset() - fails with function hypopg_reset() does not exist whenever hypopg isn't on the caller's search_path (e.g. installed into a separate schema from where index_advisor itself lives, which is how Supabase installs it).
  • hypopg_get_indexdef(indexrelid) - same root cause, but called inside a dynamically-built SQL string (execute format(...)), so it fails silently into index_advisor()'s own errors array at runtime instead of raising.

Tracked in https://linear.app/supabase/issue/PSQLEXT-1773

@utkarash2991
utkarash2991 added this pull request to stack #16 October 5, 2026 19:47
@utkarash2991
utkarash2991 force-pushed the utkarashsingh/psqlext-1773-schema-qualify-hypopg-calls-v2 branch from 2f18fbb to 3027546 Compare October 6, 2026 10:47
@utkarash2991
utkarash2991 deleted the branch main October 6, 2026 10:48
Base automatically changed from utkarashsingh/psqlext-1773-force-upgrade-chain to main October 6, 2026 10:48
Both were called unqualified, so they fail with "function ... does not
exist" whenever hypopg isn't on the caller's search_path (e.g. installed
in a separate schema from where index_advisor runs). hypopg_create_index()
and hypopg() were already qualified via the existing hypopg_schema_name
lookup; these two just hadn't been.

hypopg_get_indexdef() is called inside a dynamically-built SQL string, so
it fails silently into index_advisor()'s own errors array rather than
raising - it doesn't show up under plpgsql_check/static analysis, only at
runtime.

Ships as 0.2.1, as a pure incremental upgrade script on top of the forced
upgrade chain from the previous PR - no standalone "latest" script needed.
@utkarash2991
utkarash2991 force-pushed the utkarashsingh/psqlext-1773-schema-qualify-hypopg-calls-v2 branch from 3027546 to 59185e6 Compare October 6, 2026 10:51
Comment thread index_advisor--0.2.0--0.2.1.sql Resolved
Per hanefi's review comment on #13 - 0.2.1 hasn't been released
anywhere yet, so there's no reason to burn a second version number
(0.2.2) for more fixes found before the first real release. These two
bugs (greedy block-comment regex deleting code between separate
comments, and bare "deallocate all" wiping every prepared statement in
the session) were originally a separate stacked PR on top of this one -
folding them in here instead, so 0.2.1 ships as the one complete fix.
utkarash2991 added a commit that referenced this pull request Oct 6, 2026
Two issues found during review of the function, both silent and both
real:

1. The block-comment regex ('\/\*.+\*\/') is greedy across every /* */
   pair in the query, not just one. A query with two separate block
   comments had everything between the first "/*" and the last "*/"
   deleted - including real code in between - with no error raised.
   Fixed with a non-greedy quantifier.

2. The two bare "deallocate all;" calls wipe every prepared statement in
   the calling session, not just index_advisor's own internal one. In a
   pooled or persistent connection (PostgREST, pgbouncer session mode)
   this silently breaks whatever else that connection had prepared.
   Fixed by checking pg_prepared_statements for the specific name before
   deallocating it - DEALLOCATE has no IF EXISTS clause, so this needs an
   explicit existence check rather than DROP-style IF EXISTS syntax.

Edits the same 0.2.0--0.2.1.sql script from #14 rather than bumping to
0.2.2 - 0.2.1 hasn't shipped anywhere yet, so there's no reason for two
version bumps when both PRs land in the same release.
@AndrewJackson2020

AndrewJackson2020 commented Oct 6, 2026 •

Copy link
Copy Markdown

@utkarash2991 it seems like the stacked PR setup here is broken, if you fix I can review.

@utkarash2991

Copy link
Copy Markdown
Contributor Author

@utkarash2991 it seems like the stacked PR setup here is broken, if you fix I can review.

@AndrewJackson2020 I accidentally closed #15. The changes are there in other PR: #17 . I am really not able to fix the stacked Pr links as shown in the UI above.

@utkarash2991
utkarash2991 merged commit 8fc0e7a into main Oct 8, 2026
4 checks passed
@utkarash2991
utkarash2991 deleted the utkarashsingh/psqlext-1773-schema-qualify-hypopg-calls-v2 branch October 8, 2026 14:56
utkarash2991 added a commit that referenced this pull request Oct 22, 2026
…omment-regex-and-deallocate

Fix greedy comment regex and deallocate-all blast radius (stacked on #14)
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.

4 participants