This is an automated email from the ASF dual-hosted git repository. jiaqizho pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/cloudberry.git
The following commit(s) were added to refs/heads/main by this push: new 7555993ef4c ORCA: inline some of basic wrapper function 7555993ef4c is described below commit 7555993ef4c729272f9549cd10228ea763a649ce Author: zhoujiaqi <zhouji...@hashdata.cn> AuthorDate: Thu Jul 3 13:53:27 2025 +0800 ORCA: inline some of basic wrapper function ORCA is written in C++, it cannot direct call the function which may cause the long jumps(cbdb kernel defined), so GP_WRAP is used to convert long jumps to the C++ exceptions. However, not all of kernel methods will generate the long jumps, so current commit changes kernel methods which won't generate long jumps to `static inline` function. --- src/backend/gpopt/gpdbwrappers.cpp | 280 ------------------------------------- src/include/gpopt/gpdbwrappers.h | 133 ++++++++++++++---- 2 files changed, 107 insertions(+), 306 deletions(-) diff --git a/src/backend/gpopt/gpdbwrappers.cpp b/src/backend/gpopt/gpdbwrappers.cpp index bbc686c3e37..84ff881da28 100644 --- a/src/backend/gpopt/gpdbwrappers.cpp +++ b/src/backend/gpopt/gpdbwrappers.cpp @@ -71,283 +71,6 @@ extern "C" { using namespace gpos; -bool -gpdb::BoolFromDatum(Datum d) -{ - GP_WRAP_START; - { - return DatumGetBool(d); - } - GP_WRAP_END; - return false; -} - -Datum -gpdb::DatumFromBool(bool b) -{ - GP_WRAP_START; - { - return BoolGetDatum(b); - } - GP_WRAP_END; - return 0; -} - -char -gpdb::CharFromDatum(Datum d) -{ - GP_WRAP_START; - { - return DatumGetChar(d); - } - GP_WRAP_END; - return '\0'; -} - -Datum -gpdb::DatumFromChar(char c) -{ - GP_WRAP_START; - { - return CharGetDatum(c); - } - GP_WRAP_END; - return 0; -} - -int8 -gpdb::Int8FromDatum(Datum d) -{ - GP_WRAP_START; - { - return DatumGetInt8(d); - } - GP_WRAP_END; - return 0; -} - -Datum -gpdb::DatumFromInt8(int8 i8) -{ - GP_WRAP_START; - { - return Int8GetDatum(i8); - } - GP_WRAP_END; - return 0; -} - -uint8 -gpdb::Uint8FromDatum(Datum d) -{ - GP_WRAP_START; - { - return DatumGetUInt8(d); - } - GP_WRAP_END; - return 0; -} - -Datum -gpdb::DatumFromUint8(uint8 ui8) -{ - GP_WRAP_START; - { - return UInt8GetDatum(ui8); - } - GP_WRAP_END; - return 0; -} - -int16 -gpdb::Int16FromDatum(Datum d) -{ - GP_WRAP_START; - { - return DatumGetInt16(d); - } - GP_WRAP_END; - return 0; -} - -Datum -gpdb::DatumFromInt16(int16 i16) -{ - GP_WRAP_START; - { - return Int16GetDatum(i16); - } - GP_WRAP_END; - return 0; -} - -uint16 -gpdb::Uint16FromDatum(Datum d) -{ - GP_WRAP_START; - { - return DatumGetUInt16(d); - } - GP_WRAP_END; - return 0; -} - -Datum -gpdb::DatumFromUint16(uint16 ui16) -{ - GP_WRAP_START; - { - return UInt16GetDatum(ui16); - } - GP_WRAP_END; - return 0; -} - -int32 -gpdb::Int32FromDatum(Datum d) -{ - GP_WRAP_START; - { - return DatumGetInt32(d); - } - GP_WRAP_END; - return 0; -} - -Datum -gpdb::DatumFromInt32(int32 i32) -{ - GP_WRAP_START; - { - return Int32GetDatum(i32); - } - GP_WRAP_END; - return 0; -} - -uint32 -gpdb::lUint32FromDatum(Datum d) -{ - GP_WRAP_START; - { - return DatumGetUInt32(d); - } - GP_WRAP_END; - return 0; -} - -Datum -gpdb::DatumFromUint32(uint32 ui32) -{ - GP_WRAP_START; - { - return UInt32GetDatum(ui32); - } - GP_WRAP_END; - return 0; -} - -int64 -gpdb::Int64FromDatum(Datum d) -{ - Datum d2 = d; - GP_WRAP_START; - { - return DatumGetInt64(d2); - } - GP_WRAP_END; - return 0; -} - -Datum -gpdb::DatumFromInt64(int64 i64) -{ - int64 ii64 = i64; - GP_WRAP_START; - { - return Int64GetDatum(ii64); - } - GP_WRAP_END; - return 0; -} - -uint64 -gpdb::Uint64FromDatum(Datum d) -{ - GP_WRAP_START; - { - return DatumGetUInt64(d); - } - GP_WRAP_END; - return 0; -} - -Datum -gpdb::DatumFromUint64(uint64 ui64) -{ - GP_WRAP_START; - { - return UInt64GetDatum(ui64); - } - GP_WRAP_END; - return 0; -} - -Oid -gpdb::OidFromDatum(Datum d) -{ - GP_WRAP_START; - { - return DatumGetObjectId(d); - } - GP_WRAP_END; - return 0; -} - -void * -gpdb::PointerFromDatum(Datum d) -{ - GP_WRAP_START; - { - return DatumGetPointer(d); - } - GP_WRAP_END; - return nullptr; -} - -float4 -gpdb::Float4FromDatum(Datum d) -{ - GP_WRAP_START; - { - return DatumGetFloat4(d); - } - GP_WRAP_END; - return 0; -} - -float8 -gpdb::Float8FromDatum(Datum d) -{ - GP_WRAP_START; - { - return DatumGetFloat8(d); - } - GP_WRAP_END; - return 0; -} - -Datum -gpdb::DatumFromPointer(const void *p) -{ - GP_WRAP_START; - { - return PointerGetDatum(p); - } - GP_WRAP_END; - return 0; -} - bool gpdb::AggregateExists(Oid oid) { @@ -719,9 +442,6 @@ gpdb::GetAggregateInfo(Aggref *aggref, Oid *aggtransfn, *aggtranstype = aggform->aggtranstype; *aggtransspace = aggform->aggtransspace; - (aggform->aggfinalmodify != AGGMODIFY_READ_WRITE); - - /* * Resolve the possibly-polymorphic aggregate transition type. */ diff --git a/src/include/gpopt/gpdbwrappers.h b/src/include/gpopt/gpdbwrappers.h index 39e294db8fa..ba710f994f7 100644 --- a/src/include/gpopt/gpdbwrappers.h +++ b/src/include/gpopt/gpdbwrappers.h @@ -63,82 +63,163 @@ struct ArrayExpr; #include "gpopt/utils/RelationWrapper.h" +// without GP_WRAP try...catch functions namespace gpdb { // convert datum to bool -bool BoolFromDatum(Datum d); +static inline bool BoolFromDatum(Datum d) +{ + return DatumGetBool(d); +} // convert bool to datum -Datum DatumFromBool(bool b); +static inline Datum DatumFromBool(bool b) +{ + return BoolGetDatum(b); +} // convert datum to char -char CharFromDatum(Datum d); +static inline char CharFromDatum(Datum d) +{ + return DatumGetChar(d); +} // convert char to datum -Datum DatumFromChar(char c); +static inline Datum DatumFromChar(char c) +{ + return CharGetDatum(c); +} // convert datum to int8 -int8 Int8FromDatum(Datum d); +static inline int8 Int8FromDatum(Datum d) +{ + return DatumGetInt8(d); +} // convert int8 to datum -Datum DatumFromInt8(int8 i8); +static inline Datum DatumFromInt8(int8 i8) +{ + return Int8GetDatum(i8); +} // convert datum to uint8 -uint8 Uint8FromDatum(Datum d); +static inline uint8 Uint8FromDatum(Datum d) +{ + return DatumGetUInt8(d); +} // convert uint8 to datum -Datum DatumFromUint8(uint8 ui8); +static inline Datum DatumFromUint8(uint8 ui8) +{ + return UInt8GetDatum(ui8); +} // convert datum to int16 -int16 Int16FromDatum(Datum d); +static inline int16 Int16FromDatum(Datum d) +{ + return DatumGetInt16(d); +} // convert int16 to datum -Datum DatumFromInt16(int16 i16); +static inline Datum DatumFromInt16(int16 i16) +{ + return Int16GetDatum(i16); +} // convert datum to uint16 -uint16 Uint16FromDatum(Datum d); +static inline uint16 Uint16FromDatum(Datum d) +{ + return DatumGetUInt16(d); +} // convert uint16 to datum -Datum DatumFromUint16(uint16 ui16); +static inline Datum DatumFromUint16(uint16 ui16) +{ + return UInt16GetDatum(ui16); +} // convert datum to int32 -int32 Int32FromDatum(Datum d); +static inline int32 Int32FromDatum(Datum d) +{ + return DatumGetInt32(d); +} // convert int32 to datum -Datum DatumFromInt32(int32 i32); +static inline Datum DatumFromInt32(int32 i32) +{ + return Int32GetDatum(i32); +} // convert datum to uint32 -uint32 lUint32FromDatum(Datum d); +static inline uint32 Uint32FromDatum(Datum d) +{ + return DatumGetUInt32(d); +} // convert uint32 to datum -Datum DatumFromUint32(uint32 ui32); +static inline Datum DatumFromUint32(uint32 ui32) +{ + return UInt32GetDatum(ui32); +} // convert datum to int64 -int64 Int64FromDatum(Datum d); +static inline int64 Int64FromDatum(Datum d) +{ + return DatumGetInt64(d); +} // convert int64 to datum -Datum DatumFromInt64(int64 i64); +static inline Datum DatumFromInt64(int64 i64) +{ + return Int64GetDatum(i64); +} // convert datum to uint64 -uint64 Uint64FromDatum(Datum d); +static inline uint64 Uint64FromDatum(Datum d) +{ + return DatumGetUInt64(d); +} // convert uint64 to datum -Datum DatumFromUint64(uint64 ui64); +static inline Datum DatumFromUint64(uint64 ui64) +{ + return UInt64GetDatum(ui64); +} // convert datum to oid -Oid OidFromDatum(Datum d); +static inline Oid OidFromDatum(Datum d) +{ + return DatumGetObjectId(d); +} // convert datum to generic object with pointer handle -void *PointerFromDatum(Datum d); +static inline void *PointerFromDatum(Datum d) +{ + return DatumGetPointer(d); +} + +// convert pointer to datum +static inline Datum DatumFromPointer(const void *p) +{ + return PointerGetDatum(p); +} // convert datum to float4 -float4 Float4FromDatum(Datum d); +static inline float4 Float4FromDatum(Datum d) +{ + return DatumGetFloat4(d); +} // convert datum to float8 -float8 Float8FromDatum(Datum d); +static inline float8 Float8FromDatum(Datum d) +{ + return DatumGetFloat8(d); +} -// convert pointer to datum -Datum DatumFromPointer(const void *p); +} + +namespace gpdb +{ // does an aggregate exist with the given oid bool AggregateExists(Oid oid); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cloudberry.apache.org For additional commands, e-mail: commits-h...@cloudberry.apache.org