This is an automated email from the ASF dual-hosted git repository.

maxyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git

commit 85d7ba83f87335b2a45f1652da743552dd3b30bf
Author: THANATOSLAVA <[email protected]>
AuthorDate: Wed Oct 19 11:00:24 2022 -0700

    Patch handling of composite type returning TVF that evaluates to const 
(#14283)
    
    Issue:
    Regression in GPDB compatibility with PostGIS. Exception hit by NULL Datum 
pointer.
    
    Root cause:
    While implementing support for composite type returning TVF, we didn't 
factor in unsupported PostGIS functions.
    
    Solution:
    Patch 394c058. While translating query to DXL, check if the const value of 
TVF is NULL. If so, fall back on planner.
    
    Implementation:
    [CTranslatorQueryToDXL] -- Raise exception if the const value of TVF cannot 
be populated
    
    Co-authored-by: Jingyu Wang <[email protected]>
---
 src/backend/gpopt/translate/CTranslatorQueryToDXL.cpp | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/backend/gpopt/translate/CTranslatorQueryToDXL.cpp 
b/src/backend/gpopt/translate/CTranslatorQueryToDXL.cpp
index 3045ed6d35..58dedc3ca9 100644
--- a/src/backend/gpopt/translate/CTranslatorQueryToDXL.cpp
+++ b/src/backend/gpopt/translate/CTranslatorQueryToDXL.cpp
@@ -3696,6 +3696,16 @@ CTranslatorQueryToDXL::TranslateTVFToDXL(const 
RangeTblEntry *rte,
        // funcexpr evaluates to const and returns composite type
        if (IsA(rtfunc->funcexpr, Const))
        {
+               // If the const is NULL, the const value cannot be populated
+               // Raise exception
+               // This happens to PostGIS functions, which aren't supported
+               const Const *constant = (Const *) rtfunc->funcexpr;
+               if (constant->constisnull)
+               {
+                       GPOS_RAISE(gpdxl::ExmaDXL, 
gpdxl::ExmiQuery2DXLUnsupportedFeature,
+                                          GPOS_WSZ_LIT("Row-type variable"));
+               }
+
                CDXLNode *constValue = 
m_scalar_translator->TranslateScalarToDXL(
                        (Expr *) (rtfunc->funcexpr), m_var_to_colid_map);
                tvf_dxlnode->AddChild(constValue);


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to