diff --git a/include/pgduckdb/pg/types.hpp b/include/pgduckdb/pg/types.hpp index 4a59c25..66a3b46 100644 --- a/include/pgduckdb/pg/types.hpp +++ b/include/pgduckdb/pg/types.hpp @@ -6,5 +6,5 @@ namespace pgduckdb::pg { bool IsArrayType(Oid type_oid); bool IsDomainType(Oid type_oid); bool IsArrayDomainType(Oid type_oid); -Oid GetBaseDuckColumnType(Oid attribute_typoid); +Oid GetBaseDuckColumnType(Oid attribute_type_oid); } diff --git a/src/pg/types.cpp b/src/pg/types.cpp index bea2a91..3fba995 100644 --- a/src/pg/types.cpp +++ b/src/pg/types.cpp @@ -32,15 +32,14 @@ IsArrayDomainType(Oid type_oid) { return is_array_domain; } -Oid -GetBaseDuckColumnType(Oid attribute_typoid) { - std::lock_guard lock(pgduckdb::GlobalProcessLock::GetLock()); - Oid typoid = attribute_typoid; - if (get_typtype(attribute_typoid) == TYPTYPE_DOMAIN) { +static Oid +GetBaseDuckColumnType_C(Oid attribute_type_oid) { + Oid typoid = attribute_type_oid; + if (get_typtype(attribute_type_oid) == TYPTYPE_DOMAIN) { /* It is a domain type that needs to be reduced to its base type */ - typoid = getBaseType(attribute_typoid); - } else if (type_is_array(attribute_typoid)) { - Oid eltoid = get_base_element_type(attribute_typoid); + typoid = getBaseType(attribute_type_oid); + } else if (type_is_array(attribute_type_oid)) { + Oid eltoid = get_base_element_type(attribute_type_oid); if (OidIsValid(eltoid) && get_typtype(eltoid) == TYPTYPE_DOMAIN) { /* When the member type of an array is domain, you need to build a base array type */ typoid = get_array_type(getBaseType(eltoid)); @@ -49,4 +48,9 @@ GetBaseDuckColumnType(Oid attribute_typoid) { return typoid; } +Oid +GetBaseDuckColumnType(Oid attribute_type_oid) { + return PostgresFunctionGuard(GetBaseDuckColumnType_C, attribute_type_oid); +} + } // namespace pgduckdb::pg