Skip to content

Commit

Permalink
Revert index scan functionality (#247)
Browse files Browse the repository at this point in the history
Reverting index scan feature as explained in #183.
  • Loading branch information
mkaruza committed Oct 7, 2024
1 parent 01f3050 commit 585a87a
Show file tree
Hide file tree
Showing 8 changed files with 3 additions and 515 deletions.
16 changes: 0 additions & 16 deletions include/pgduckdb/catalog/pgduckdb_table.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,4 @@ class PostgresHeapTable : public PostgresTable {
Oid oid;
};

class PostgresIndexTable : public PostgresTable {
public:
PostgresIndexTable(Catalog &catalog, SchemaCatalogEntry &schema, CreateTableInfo &info, Cardinality cardinality,
Snapshot snapshot, Path *path, PlannerInfo *planner_info);

public:
// -- Table API --
unique_ptr<BaseStatistics> GetStatistics(ClientContext &context, column_t column_id) override;
TableFunction GetScanFunction(ClientContext &context, unique_ptr<FunctionData> &bind_data) override;
TableStorageInfo GetStorageInfo(ClientContext &context) override;

private:
Path *path;
PlannerInfo *planner_info;
};

} // namespace duckdb
18 changes: 0 additions & 18 deletions include/pgduckdb/scan/index_scan_utils.hpp

This file was deleted.

99 changes: 0 additions & 99 deletions include/pgduckdb/scan/postgres_index_scan.hpp

This file was deleted.

29 changes: 0 additions & 29 deletions src/catalog/pgduckdb_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "duckdb/parser/parsed_data/create_table_info.hpp"
#include "pgduckdb/scan/postgres_seq_scan.hpp"
#include "pgduckdb/scan/postgres_scan.hpp"
#include "pgduckdb/scan/postgres_index_scan.hpp"

extern "C" {
#include "postgres.h"
Expand Down Expand Up @@ -80,32 +79,4 @@ PostgresHeapTable::GetStorageInfo(ClientContext &context) {
throw duckdb::NotImplementedException("GetStorageInfo not supported yet");
}

//===--------------------------------------------------------------------===//
// PostgresIndexTable
//===--------------------------------------------------------------------===//

PostgresIndexTable::PostgresIndexTable(Catalog &catalog, SchemaCatalogEntry &schema, CreateTableInfo &info,
Cardinality cardinality, Snapshot snapshot, Path *path,
PlannerInfo *planner_info)
: PostgresTable(catalog, schema, info, cardinality, snapshot), path(path), planner_info(planner_info) {
}

unique_ptr<BaseStatistics>
PostgresIndexTable::GetStatistics(ClientContext &context, column_t column_id) {
throw duckdb::NotImplementedException("GetStatistics not supported yet");
}

TableFunction
PostgresIndexTable::GetScanFunction(ClientContext &context, unique_ptr<FunctionData> &bind_data) {
RangeTblEntry *rte = planner_rt_fetch(path->parent->relid, planner_info);
bind_data = duckdb::make_uniq<pgduckdb::PostgresIndexScanFunctionData>(cardinality, path, planner_info, rte->relid,
snapshot);
return pgduckdb::PostgresIndexScanFunction();
}

TableStorageInfo
PostgresIndexTable::GetStorageInfo(ClientContext &context) {
throw duckdb::NotImplementedException("GetStorageInfo not supported yet");
}

} // namespace duckdb
29 changes: 3 additions & 26 deletions src/catalog/pgduckdb_transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,6 @@ FindMatchingRelEntry(Oid relid, PlannerInfo *planner_info) {
return nullptr;
}

static bool
IsIndexScan(const Path *nodePath) {
if (nodePath == nullptr) {
return false;
}

if (nodePath->pathtype == T_IndexScan || nodePath->pathtype == T_IndexOnlyScan) {
return true;
}

return false;
}

optional_ptr<CatalogEntry>
SchemaItems::GetTable(const string &entry_name, PlannerInfo *planner_info) {
auto it = tables.find(entry_name);
Expand Down Expand Up @@ -118,20 +105,10 @@ SchemaItems::GetTable(const string &entry_name, PlannerInfo *planner_info) {
CreateTableInfo info;
info.table = entry_name;
Cardinality cardinality = node_path ? node_path->rows : 1;
if (IsIndexScan(node_path)) {
RangeTblEntry *rte = planner_rt_fetch(node_path->parent->relid, planner_info);
rel_oid = rte->relid;
if (!PostgresTable::PopulateColumns(info, rel_oid, snapshot)) {
return nullptr;
}
table = make_uniq<PostgresIndexTable>(catalog, *schema, info, cardinality, snapshot, node_path, planner_info);
} else {
if (!PostgresTable::PopulateColumns(info, rel_oid, snapshot)) {
return nullptr;
}
table = make_uniq<PostgresHeapTable>(catalog, *schema, info, cardinality, snapshot, rel_oid);
if (!PostgresTable::PopulateColumns(info, rel_oid, snapshot)) {
return nullptr;
}

table = make_uniq<PostgresHeapTable>(catalog, *schema, info, cardinality, snapshot, rel_oid);
tables[entry_name] = std::move(table);
return tables[entry_name].get();
}
Expand Down
5 changes: 0 additions & 5 deletions src/pgduckdb_duckdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "pgduckdb/pgduckdb_options.hpp"
#include "pgduckdb/pgduckdb_duckdb.hpp"
#include "pgduckdb/scan/postgres_scan.hpp"
#include "pgduckdb/scan/postgres_index_scan.hpp"
#include "pgduckdb/scan/postgres_seq_scan.hpp"
#include "pgduckdb/pgduckdb_utils.hpp"
#include "pgduckdb/catalog/pgduckdb_storage.hpp"
Expand Down Expand Up @@ -98,15 +97,11 @@ DuckDBManager::LoadFunctions(duckdb::ClientContext &context) {
pgduckdb::PostgresSeqScanFunction seq_scan_fun;
duckdb::CreateTableFunctionInfo seq_scan_info(seq_scan_fun);

pgduckdb::PostgresIndexScanFunction index_scan_fun;
duckdb::CreateTableFunctionInfo index_scan_info(index_scan_fun);

auto &catalog = duckdb::Catalog::GetSystemCatalog(context);
context.transaction.BeginTransaction();
auto &instance = *database->instance;
duckdb::ExtensionUtil::RegisterType(instance, "UnsupportedPostgresType", duckdb::LogicalTypeId::VARCHAR);
catalog.CreateTableFunction(context, &seq_scan_info);
catalog.CreateTableFunction(context, &index_scan_info);
context.transaction.Commit();
}

Expand Down
113 changes: 0 additions & 113 deletions src/scan/index_scan_utils.cpp

This file was deleted.

Loading

0 comments on commit 585a87a

Please sign in to comment.