Skip to content

Commit

Permalink
Updated the IsCatalogTable function information (#417)
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo-XM-Zeng authored Nov 11, 2024
1 parent 1b4514d commit f6a056e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/pgduckdb_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ static ProcessUtility_hook_type prev_process_utility_hook = NULL;
static ExplainOneQuery_hook_type prev_explain_one_query_hook = NULL;

static bool
IsCatalogTable(List *tables) {
foreach_node(RangeTblEntry, table, tables) {
if (table->rtekind == RTE_SUBQUERY) {
ContainsCatalogTable(List *rtes) {
foreach_node(RangeTblEntry, rte, rtes) {
if (rte->rtekind == RTE_SUBQUERY) {
/* Check Subquery rtable list if any table is from PG catalog */
if (IsCatalogTable(table->subquery->rtable)) {
if (ContainsCatalogTable(rte->subquery->rtable)) {
return true;
}
}

if (table->relid) {
auto rel = RelationIdGetRelation(table->relid);
if (rte->relid) {
auto rel = RelationIdGetRelation(rte->relid);
auto namespace_oid = RelationGetNamespace(rel);
RelationClose(rel);
if (namespace_oid == PG_CATALOG_NAMESPACE || namespace_oid == PG_TOAST_NAMESPACE) {
Expand Down Expand Up @@ -159,7 +159,7 @@ IsAllowedStatement(Query *query, bool throw_error = false) {
* because DuckDB has its own pg_catalog tables that contain different data
* then Postgres its pg_catalog tables.
*/
if (IsCatalogTable(query->rtable)) {
if (ContainsCatalogTable(query->rtable)) {
elog(elevel, "DuckDB does not support querying PG catalog tables");
return false;
}
Expand Down

0 comments on commit f6a056e

Please sign in to comment.