From d92dda4780309eb674074e7d63a3b1fc18a2c8ba Mon Sep 17 00:00:00 2001 From: Mark Raasveldt Date: Tue, 19 Mar 2024 23:44:46 +0100 Subject: [PATCH] Don't query pg_enum in older postgres versions --- src/include/storage/postgres_type_set.hpp | 2 +- src/storage/postgres_schema_set.cpp | 5 ++++- src/storage/postgres_type_set.cpp | 10 +++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/include/storage/postgres_type_set.hpp b/src/include/storage/postgres_type_set.hpp index d784bf9c..e6dba17f 100644 --- a/src/include/storage/postgres_type_set.hpp +++ b/src/include/storage/postgres_type_set.hpp @@ -25,7 +25,7 @@ class PostgresTypeSet : public PostgresInSchemaSet { public: optional_ptr CreateType(ClientContext &context, CreateTypeInfo &info); - static string GetInitializeEnumsQuery(); + static string GetInitializeEnumsQuery(PostgresVersion version); static string GetInitializeCompositesQuery(); protected: diff --git a/src/storage/postgres_schema_set.cpp b/src/storage/postgres_schema_set.cpp index 940407b0..fbdbc91a 100644 --- a/src/storage/postgres_schema_set.cpp +++ b/src/storage/postgres_schema_set.cpp @@ -5,6 +5,7 @@ #include "storage/postgres_transaction.hpp" #include "duckdb/parser/parsed_data/create_schema_info.hpp" #include "storage/postgres_table_set.hpp" +#include "storage/postgres_catalog.hpp" namespace duckdb { @@ -40,9 +41,11 @@ ORDER BY oid; } void PostgresSchemaSet::LoadEntries(ClientContext &context) { + auto &pg_catalog = catalog.Cast(); + auto pg_version = pg_catalog.GetPostgresVersion(); string schema_query = PostgresSchemaSet::GetInitializeQuery(); string tables_query = PostgresTableSet::GetInitializeQuery(); - string enum_types_query = PostgresTypeSet::GetInitializeEnumsQuery(); + string enum_types_query = PostgresTypeSet::GetInitializeEnumsQuery(pg_version); string composite_types_query = PostgresTypeSet::GetInitializeCompositesQuery(); string index_query = PostgresIndexSet::GetInitializeQuery(); diff --git a/src/storage/postgres_type_set.cpp b/src/storage/postgres_type_set.cpp index 40a31ce2..7ea42532 100644 --- a/src/storage/postgres_type_set.cpp +++ b/src/storage/postgres_type_set.cpp @@ -20,7 +20,15 @@ PostgresTypeSet::PostgresTypeSet(PostgresSchemaEntry &schema, unique_ptr