Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated the IsCatalogTable function information #417

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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