Skip to content

Conversation

eeeebbbbrrrr
Copy link
Collaborator

Ticket(s) Closed

  • Closes #

What

It's possible that when upgrading pg_search from v0.15.26 to v0.17.x we could generate an ERROR complaining that
paradedb.terms_with_operator(...) doesn't exist if the user upgraded the extension binary but has not yet run ALTER EXTENSION pg_search UPDATE;.

This fixes that by inspecting the catalogs directly when it's necessary to lookup that function and plumbing through an Option<pg_sys::Oid> return value.

Why

To help users/customers/partners better deal with upgrading from really old pg_search versions.

How

Tests

Existing tests pass, especially the ones added in #2730, and a new regress test has been added that explicitly removes the function from the schema and ensures the query still works (tho with a different plan, of course).

It's possible that when upgrading pg_search from `v0.15.26` to `v0.17.x`
we could generate an ERROR complaining that
`paradedb.terms_with_operator(...)` doesn't exist if the user upgraded
the extension binary but has not yet run `ALTER EXTENSION pg_search
UPDATE;`.

This fixes that by inspecting the catalogs directly when it's necessary
to lookup that function and plumbing through an `Option<pg_sys::Oid>`
return value.
@stuhood stuhood added cherry-pick/0.17.x Request that this PR to `main` should get an automatic cherry-pick PR to `0.17.x` after it lands. cherry-pick/0.18.x Request that this PR to `main` should get an automatic cherry-pick PR to `0.18.x` after it lands. and removed cherry-pick/0.17.x Request that this PR to `main` should get an automatic cherry-pick PR to `0.17.x` after it lands. cherry-pick/0.18.x Request that this PR to `main` should get an automatic cherry-pick PR to `0.18.x` after it lands. labels Aug 21, 2025
Copy link
Contributor

@stuhood stuhood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

As discussed, I think that tagging these with the versions when we expect to be able to delete them would be great to look at when we pick this change to main.

@eeeebbbbrrrr
Copy link
Collaborator Author

As discussed, I think that tagging these with the versions when we expect to be able to delete them would be great to look at when we pick this change to main.

I don't understand. What in this PR do you believe will or should eventually be deleted?

@stuhood
Copy link
Contributor

stuhood commented Aug 21, 2025

What in this PR do you believe will or should eventually be deleted?

Nothing, because this PR is bound for 0.17.x. But on main, I think that we'll want to make these conditionals only live long enough to allow upgrades across "some reasonable number of minor versions"... i.e. 3 minor versions 0.15.x -> 0.18.x... and then eventually convert them into infallible/required.

@eeeebbbbrrrr
Copy link
Collaborator Author

eeeebbbbrrrr commented Aug 21, 2025

I'm sorry. What conditionals? There's nothing in this PR that adds code we might remove later. What it does is makes the current code resilient in the face of a schema object not existing.

@stuhood
Copy link
Contributor

stuhood commented Aug 21, 2025

I'm sorry. What conditionals? There's nothing in this PR that adds code we might remove later. What it does is makes the current code resilient in the face of a schema object not existing.

terms_with_operator not existing is a case that we only expect when upgrading from 0.15.x, I think? So if we decided not to support upgrading from 0.15.x any more, then we could make the lookup for that method non-Optional, and callers would be able to assume it exists, rather than having a fallback method for what to do when it doesn't.

@eeeebbbbrrrr
Copy link
Collaborator Author

eeeebbbbrrrr commented Aug 21, 2025

I see...

terms_with_operator not existing is a case that we only expect when upgrading from 0.15.x, I think?

technically, yes.

So if we decided not to support upgrading from 0.15.x any more, then we could make the lookup for that method non-Optional, and callers would be able to assume it exists, rather than having a fallback method for what to do when it doesn't.

In this case, if for whatever reason the function doesn't exist we can't produce a custom scan that requires that function, so we should either produce a different custom scan or no custom scan. We probably shouldn't ERROR.

As you can see in the regression test in this PR, it is possible for a superuser to just drop the function entirely. Maybe they should get what they deserve in that case but we can still successfully get their query answered with basically a few ?'s.

For my own sanity I'm internally rationalizing this PR not as "let us upgrade from 0.15.26 cleanly" but "let us be resilient when the schema doesn't match our expectations." And I don't think resiliency is something we'd want to later revert. In fact, I intend to do more of this as part of cherry-picking this to main.

@eeeebbbbrrrr eeeebbbbrrrr merged commit 2bb7c02 into 0.17.x Aug 21, 2025
18 of 20 checks passed
@eeeebbbbrrrr eeeebbbbrrrr deleted the eebbrr/backcomapt-to-0.15.26 branch August 21, 2025 19:17
eeeebbbbrrrr added a commit that referenced this pull request Sep 2, 2025
Cherry picks PR #3013, which only landed in 0.17.x, to `main` and
`0.18.x` via the label.
github-actions bot pushed a commit that referenced this pull request Sep 2, 2025
Cherry picks PR #3013, which only landed in 0.17.x, to `main` and
`0.18.x` via the label.
eeeebbbbrrrr added a commit that referenced this pull request Sep 2, 2025
Cherry picks PR #3013, which only landed in 0.17.x, to `main` and
`0.18.x` via the label.

---------

Co-authored-by: Eric Ridge <eebbrr@gmail.com>
Co-authored-by: Eric B. Ridge <eebbrr@paradedb.com>
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