Skip to content

Commit 7c64f03

Browse files
committed
Fix ptrack clear. Need run pg_ptrack_clear for every db.
1 parent 3d4a85f commit 7c64f03

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

backup.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include <stdio.h>
1313
#include <stdlib.h>
14+
#include <string.h>
1415
#include <sys/stat.h>
1516
#include <sys/time.h>
1617
#include <unistd.h>
@@ -543,12 +544,25 @@ pg_start_backup(const char *label, bool smooth, pgBackup *backup)
543544
static void
544545
pg_ptrack_clear(void)
545546
{
546-
PGresult *res;
547+
PGresult *res_db, *res;
548+
const char *old_dbname = dbname;
549+
int i;
547550

548551
reconnect();
549-
res = execute("select pg_ptrack_clear()", 0, NULL);
550-
PQclear(res);
552+
res_db = execute("SELECT datname FROM pg_database", 0, NULL);
553+
disconnect();
554+
for(i=0; i < PQntuples(res_db); i++)
555+
{
556+
dbname = PQgetvalue(res_db, i, 0);
557+
if (strcmp(dbname, "template0"))
558+
continue;
559+
reconnect();
560+
res = execute("SELECT pg_ptrack_clear()", 0, NULL);
561+
PQclear(res);
562+
}
563+
PQclear(res_db);
551564
disconnect();
565+
dbname = old_dbname;
552566
}
553567

554568
static void

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