Add preflight check for source sequence SELECT privileges#947
Conversation
|
Could you please rebase your branch? |
fe0aadb to
f3238be
Compare
| JOIN pg_namespace sn ON sn.oid = s.relnamespace | ||
| WHERE t.relkind IN ('r', 'p') | ||
| AND s.relkind = 'S' | ||
| AND d.deptype = 'a' |
There was a problem hiding this comment.
Does this condition include generated identity columns? Could you please add a test to verify that those columns are checked as well?
There was a problem hiding this comment.
Thanks, I missed the identity-column case. I've updated the sequence privilege query to account for identity-backed sequences and added integration test covering GENERATED ALWAYS AS IDENTITY
| ` | ||
|
|
||
| const sourceSequenceSelectPrivilegesQuery = ` | ||
| SELECT |
There was a problem hiding this comment.
I've been testing this a bit more, and found that this query cannot find all sequences that are snapshotted. It is missing the sequences that belong to the schema, but not owned by any columns. Sorry for pointing it out now. Could you please make sure the check includes:
- sequences of the table
- generated identity columns of the table
- all sequences in the selected schema
There was a problem hiding this comment.
Thanks. I've updated the check to cover column-owned sequences, identity-backed sequences and free-standing sequences in selected schemas and added test for those cases.
kvch
left a comment
There was a problem hiding this comment.
Thank you for both the contribution and your patience.
Description
Add a second access preflight check that verifies the source role can SELECT from in-scope sequences used by snapshot tables.
This extends pgstream -check --access beyond table read privileges so sequence-value snapshot failures are caught earlier with a direct remediation message.
Related Issue(s)
pgstream checkcommand for pre-migration sanity checks #897Type of Change
Please select the relevant option(s):
Changes Made
SourceSequenceSelectPrivilegesChecktopkg/stream/preflight/access.goBuildAccessChecksto run both table and sequence access checks with the same shared source connectionTesting
Checklist
Additional Notes