Skip to content

Commit 85426f0

Browse files
Smyatkin-Maximtuhaihe
authored andcommitted
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
1 parent 9a02e6b commit 85426f0

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

src/bin/pg_dump/pg_dump.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -385,17 +385,17 @@ static char *nextToken(register char **stringp, register const char *delim);
385385
static void addDistributedBy(Archive *fout, PQExpBuffer q, const TableInfo *tbinfo, int actual_atts);
386386
static void addDistributedByOld(Archive *fout, PQExpBuffer q, const TableInfo *tbinfo, int actual_atts);
387387
static void addSchedule(Archive *fout, PQExpBuffer q, const TableInfo *tbinfo);
388-
static bool isGPDB(Archive *fout);
388+
static bool isMPP(Archive *fout);
389389
static bool isGPDB5000OrLater(Archive *fout);
390390
static bool isGPDB6000OrLater(Archive *fout);
391391

392392
/* END MPP ADDITION */
393393

394394
/*
395-
* Check if we are talking to GPDB
395+
* Check if we are talking to Greenplum or Cloudberry
396396
*/
397397
static bool
398-
isGPDB(Archive *fout)
398+
isMPP(Archive *fout)
399399
{
400400
static int value = -1; /* -1 = not known yet, 0 = no, 1 = yes */
401401

@@ -409,7 +409,7 @@ isGPDB(Archive *fout)
409409
res = ExecuteSqlQuery(fout, query, PGRES_TUPLES_OK);
410410

411411
ver = (PQgetvalue(res, 0, 0));
412-
if (strstr(ver, "Cloudberry") != NULL)
412+
if (strstr(ver, "Cloudberry") != NULL || strstr(ver, "Greenplum") != NULL)
413413
value = 1;
414414
else
415415
value = 0;
@@ -423,8 +423,8 @@ isGPDB(Archive *fout)
423423
static bool
424424
isGPDB5000OrLater(Archive *fout)
425425
{
426-
if (!isGPDB(fout))
427-
return false; /* Not Cloudberry at all. */
426+
if (!isMPP(fout))
427+
return false; /* Not GP-based at all. */
428428

429429
/* GPDB 5 is based on PostgreSQL 8.3 */
430430
return fout->remoteVersion >= 80300;
@@ -434,8 +434,8 @@ isGPDB5000OrLater(Archive *fout)
434434
static bool
435435
isGPDB6000OrLater(Archive *fout)
436436
{
437-
if (!isGPDB(fout))
438-
return false; /* Not Cloudberry at all. */
437+
if (!isMPP(fout))
438+
return false; /* Not GP-based at all. */
439439

440440
/* GPDB 6 is based on PostgreSQL 9.4 */
441441
return fout->remoteVersion >= 90400;

src/bin/psql/describe.c

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static bool describeOneTSConfig(const char *oid, const char *nspname,
5252
static void printACLColumn(PQExpBuffer buf, const char *colname);
5353
static bool listOneExtensionContents(const char *extname, const char *oid);
5454

55-
static bool isGPDB(void);
55+
static bool isMPP(void);
5656
static bool isGPDB4200OrLater(void);
5757
static bool isGPDB5000OrLater(void);
5858
static bool isGPDB6000OrLater(void);
@@ -64,7 +64,7 @@ static bool validateSQLNamePattern(PQExpBuffer buf, const char *pattern,
6464
const char *visibilityrule,
6565
bool *added_clause, int maxparts);
6666

67-
static bool isGPDB(void)
67+
static bool isMPP(void)
6868
{
6969
static enum
7070
{
@@ -86,7 +86,7 @@ static bool isGPDB(void)
8686
return false;
8787

8888
ver = PQgetvalue(res, 0, 0);
89-
if (strstr(ver, "Cloudberry") != NULL)
89+
if (strstr(ver, "Cloudberry") != NULL || strstr(ver, "Greenplum") != NULL)
9090
{
9191
PQclear(res);
9292
talking_to_gpdb = gpdb_yes;
@@ -113,7 +113,7 @@ static bool isGPDB4200OrLater(void)
113113
{
114114
bool retValue = false;
115115

116-
if (isGPDB() == true)
116+
if (isMPP() == true)
117117
{
118118
PGresult *result;
119119

@@ -134,7 +134,7 @@ isGPDB4300OrLater(void)
134134
{
135135
bool retValue = false;
136136

137-
if (isGPDB() == true)
137+
if (isMPP() == true)
138138
{
139139
PGresult *result;
140140

@@ -157,7 +157,7 @@ static bool isGPDB5000OrLater(void)
157157
{
158158
bool retValue = false;
159159

160-
if (isGPDB() == true)
160+
if (isMPP() == true)
161161
{
162162
PGresult *res;
163163

@@ -171,8 +171,8 @@ static bool isGPDB5000OrLater(void)
171171
static bool
172172
isGPDB6000OrLater(void)
173173
{
174-
if (!isGPDB())
175-
return false; /* Not Cloudberry at all. */
174+
if (!isMPP())
175+
return false; /* Not GP-based at all. */
176176

177177
/* GPDB 6 is based on PostgreSQL 9.4 */
178178
return pset.sversion >= 90400;
@@ -181,8 +181,8 @@ isGPDB6000OrLater(void)
181181
static bool
182182
isGPDB6000OrBelow(void)
183183
{
184-
if (!isGPDB())
185-
return false; /* Not Cloudberry at all. */
184+
if (!isMPP())
185+
return false; /* Not GP-based at all. */
186186

187187
/* GPDB 6 is based on PostgreSQL 9.4 */
188188
return pset.sversion <= 90400;
@@ -191,8 +191,8 @@ isGPDB6000OrBelow(void)
191191
static bool
192192
isGPDB7000OrLater(void)
193193
{
194-
if (!isGPDB())
195-
return false; /* Not Cloudberry at all. */
194+
if (!isMPP())
195+
return false; /* Not GP-based at all. */
196196

197197
/* GPDB 7 is based on PostgreSQL v12 */
198198
return pset.sversion >= 120000;
@@ -2007,7 +2007,7 @@ describeOneTableDetails(const char *schemaname,
20072007
"array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
20082008
: "''"),
20092009
/* GPDB Only: relstorage */
2010-
(isGPDB() ? "c.relstorage" : "'h'"),
2010+
(isMPP() ? "c.relstorage" : "'h'"),
20112011
oid);
20122012
}
20132013
else if (pset.sversion >= 90400)
@@ -2027,7 +2027,7 @@ describeOneTableDetails(const char *schemaname,
20272027
"array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
20282028
: "''"),
20292029
/* GPDB Only: relstorage */
2030-
(isGPDB() ? "c.relstorage" : "'h'"),
2030+
(isMPP() ? "c.relstorage" : "'h'"),
20312031
oid);
20322032
}
20332033
else if (pset.sversion >= 90100)
@@ -2047,7 +2047,7 @@ describeOneTableDetails(const char *schemaname,
20472047
"array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
20482048
: "''"),
20492049
/* GPDB Only: relstorage */
2050-
(isGPDB() ? "c.relstorage" : "'h'"),
2050+
(isMPP() ? "c.relstorage" : "'h'"),
20512051
oid);
20522052
}
20532053
else if (pset.sversion >= 90000)
@@ -2066,7 +2066,7 @@ describeOneTableDetails(const char *schemaname,
20662066
"array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
20672067
: "''"),
20682068
/* GPDB Only: relstorage */
2069-
(isGPDB() ? "c.relstorage" : "'h'"),
2069+
(isMPP() ? "c.relstorage" : "'h'"),
20702070
oid);
20712071
}
20722072
else if (pset.sversion >= 80400)
@@ -2084,7 +2084,7 @@ describeOneTableDetails(const char *schemaname,
20842084
"array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
20852085
: "''"),
20862086
/* GPDB Only: relstorage */
2087-
(isGPDB() ? "c.relstorage" : "'h'"),
2087+
(isMPP() ? "c.relstorage" : "'h'"),
20882088
oid);
20892089
}
20902090
else if (pset.sversion >= 80200)
@@ -2098,7 +2098,7 @@ describeOneTableDetails(const char *schemaname,
20982098
(verbose ?
20992099
"pg_catalog.array_to_string(reloptions, E', ')" : "''"),
21002100
/* GPDB Only: relstorage */
2101-
(isGPDB() ? "relstorage" : "'h'"),
2101+
(isMPP() ? "relstorage" : "'h'"),
21022102
oid);
21032103
}
21042104
else if (pset.sversion >= 80000)
@@ -2161,7 +2161,7 @@ describeOneTableDetails(const char *schemaname,
21612161
tableinfo.isdynamic = strcmp(PQgetvalue(res, 0, 16), "t") == 0;
21622162

21632163
/* GPDB Only: relstorage */
2164-
if (pset.sversion < 120000 && isGPDB())
2164+
if (pset.sversion < 120000 && isMPP())
21652165
tableinfo.relstorage = *(PQgetvalue(res, 0, PQfnumber(res, "relstorage")));
21662166
else
21672167
tableinfo.relstorage = 'h';
@@ -3840,7 +3840,7 @@ describeOneTableDetails(const char *schemaname,
38403840
* listing them.
38413841
*/
38423842
tgdef = PQgetvalue(result, i, 1);
3843-
if (isGPDB() && strstr(tgdef, "RI_FKey_") != NULL)
3843+
if (isMPP() && strstr(tgdef, "RI_FKey_") != NULL)
38443844
list_trigger = false;
38453845

38463846
break;
@@ -5145,7 +5145,7 @@ listTables(const char *tabtypes, const char *pattern, bool verbose, bool showSys
51455145
cols_so_far = 4;
51465146

51475147
/* Show Storage type for tables */
5148-
if (showTables && isGPDB())
5148+
if (showTables && isMPP())
51495149
{
51505150
if (isGPDB7000OrLater())
51515151
{

0 commit comments

Comments
 (0)