Add snapshot-aware catalog lookup SQL functions#9693
Open
zilder wants to merge 1 commit into
Open
Conversation
78741ee to
9217153
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
774f9a4 to
0eaddbd
Compare
Introduce four _timescaledb_functions.* lookups that resolve TimescaleDB catalog entries against the active snapshot: chunk_id_by_name(schema name, table name) -> int4 compressed_chunk_parent_id(int4) -> int4 chunk_hypertable_id(int4) -> int4 hypertable_id_to_relid(int4) -> regclass Each function reads GetActiveSnapshot() and passes it explicitly into the catalog scan rather than relying on the scanner's default of SnapshotSelf. Callers that need a non-default snapshot -- e.g. a custom logical decoding plugin running against a HistoricSnapshot -- push it before invoking: PushActiveSnapshot(snapshot); /* DirectFunctionCall ... */ PopActiveSnapshot(); From an ordinary SQL session the executor's transaction snapshot is in effect, so the functions also work for ad-hoc use. All four return NULL on miss rather than erroring, so callers can skip rows that don't (yet) resolve.
0eaddbd to
f68d437
Compare
|
@pnthao, @antekresic: please review this pull request.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduce four snapshot-aware _timescaledb_functions.* lookup functions that resolve TimescaleDB catalog entries against the active snapshot:
chunk_id_by_name(schema name, table name) -> int4compressed_chunk_parent_id(int4) -> int4chunk_hypertable_id(int4) -> int4hypertable_relid_by_id(int4) -> regclassEach function reads
GetActiveSnapshot()and passes it explicitly into the catalog scan rather than relying on the scanner's default ofSnapshotSelf. Callers that need a non-default snapshot -- e.g. a custom logical decoding plugin running against a HistoricSnapshot -- push it before invoking:From an ordinary SQL session the executor's transaction snapshot is in effect, so the functions also work for ad-hoc use. All four return NULL on miss rather than erroring, so callers can skip rows that don't (yet) resolve.
Follow-up for #9684