This is an automated email from the ASF dual-hosted git repository. oppenheimer01 pushed a commit to branch cbdb-postgres-merge in repository https://gitbox.apache.org/repos/asf/cloudberry.git
commit f77295e1c9aa3541f3b5ee9660477231d94acc5c Author: Maxim Smyatkin <[email protected]> AuthorDate: Fri Apr 3 17:43:02 2026 +0300 pg_dump/psql: properly recognize GP During a batch rebranding from Greenplum to Cloudberry we've lost ability to work with Greenplum from pg_dump and psql --- src/bin/pg_dump/pg_dump.c | 22 +++++++++++++++++----- src/bin/psql/describe.c | 36 ++++++++++++++++++------------------ 2 files changed, 35 insertions(+), 23 deletions(-) diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 92f243a5982..1f8f76c26ff 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -411,15 +411,17 @@ static void addDistributedBy(Archive *fout, PQExpBuffer q, const TableInfo *tbin static void addDistributedByOld(Archive *fout, PQExpBuffer q, const TableInfo *tbinfo, int actual_atts); static void addSchedule(Archive *fout, PQExpBuffer q, const TableInfo *tbinfo); static bool isGPDB(Archive *fout); +static bool isMPP(Archive *fout); +static bool isGPDB5000OrLater(Archive *fout); static bool isGPDB6000OrLater(Archive *fout); /* END MPP ADDITION */ /* - * Check if we are talking to GPDB + * Check if we are talking to Greenplum or Cloudberry */ static bool -isGPDB(Archive *fout) +isMPP(Archive *fout) { static int value = -1; /* -1 = not known yet, 0 = no, 1 = yes */ @@ -433,7 +435,7 @@ isGPDB(Archive *fout) res = ExecuteSqlQuery(fout, query, PGRES_TUPLES_OK); ver = (PQgetvalue(res, 0, 0)); - if (strstr(ver, "Cloudberry") != NULL) + if (strstr(ver, "Cloudberry") != NULL || strstr(ver, "Greenplum") != NULL) value = 1; else value = 0; @@ -443,11 +445,21 @@ isGPDB(Archive *fout) return (value == 1) ? true : false; } +static bool +isGPDB5000OrLater(Archive *fout) +{ + if (!isMPP(fout)) + return false; /* Not GP-based at all. */ + + /* GPDB 5 is based on PostgreSQL 8.3 */ + return fout->remoteVersion >= 80300; +} + static bool isGPDB6000OrLater(Archive *fout) { - if (!isGPDB(fout)) - return false; /* Not Cloudberry at all. */ + if (!isMPP(fout)) + return false; /* Not GP-based at all. */ /* GPDB 6 is based on PostgreSQL 9.4 */ return fout->remoteVersion >= 90400; diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7d9515f6c08..8d8a95707e9 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -59,7 +59,7 @@ static bool validateSQLNamePattern(PQExpBuffer buf, const char *pattern, const char *visibilityrule, bool *added_clause, int maxparts); -static bool isGPDB(void); +static bool isMPP(void); static bool isGPDB4200OrLater(void); static bool isGPDB5000OrLater(void); static bool isGPDB6000OrLater(void); @@ -71,7 +71,7 @@ static bool validateSQLNamePattern(PQExpBuffer buf, const char *pattern, const char *visibilityrule, bool *added_clause, int maxparts); -static bool isGPDB(void) +static bool isMPP(void) { static enum { @@ -93,7 +93,7 @@ static bool isGPDB(void) return false; ver = PQgetvalue(res, 0, 0); - if (strstr(ver, "Cloudberry") != NULL) + if (strstr(ver, "Cloudberry") != NULL || strstr(ver, "Greenplum") != NULL) { PQclear(res); talking_to_gpdb = gpdb_yes; @@ -120,7 +120,7 @@ static bool isGPDB4200OrLater(void) { bool retValue = false; - if (isGPDB() == true) + if (isMPP() == true) { PGresult *result; @@ -141,7 +141,7 @@ isGPDB4300OrLater(void) { bool retValue = false; - if (isGPDB() == true) + if (isMPP() == true) { PGresult *result; @@ -164,7 +164,7 @@ static bool isGPDB5000OrLater(void) { bool retValue = false; - if (isGPDB() == true) + if (isMPP() == true) { PGresult *res; @@ -178,8 +178,8 @@ static bool isGPDB5000OrLater(void) static bool isGPDB6000OrLater(void) { - if (!isGPDB()) - return false; /* Not Cloudberry at all. */ + if (!isMPP()) + return false; /* Not GP-based at all. */ /* GPDB 6 is based on PostgreSQL 9.4 */ return pset.sversion >= 90400; @@ -188,8 +188,8 @@ isGPDB6000OrLater(void) static bool isGPDB6000OrBelow(void) { - if (!isGPDB()) - return false; /* Not Cloudberry at all. */ + if (!isMPP()) + return false; /* Not GP-based at all. */ /* GPDB 6 is based on PostgreSQL 9.4 */ return pset.sversion <= 90400; @@ -198,8 +198,8 @@ isGPDB6000OrBelow(void) static bool isGPDB7000OrLater(void) { - if (!isGPDB()) - return false; /* Not Cloudberry at all. */ + if (!isMPP()) + return false; /* Not GP-based at all. */ /* GPDB 7 is based on PostgreSQL v12 */ return pset.sversion >= 120000; @@ -1885,7 +1885,7 @@ describeOneTableDetails(const char *schemaname, "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" : "''"), /* GPDB Only: relstorage */ - (isGPDB() ? "c.relstorage" : "'h'"), + (isMPP() ? "c.relstorage" : "'h'"), oid); } else if (pset.sversion >= 90400) @@ -1905,7 +1905,7 @@ describeOneTableDetails(const char *schemaname, "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" : "''"), /* GPDB Only: relstorage */ - (isGPDB() ? "c.relstorage" : "'h'"), + (isMPP() ? "c.relstorage" : "'h'"), oid); } else @@ -1925,7 +1925,7 @@ describeOneTableDetails(const char *schemaname, "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" : "''"), /* GPDB Only: relstorage */ - (isGPDB() ? "c.relstorage" : "'h'"), + (isMPP() ? "c.relstorage" : "'h'"), oid); } res = PSQLexec(buf.data); @@ -1965,7 +1965,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.isdynamic = strcmp(PQgetvalue(res, 0, 16), "t") == 0; /* GPDB Only: relstorage */ - if (pset.sversion < 120000 && isGPDB()) + if (pset.sversion < 120000 && isMPP()) tableinfo.relstorage = *(PQgetvalue(res, 0, PQfnumber(res, "relstorage"))); else tableinfo.relstorage = 'h'; @@ -3655,7 +3655,7 @@ describeOneTableDetails(const char *schemaname, * listing them. */ tgdef = PQgetvalue(result, i, 1); - if (isGPDB() && strstr(tgdef, "RI_FKey_") != NULL) + if (isMPP() && strstr(tgdef, "RI_FKey_") != NULL) list_trigger = false; break; @@ -4975,7 +4975,7 @@ listTables(const char *tabtypes, const char *pattern, bool verbose, bool showSys cols_so_far = 4; /* Show Storage type for tables */ - if (showTables && isGPDB()) + if (showTables && isMPP()) { if (isGPDB7000OrLater()) { --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
