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.
This PR upstreams the changes discussed in the last progress update meeting.
This is essentially
pg_quack
updated to use the C++ API (DuckDB
,Connection
,Appender
,DBConfig
objects)One additional change I've had to make to get it to work with PG16.0 is this, of which I'm not sure this is the equivalent behavior:
Tishj/pg_extension@5b5a678
PostgresReplacementScan
ReplacementScans are a part of DuckDB's extension mechanism, they allow us to hook into a bind of a table ref when that bind can not be fulfilled by the catalog.
We register a replacement scan that receives the
QueryDesc
object through theReplacementScanData
, in the replacement scan it uses that object to determine whichRangeTblEntry
corresponds to the table we're binding.From the replacement scan we return a
TableFunctionRef
, where we essentially transform the received tableref (i.e "tbl") into a call to a table function, providing both theSnapshot
and theRangeTblEntry
as POINTER to the function.PostgresScanFunction
We create a TableFunction that will use the
Snapshot
andRangeTblEntry
to scan Postgres using the TableAM interface from within DuckDB.