From 7670f829f26b0f4fc1f8f532658d95d0661cd5b7 Mon Sep 17 00:00:00 2001
From: Hao Wu <gfphoenix78@gmail.com>
Date: Mon, 8 Jul 2024 18:02:28 +0800
Subject: [PATCH] Fix compile errors detected by gcc 12 (#503)

* Check the string value, not the array itself
* Use global namespace to eliminate ambiguity
* Ignore assert condition.

Reviewed-by: Zhang Mingli avamingli@gmail.com
---
 src/backend/gpopt/gpdbwrappers.cpp                    | 2 +-
 src/backend/gpopt/translate/CTranslatorQueryToDXL.cpp | 6 ++++++
 src/backend/postmaster/loginmonitor.c                 | 2 +-
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/backend/gpopt/gpdbwrappers.cpp b/src/backend/gpopt/gpdbwrappers.cpp
index 41d3e0557aa..9e3f437ad3f 100644
--- a/src/backend/gpopt/gpdbwrappers.cpp
+++ b/src/backend/gpopt/gpdbwrappers.cpp
@@ -2168,7 +2168,7 @@ gpdb::ParseExternalTableUri(const char *uri)
 {
 	GP_WRAP_START;
 	{
-		return ParseExternalTableUri(uri);
+		return ::ParseExternalTableUri(uri);
 	}
 	GP_WRAP_END;
 	return nullptr;
diff --git a/src/backend/gpopt/translate/CTranslatorQueryToDXL.cpp b/src/backend/gpopt/translate/CTranslatorQueryToDXL.cpp
index 49179691f89..18d4a47f14d 100644
--- a/src/backend/gpopt/translate/CTranslatorQueryToDXL.cpp
+++ b/src/backend/gpopt/translate/CTranslatorQueryToDXL.cpp
@@ -4211,10 +4211,16 @@ CTranslatorQueryToDXL::CreateDXLProjectNullsForGroupingSets(
 
 		INT sort_group_ref = INT(target_entry->ressortgroupref);
 
+#if 0
+		// FIXME: The following assert is wrong for its semantics that may
+		// call a member function on a null pointer.
+		// The assert expression is highly relative to the if condition below.
+		// We should figure out what the assert state really is and add it back.
 		GPOS_ASSERT_IMP(
 			nullptr == sort_grouping_col_mapping,
 			nullptr != sort_grouping_col_mapping->Find(&sort_group_ref) &&
 				"Grouping column with no mapping");
+#endif
 
 		if (0 < sort_group_ref && 0 < colid &&
 			nullptr == sort_grouping_col_mapping->Find(&sort_group_ref))
diff --git a/src/backend/postmaster/loginmonitor.c b/src/backend/postmaster/loginmonitor.c
index 7af7006984e..466be82e9e7 100644
--- a/src/backend/postmaster/loginmonitor.c
+++ b/src/backend/postmaster/loginmonitor.c
@@ -572,7 +572,7 @@ LoginMonitorWorkerMain(int argc, char *argv[]) {
 		SetConfigOption("synchronous_commit", "local",
 				PGC_SUSET, PGC_S_OVERRIDE);
 
-	if (LoginMonitorShmem->curr_user_name) {
+	if (LoginMonitorShmem->curr_user_name[0] != '\0') {
 		InitPostgres(DB_FOR_COMMON_ACCESS, InvalidOid, NULL, InvalidOid, NULL, false);
 		SetProcessingMode(NormalProcessing);
 		set_ps_display(LoginMonitorShmem->curr_user_name);