Skip to content

Commit 99da5dc

Browse files
committed
pg_dump is compatible with vanilla postgres
1 parent 21bfc87 commit 99da5dc

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

src/bin/pg_dump/pg_backup.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ typedef struct Archive
172172
int verbose;
173173
char *remoteVersionStr; /* server's version string */
174174
int remoteVersion; /* same in numeric form */
175+
bool isPgpro; /* true if server is PGPRO version */
175176
bool isStandby; /* is server a standby node */
176177

177178
int minRemoteVersion; /* allowable range */

src/bin/pg_dump/pg_backup_db.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ _check_database_version(ArchiveHandle *AH)
7272
}
7373
else
7474
AH->public.isStandby = false;
75+
76+
/* Check if we use pgpro or vanilla postgres */
77+
res = ExecuteSqlQueryForSingleRow((Archive *) AH, "SELECT exists(SELECT * FROM pg_proc WHERE proname = 'pgpro_version');");
78+
AH->public.isPgpro = (strcmp(PQgetvalue(res, 0, 0), "t") == 0);
79+
write_msg(NULL, "isPgpro = %s\n", PQgetvalue(res, 0, 0));
80+
PQclear(res);
7581
}
7682

7783
/*

src/bin/pg_dump/pg_dump.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5461,7 +5461,8 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
54615461
* is not.
54625462
*/
54635463
resetPQExpBuffer(query);
5464-
if (fout->remoteVersion >= 90502)
5464+
5465+
if (fout->remoteVersion >= 90502 && fout->isPgpro)
54655466
{
54665467
/*
54675468
* In PGPRO_9.5.2 we add INCLUDING columns functionality
@@ -5506,8 +5507,8 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
55065507
"SELECT t.tableoid, t.oid, "
55075508
"t.relname AS indexname, "
55085509
"pg_catalog.pg_get_indexdef(i.indexrelid) AS indexdef, "
5509-
"NULL AS indnkeyatts, "
5510-
"NULL AS indnatts, "
5510+
"t.relnatts AS indnkeyatts, "
5511+
"t.relnatts AS indnatts, "
55115512
"t.relnatts AS indnkeys, "
55125513
"i.indkey, i.indisclustered, "
55135514
"i.indisreplident, t.relpages, "
@@ -5539,8 +5540,8 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
55395540
"SELECT t.tableoid, t.oid, "
55405541
"t.relname AS indexname, "
55415542
"pg_catalog.pg_get_indexdef(i.indexrelid) AS indexdef, "
5542-
"NULL AS indnkeyatts, "
5543-
"NULL AS indnatts, "
5543+
"t.relnatts AS indnkeyatts, "
5544+
"t.relnatts AS indnatts, "
55445545
"t.relnatts AS indnkeys, "
55455546
"i.indkey, i.indisclustered, "
55465547
"false AS indisreplident, t.relpages, "
@@ -5568,8 +5569,8 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
55685569
"SELECT t.tableoid, t.oid, "
55695570
"t.relname AS indexname, "
55705571
"pg_catalog.pg_get_indexdef(i.indexrelid) AS indexdef, "
5571-
"NULL AS indnkeyatts, "
5572-
"NULL AS indnatts, "
5572+
"t.relnatts AS indnkeyatts, "
5573+
"t.relnatts AS indnatts, "
55735574
"t.relnatts AS indnkeys, "
55745575
"i.indkey, i.indisclustered, "
55755576
"false AS indisreplident, t.relpages, "
@@ -5600,8 +5601,8 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
56005601
"SELECT t.tableoid, t.oid, "
56015602
"t.relname AS indexname, "
56025603
"pg_catalog.pg_get_indexdef(i.indexrelid) AS indexdef, "
5603-
"NULL AS indnkeyatts, "
5604-
"NULL AS indnatts, "
5604+
"t.relnatts AS indnkeyatts, "
5605+
"t.relnatts AS indnatts, "
56055606
"t.relnatts AS indnkeys, "
56065607
"i.indkey, i.indisclustered, "
56075608
"false AS indisreplident, t.relpages, "
@@ -5631,8 +5632,8 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
56315632
"SELECT t.tableoid, t.oid, "
56325633
"t.relname AS indexname, "
56335634
"pg_catalog.pg_get_indexdef(i.indexrelid) AS indexdef, "
5634-
"NULL AS indnkeyatts, "
5635-
"NULL AS indnatts, "
5635+
"t.relnatts AS indnkeyatts, "
5636+
"t.relnatts AS indnatts, "
56365637
"t.relnatts AS indnkeys, "
56375638
"i.indkey, i.indisclustered, "
56385639
"false AS indisreplident, t.relpages, "
@@ -5662,8 +5663,8 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
56625663
"SELECT t.tableoid, t.oid, "
56635664
"t.relname AS indexname, "
56645665
"pg_get_indexdef(i.indexrelid) AS indexdef, "
5665-
"NULL AS indnkeyatts, "
5666-
"NULL AS indnatts, "
5666+
"t.relnatts AS indnkeyatts, "
5667+
"t.relnatts AS indnatts, "
56675668
"t.relnatts AS indnkeys, "
56685669
"i.indkey, false AS indisclustered, "
56695670
"false AS indisreplident, t.relpages, "
@@ -5691,8 +5692,8 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
56915692
"t.oid, "
56925693
"t.relname AS indexname, "
56935694
"pg_get_indexdef(i.indexrelid) AS indexdef, "
5694-
"NULL AS indnkeyatts, "
5695-
"NULL AS indnatts, "
5695+
"t.relnatts AS indnkeyatts, "
5696+
"t.relnatts AS indnatts, "
56965697
"t.relnatts AS indnkeys, "
56975698
"i.indkey, false AS indisclustered, "
56985699
"false AS indisreplident, t.relpages, "

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy