From 67da79d76afe387772d79c88409a5318188a0d45 Mon Sep 17 00:00:00 2001 From: Mark Raasveldt Date: Tue, 9 Apr 2024 16:11:50 +0200 Subject: [PATCH 1/3] Consider relkind also when filtering relations --- src/storage/postgres_table_set.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/storage/postgres_table_set.cpp b/src/storage/postgres_table_set.cpp index 95d6048b..06f9df99 100644 --- a/src/storage/postgres_table_set.cpp +++ b/src/storage/postgres_table_set.cpp @@ -38,7 +38,7 @@ SELECT pg_namespace.oid AS namespace_id, relname, NULL relpages, NULL attname, N FROM pg_class JOIN pg_namespace ON relnamespace = pg_namespace.oid JOIN pg_constraint ON (pg_class.oid=pg_constraint.conrelid) -WHERE contype IN ('p', 'u') ${CONDITION} +WHERE relkind IN ('r', 'v', 'm', 'f', 'p') AND contype IN ('p', 'u') ${CONDITION} ORDER BY namespace_id, relname, attnum, constraint_id; )"; string condition; @@ -98,6 +98,9 @@ void PostgresTableSet::AddConstraint(PostgresResult &result, idx_t row, Postgres vector columns; for (auto &split : splits) { auto index = std::stoull(split); + if (index >= create_info.columns.LogicalColumnCount()) { + return; + } columns.push_back(create_info.columns.GetColumn(LogicalIndex(index - 1)).Name()); } From 018d0f6134cbb6b6130600e7253b1f05d1bea32c Mon Sep 17 00:00:00 2001 From: Mark Raasveldt Date: Tue, 9 Apr 2024 16:14:46 +0200 Subject: [PATCH 2/3] > --- src/storage/postgres_table_set.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/storage/postgres_table_set.cpp b/src/storage/postgres_table_set.cpp index 06f9df99..acd78385 100644 --- a/src/storage/postgres_table_set.cpp +++ b/src/storage/postgres_table_set.cpp @@ -98,7 +98,7 @@ void PostgresTableSet::AddConstraint(PostgresResult &result, idx_t row, Postgres vector columns; for (auto &split : splits) { auto index = std::stoull(split); - if (index >= create_info.columns.LogicalColumnCount()) { + if (index > create_info.columns.LogicalColumnCount()) { return; } columns.push_back(create_info.columns.GetColumn(LogicalIndex(index - 1)).Name()); From 0a4f8512da6e63df845b1eb343db8da471c3ea94 Mon Sep 17 00:00:00 2001 From: Mark Raasveldt Date: Tue, 9 Apr 2024 16:15:04 +0200 Subject: [PATCH 3/3] Also consider the "0" case here --- src/storage/postgres_table_set.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/storage/postgres_table_set.cpp b/src/storage/postgres_table_set.cpp index acd78385..3ae8a01b 100644 --- a/src/storage/postgres_table_set.cpp +++ b/src/storage/postgres_table_set.cpp @@ -98,7 +98,7 @@ void PostgresTableSet::AddConstraint(PostgresResult &result, idx_t row, Postgres vector columns; for (auto &split : splits) { auto index = std::stoull(split); - if (index > create_info.columns.LogicalColumnCount()) { + if (index <= 0 || index > create_info.columns.LogicalColumnCount()) { return; } columns.push_back(create_info.columns.GetColumn(LogicalIndex(index - 1)).Name());