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

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

commit 5d86a49b131b808263c604f41b3b5de0e32fd4ed
Author: Chris Hajas <[email protected]>
AuthorDate: Thu Aug 10 15:05:27 2023 -0700

    Remove unused error messages in Orca
    
    These aren't referenced/used anywhere, so remove them.
---
 src/backend/gpopt/CGPOptimizer.cpp                 | 48 +-------------
 src/backend/gpopt/utils/COptTasks.cpp              |  1 -
 src/backend/gporca/libgpos/include/gpos/_api.h     |  3 -
 src/backend/gporca/libgpos/src/_api.cpp            | 20 +-----
 .../libnaucrates/include/naucrates/exception.h     | 14 ----
 src/backend/gporca/libnaucrates/src/exception.cpp  | 74 ----------------------
 src/include/gpopt/utils/COptTasks.h                |  4 --
 7 files changed, 3 insertions(+), 161 deletions(-)

diff --git a/src/backend/gpopt/CGPOptimizer.cpp 
b/src/backend/gpopt/CGPOptimizer.cpp
index f4beabdf08..88100e9d46 100644
--- a/src/backend/gpopt/CGPOptimizer.cpp
+++ b/src/backend/gpopt/CGPOptimizer.cpp
@@ -69,56 +69,12 @@ CGPOptimizer::GPOPTOptimizedPlan(
 
                // Special handler for a few common user-facing errors. In 
particular,
                // we want to use the correct error code for these, in case an 
application
-               // tries to do something smart with them. Also, 
ERRCODE_INTERNAL_ERROR
-               // is handled specially in elog.c, and we don't want that for 
"normal"
-               // application errors.
-               if (GPOS_MATCH_EX(ex, gpdxl::ExmaDXL,
-                                                 
gpdxl::ExmiQuery2DXLNotNullViolation))
-               {
-                       if (errstart(ERROR, TEXTDOMAIN))
-                       {
-                               errcode(ERRCODE_NOT_NULL_VIOLATION);
-                               errmsg("%s", serialized_error_msg);
-                               errfinish(ex.Filename(), ex.Line(), nullptr);
-                       }
-               }
+               // tries to do something smart with them.
 
-               else if (GPOS_MATCH_EX(ex, gpdxl::ExmaDXL, 
gpdxl::ExmiOptimizerError) ||
-                                gpopt_context.m_should_error_out)
-               {
-                       Assert(nullptr != serialized_error_msg);
-                       if (errstart(ERROR, TEXTDOMAIN))
-                       {
-                               errcode(ERRCODE_INTERNAL_ERROR);
-                               errmsg("%s", serialized_error_msg);
-                               errfinish(ex.Filename(), ex.Line(), nullptr);
-                       }
-               }
-               else if (GPOS_MATCH_EX(ex, gpdxl::ExmaGPDB, 
gpdxl::ExmiGPDBError))
+               if (GPOS_MATCH_EX(ex, gpdxl::ExmaGPDB, gpdxl::ExmiGPDBError))
                {
                        PG_RE_THROW();
                }
-               else if (GPOS_MATCH_EX(ex, gpdxl::ExmaDXL,
-                                                          
gpdxl::ExmiNoAvailableMemory))
-               {
-                       if (errstart(ERROR, TEXTDOMAIN))
-                       {
-                               errcode(ERRCODE_INTERNAL_ERROR);
-                               errmsg("no available memory to allocate string 
buffer");
-                               errfinish(ex.Filename(), ex.Line(), nullptr);
-                       }
-               }
-               else if (GPOS_MATCH_EX(ex, gpdxl::ExmaDXL,
-                                                          
gpdxl::ExmiInvalidComparisonTypeCode))
-               {
-                       if (errstart(ERROR, TEXTDOMAIN))
-                       {
-                               errcode(ERRCODE_INTERNAL_ERROR);
-                               errmsg(
-                                       "invalid comparison type code. Valid 
values are Eq, NEq, LT, LEq, GT, GEq.");
-                               errfinish(ex.Filename(), ex.Line(), nullptr);
-                       }
-               }
 
                // Failed to produce a plan, but it wasn't an error that should
                // be propagated to the user. Log the failure if needed, and
diff --git a/src/backend/gpopt/utils/COptTasks.cpp 
b/src/backend/gpopt/utils/COptTasks.cpp
index a0a7a95efc..b339a8da73 100644
--- a/src/backend/gpopt/utils/COptTasks.cpp
+++ b/src/backend/gpopt/utils/COptTasks.cpp
@@ -631,7 +631,6 @@ COptTasks::OptimizeTask(void *ptr)
 
                IErrorContext *errctxt = CTask::Self()->GetErrCtxt();
 
-               opt_ctxt->m_should_error_out = ShouldErrorOut(ex);
                opt_ctxt->m_is_unexpected_failure = IsLoggableFailure(ex);
                opt_ctxt->m_error_msg =
                        
CreateMultiByteCharStringFromWCString(errctxt->GetErrorMsg());
diff --git a/src/backend/gporca/libgpos/include/gpos/_api.h 
b/src/backend/gporca/libgpos/include/gpos/_api.h
index 31ecdfe201..9ba3c6ec87 100644
--- a/src/backend/gporca/libgpos/include/gpos/_api.h
+++ b/src/backend/gporca/libgpos/include/gpos/_api.h
@@ -32,9 +32,6 @@ gpos::BOOL FoundException(gpos::CException &exc, const 
gpos::ULONG *exceptions,
 // produce a plan
 gpos::BOOL IsLoggableFailure(gpos::CException &exc);
 
-// check if given exception should error out
-gpos::BOOL ShouldErrorOut(gpos::CException &exc);
-
 
 extern "C" {
 #include <stddef.h>
diff --git a/src/backend/gporca/libgpos/src/_api.cpp 
b/src/backend/gporca/libgpos/src/_api.cpp
index 555e48978a..05512f3af9 100644
--- a/src/backend/gporca/libgpos/src/_api.cpp
+++ b/src/backend/gporca/libgpos/src/_api.cpp
@@ -57,30 +57,12 @@ const ULONG expected_dxl_fallback[] = {
        gpdxl::
                ExmiDXL2PlStmtConversion,  // unsupported feature during 
planned statement translation
        gpdxl::ExmiDXL2ExprAttributeNotFound,
-       gpdxl::ExmiOptimizerError,
        gpdxl::ExmiDXLMissingAttribute,
        gpdxl::ExmiDXLUnrecognizedOperator,
        gpdxl::ExmiDXLUnrecognizedCompOperator,
        gpdxl::ExmiDXLIncorrectNumberOfChildren,
-       gpdxl::ExmiQuery2DXLMissingValue,
-       gpdxl::ExmiQuery2DXLDuplicateRTE,
        gpdxl::ExmiMDCacheEntryNotFound,
-       gpdxl::ExmiQuery2DXLError,
-       gpdxl::ExmiInvalidComparisonTypeCode};
-
-// array of DXL minor exception types that error out and NOT fallback to the 
planner
-const ULONG expected_dxl_errors[] = {
-       gpdxl::ExmiDXL2PlStmtForeignScanError,  // foreign table error
-       gpdxl::ExmiQuery2DXLNotNullViolation,   // not null violation
-};
-
-BOOL
-ShouldErrorOut(gpos::CException &exc)
-{
-       return gpdxl::ExmaDXL == exc.Major() &&
-                  FoundException(exc, expected_dxl_errors,
-                                                 
GPOS_ARRAY_SIZE(expected_dxl_errors));
-}
+       gpdxl::ExmiQuery2DXLError};
 
 gpos::BOOL
 FoundException(gpos::CException &exc, const gpos::ULONG *exceptions,
diff --git a/src/backend/gporca/libnaucrates/include/naucrates/exception.h 
b/src/backend/gporca/libnaucrates/include/naucrates/exception.h
index ec69381ca5..d889ef6bba 100644
--- a/src/backend/gporca/libnaucrates/include/naucrates/exception.h
+++ b/src/backend/gporca/libnaucrates/include/naucrates/exception.h
@@ -43,13 +43,8 @@ enum ExMinor
        ExmiDXLIncorrectNumberOfChildren,
        ExmiPlStmt2DXLConversion,
        ExmiDXL2PlStmtConversion,
-       ExmiDXL2PlStmtForeignScanError,
-       ExmiDXL2PlStmtMissingPlanForSubPlanTranslation,
        ExmiQuery2DXLAttributeNotFound,
        ExmiQuery2DXLUnsupportedFeature,
-       ExmiQuery2DXLDuplicateRTE,
-       ExmiQuery2DXLMissingValue,
-       ExmiQuery2DXLNotNullViolation,
        ExmiQuery2DXLError,
        ExmiExpr2DXLUnsupportedFeature,
        ExmiExpr2DXLAttributeNotFound,
@@ -61,21 +56,12 @@ enum ExMinor
        ExmiMDCacheEntryNotFound,
        ExmiMDObjUnsupported,
 
-       // communication related errors
-       ExmiCommPropagateError,
-       ExmiCommUnexpectedMessage,
-
        // GPDB-related exceptions
        ExmiGPDBError,
 
        // exceptions related to constant expression evaluation
        ExmiConstExprEvalNonConst,
 
-       // ORCA Exceptions that need to be reported as ERROR to GPDB
-       ExmiOptimizerError,
-       ExmiNoAvailableMemory,
-       ExmiInvalidComparisonTypeCode,
-
        ExmiDXLSentinel
 };
 
diff --git a/src/backend/gporca/libnaucrates/src/exception.cpp 
b/src/backend/gporca/libnaucrates/src/exception.cpp
index a15c3b6b5f..3cb68ef0b0 100644
--- a/src/backend/gporca/libnaucrates/src/exception.cpp
+++ b/src/backend/gporca/libnaucrates/src/exception.cpp
@@ -101,16 +101,6 @@ gpdxl::EresExceptionInit(CMemoryPool *mp)
                        1,      //
                        GPOS_WSZ_WSZLEN("GPDB Expression type not supported in 
DXL")),
 
-               CMessage(
-                       CException(gpdxl::ExmaDXL,
-                                          
gpdxl::ExmiDXL2PlStmtMissingPlanForSubPlanTranslation),
-                       CException::ExsevError,
-                       GPOS_WSZ_WSZLEN(
-                               "DXL-to-PlStmt: Missing Plan During SubPlan 
Translation"),
-                       0,      //
-                       GPOS_WSZ_WSZLEN(
-                               "DXL-to-PlStmt: Missing Plan During SubPlan 
Translation")),
-
                CMessage(
                        CException(gpdxl::ExmaDXL, 
gpdxl::ExmiDXL2PlStmtConversion),
                        CException::ExsevError,
@@ -118,12 +108,6 @@ gpdxl::EresExceptionInit(CMemoryPool *mp)
                        1,      //
                        GPOS_WSZ_WSZLEN("DXL-to-PlStmt Translation not 
supported")),
 
-               CMessage(
-                       CException(gpdxl::ExmaDXL, 
gpdxl::ExmiDXL2PlStmtForeignScanError),
-                       CException::ExsevError, GPOS_WSZ_WSZLEN("Foreign scan 
error: %ls"),
-                       1,      //
-                       GPOS_WSZ_WSZLEN("Foreign scan error")),
-
                CMessage(
                        CException(gpdxl::ExmaDXL, 
gpdxl::ExmiQuery2DXLAttributeNotFound),
                        CException::ExsevError,
@@ -140,29 +124,6 @@ gpdxl::EresExceptionInit(CMemoryPool *mp)
                        1,      //
                        GPOS_WSZ_WSZLEN("Feature not supported")),
 
-               CMessage(CException(gpdxl::ExmaDXL, 
gpdxl::ExmiQuery2DXLMissingValue),
-                                CException::ExsevError,
-                                GPOS_WSZ_WSZLEN("Query-to-DXL Translation: 
Missing %ls value"),
-                                1,      //
-                                GPOS_WSZ_WSZLEN("Query-to-DXL Translation: 
Missing value")),
-
-               CMessage(
-                       CException(gpdxl::ExmaDXL, 
gpdxl::ExmiQuery2DXLNotNullViolation),
-                       CException::ExsevError,
-                       GPOS_WSZ_WSZLEN(
-                               "null value in column \"%ls\" violates not-null 
constraint"),
-                       1,      //
-                       GPOS_WSZ_WSZLEN(
-                               "null value in column violates not-null 
constraint")),
-
-               CMessage(
-                       CException(gpdxl::ExmaDXL, 
gpdxl::ExmiQuery2DXLDuplicateRTE),
-                       CException::ExsevError,
-                       GPOS_WSZ_WSZLEN(
-                               "DXL-to-Query: Duplicate range table entry at 
query level %d at position %d"),
-                       2,      // query level and var no
-                       GPOS_WSZ_WSZLEN("DXL-to-Query: Duplicate range table 
entry")),
-
                // MD related messages
                CMessage(
                        CException(gpdxl::ExmaMD, 
gpdxl::ExmiMDCacheEntryDuplicate),
@@ -184,18 +145,6 @@ gpdxl::EresExceptionInit(CMemoryPool *mp)
                                 1,      // md obj
                                 GPOS_WSZ_WSZLEN("Feature not supported")),
 
-               CMessage(CException(gpdxl::ExmaComm, 
gpdxl::ExmiCommPropagateError),
-                                CException::ExsevError, GPOS_WSZ_WSZLEN("%S"),
-                                1,      // message
-                                GPOS_WSZ_WSZLEN("Propagate remote exception")),
-
-               CMessage(
-                       CException(gpdxl::ExmaComm, 
gpdxl::ExmiCommPropagateError),
-                       CException::ExsevError,
-                       GPOS_WSZ_WSZLEN("Received unexpected message type from 
OPT: %d"),
-                       1,      // type
-                       GPOS_WSZ_WSZLEN("Received unexpected message type from 
OPT")),
-
                CMessage(CException(gpdxl::ExmaGPDB, gpdxl::ExmiGPDBError),
                                 CException::ExsevError, GPOS_WSZ_WSZLEN("PG 
exception raised"),
                                 1,      // type
@@ -254,29 +203,6 @@ gpdxl::EresExceptionInit(CMemoryPool *mp)
                        GPOS_WSZ_WSZLEN(
                                "DXL-to-Expr Translation: Attribute number not 
found in project list")),
 
-               CMessage(
-                       CException(gpdxl::ExmaDXL, gpdxl::ExmiOptimizerError),
-                       CException::ExsevError, GPOS_WSZ_WSZLEN("%s"),
-                       1,      // attno
-                       GPOS_WSZ_WSZLEN(
-                               "PQO unable to generate a plan, please see the 
above message for details.")),
-
-               CMessage(
-                       CException(gpdxl::ExmaDXL, 
gpdxl::ExmiNoAvailableMemory),
-                       CException::ExsevError,
-                       GPOS_WSZ_WSZLEN("No available memory to allocate string 
buffer."),
-                       0,
-                       GPOS_WSZ_WSZLEN("No available memory to allocate string 
buffer.")),
-
-               CMessage(
-                       CException(gpdxl::ExmaDXL, 
gpdxl::ExmiInvalidComparisonTypeCode),
-                       CException::ExsevError,
-                       GPOS_WSZ_WSZLEN(
-                               "Invalid comparison type code. Valid values are 
Eq, NEq, LT, LEq, GT, GEq."),
-                       0,
-                       GPOS_WSZ_WSZLEN(
-                               "Invalid comparison type code. Valid values are 
Eq, NEq, LT, LEq, GT, GEq."))
-
        };
 
        // copy exception array into heap
diff --git a/src/include/gpopt/utils/COptTasks.h 
b/src/include/gpopt/utils/COptTasks.h
index b97cdc321a..7910aeb3ad 100644
--- a/src/include/gpopt/utils/COptTasks.h
+++ b/src/include/gpopt/utils/COptTasks.h
@@ -88,10 +88,6 @@ struct SOptContext
        // did the optimizer fail unexpectedly?
        BOOL m_is_unexpected_failure{false};
 
-       // should the error be propagated to user, instead of falling back to 
the
-       // Postres planner?
-       BOOL m_should_error_out{false};
-
        // buffer for optimizer error messages
        CHAR *m_error_msg{nullptr};
 


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

Reply via email to