Skip to content

Support for secrets/endpoints via FDW - #383

Draft
Thom Chiovoloni (thomcc-work) wants to merge 9 commits into
mainfrom
thomcc/secrets-fdw
Draft

Support for secrets/endpoints via FDW#383
Thom Chiovoloni (thomcc-work) wants to merge 9 commits into
mainfrom
thomcc/secrets-fdw

Conversation

@thomcc-work

Copy link
Copy Markdown
Contributor

WIP. Not totally implemented. It's just easier for me to review local changes on GH's UI.

Several of my tasks require passing additional options to `df.http` and
`df.http_multipart`. Unfortunately, adding new parameters to these
functions is Hard. The normal approach (for example taken in #377 with
the `df.loop`) is to keep the old function around, renamed (but with the
same wrapper name). This is fine (and even avoids issues when
`ALTER EXTENSION UPDATE` is not run), but `df.http` and
`df.http_multipart` are functions that will likely have a bunch
of `GRANT`s (and those grants are semantically meaningful to
`pg_durable` beyond our ability to call the functions).

If we try to capture and re-issue[^1] those grants from an extension, PG
will record the grants as coming from the extension update script, and
assume it doesn't need to provide them in pg_dump, so then the
pg_restore won't have them, meaning logical restore and/or PG upgrades
will be broken.

The AI suggested the right approach was some catalog feng shui but that
it would take a while to engineer. I asked on the PostgreSQL discord,
and one of the PG committers (rhass) told me that this (trying to copy
grants from one function to another) was something that you should
never do, and to just have users reissue the grants on update.

So... instead of that, we just add a combinator function that
manipulates the durofut JSON directly to add the options. For
example, you'd use it like:

```sql
df.with_http_options(
    df.http(...),
    '{"options": "here"}'::jsonb
);
```

This admittedly is less ergonomic than adding an `options =>` parameter
for `df.http`, but... well, yeah.

If we want, we could make this into an operator, e.g. allowing
`df.http(...) <some-operator> '{"options": "here"}'` or something like
that? I don't have strong feelings.

[^1]: This is ignoring the fact that the permissions may be different
    now, for example even ignoring the next issue this won't work quite
    right if a delegator of a grant became a superuser.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.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.

1 participant