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

gfphoenix78 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry-go-libs.git


The following commit(s) were added to refs/heads/main by this push:
     new e8ca939  fix(cluster): add database type check for legacy GPDB query 
(#12)
e8ca939 is described below

commit e8ca939d5c9c430da7dbd77abbdc5c1b00f41a87
Author: Robert Mu <[email protected]>
AuthorDate: Fri Jul 25 19:59:01 2025 +0800

    fix(cluster): add database type check for legacy GPDB query (#12)
    
    When retrieving the segment configuration, there is special query
    logic for GreenplumDB (GPDB) versions prior to "6".
    
    The previous implementation only checked the version number. This could
    cause an incorrect query to be executed on a non-GPDB database
    (like CloudberryDB) that might also satisfy the `Before("6")` version
    check.
    
    This commit adds an `IsGPDB()` check to ensure this legacy logic is
    triggered only when connected to the correct database type, making
    the function more robust.
---
 cluster/cluster.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cluster/cluster.go b/cluster/cluster.go
index 9877526..fbc1386 100644
--- a/cluster/cluster.go
+++ b/cluster/cluster.go
@@ -577,7 +577,7 @@ func GetSegmentConfiguration(connection *dbconn.DBConn, 
getMirrors ...bool) ([]S
        includeMirrors := len(getMirrors) == 1 && getMirrors[0]
        includeOnlyMirrors := len(getMirrors) == 2 && getMirrors[1]
        query := ""
-       if connection.Version.Before("6") {
+       if connection.Version.IsGPDB() && connection.Version.Before("6") {
                whereClause := "WHERE%s f.fsname = 'pg_system'"
                if includeOnlyMirrors {
                        whereClause = fmt.Sprintf(whereClause, " s.role = 'm' 
AND")


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

Reply via email to