Skip to content

Commit

Permalink
Get rid of PostgresContextState (#252)
Browse files Browse the repository at this point in the history
Since #247 is merged PostgresContextState is not actually used anymore.
So this removes it completely. This will make a bunch of PRs easier to
implement, specifically #241 and #206.
  • Loading branch information
JelteF authored Oct 7, 2024
1 parent b319fa1 commit 3c88ef5
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 28 deletions.
13 changes: 0 additions & 13 deletions include/pgduckdb/scan/postgres_scan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,6 @@ class PostgresScanLocalState {
bool m_exhausted_scan;
};

struct PostgresContextState : public duckdb::ClientContextState {
public:
PostgresContextState(List *rtables, List *needed_columns, const char *query_string)
: m_rtables(rtables), m_needed_columns(needed_columns), m_query_string(query_string) {
}
~PostgresContextState() override {};

public:
List *m_rtables;
List *m_needed_columns;
std::string m_query_string;
};

duckdb::unique_ptr<duckdb::TableRef> PostgresReplacementScan(duckdb::ClientContext &context,
duckdb::ReplacementScanInput &input,
duckdb::optional_ptr<duckdb::ReplacementScanData> data);
Expand Down
4 changes: 0 additions & 4 deletions src/catalog/pgduckdb_transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,6 @@ PostgresTransaction::GetSchema(const string &name) {

optional_ptr<CatalogEntry>
PostgresTransaction::GetCatalogEntry(CatalogType type, const string &schema, const string &name) {
auto scan_data = context.lock()->registered_state->Get<pgduckdb::PostgresContextState>("postgres_state");
if (!scan_data) {
throw InternalException("Could not find 'postgres_state' in 'PostgresTransaction::GetCatalogEntry'");
}
switch (type) {
case CatalogType::TABLE_ENTRY: {
auto it = schemas.find(schema);
Expand Down
2 changes: 0 additions & 2 deletions src/pgduckdb_duckdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,6 @@ DuckdbCreateConnection(List *rtables, List *needed_columns, const char *query) {
auto con = duckdb::make_uniq<duckdb::Connection>(db);
auto &context = *con->context;

context.registered_state->Insert("postgres_state",
duckdb::make_shared_ptr<PostgresContextState>(rtables, needed_columns, query));
auto res = context.Query("set search_path='pgduckdb.main'", false);
if (res->HasError()) {
elog(WARNING, "(DuckDB) %s", res->GetError().c_str());
Expand Down
9 changes: 0 additions & 9 deletions src/scan/postgres_scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,6 @@ PostgresReplacementScan(duckdb::ClientContext &context, duckdb::ReplacementScanI

auto &schema_name = input.schema_name;
auto &table_name = input.table_name;
auto scan_data = context.registered_state->Get<PostgresContextState>("postgres_state");
if (!scan_data) {
/* There is no scan data provided by postgres so we cannot access any
* of postgres tables. This is the case for queries that are not
* directly based on a Postgres query, such as queries that pg_duckdb
* executes internally like CREATE SECRET.
*/
return nullptr;
}

auto relid = FindMatchingRelation(schema_name, table_name);

Expand Down

0 comments on commit 3c88ef5

Please sign in to comment.