Skip to content

Commit 880ef9f

Browse files
author
Arthur Zakirov
committed
Parse pg_ptrack_get_and_clear_db() result correctly
1 parent e3685e8 commit 880ef9f

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/backup.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,7 @@ pg_ptrack_get_and_clear_db(Oid dbOid, Oid tblspcOid)
12441244
char *dbname;
12451245
PGresult *res_db;
12461246
PGresult *res;
1247-
char *result;
1247+
bool result;
12481248

12491249
params[0] = palloc(64);
12501250
params[1] = palloc(64);
@@ -1277,13 +1277,17 @@ pg_ptrack_get_and_clear_db(Oid dbOid, Oid tblspcOid)
12771277

12781278
if (PQnfields(res) != 1)
12791279
elog(ERROR, "cannot perform pg_ptrack_get_and_clear_db()");
1280-
1281-
result = PQgetvalue(res, 0, 0);
1280+
1281+
if (!parse_bool(PQgetvalue(res, 0, 0), &result))
1282+
elog(ERROR,
1283+
"result of pg_ptrack_get_and_clear_db() is invalid: %s",
1284+
PQgetvalue(res, 0, 0));
1285+
12821286
PQclear(res);
12831287
pfree(params[0]);
12841288
pfree(params[1]);
12851289

1286-
return (strcmp(result, "t") == 0);
1290+
return result;
12871291
}
12881292

12891293
/* Read and clear ptrack files of the target relation.
@@ -1791,11 +1795,11 @@ pg_stop_backup(pgBackup *backup)
17911795
if (sscanf(PQgetvalue(res, 0, 0), XID_FMT, &recovery_xid) != 1)
17921796
elog(ERROR,
17931797
"result of txid_snapshot_xmax() is invalid: %s",
1794-
PQerrorMessage(conn));
1798+
PQgetvalue(res, 0, 0));
17951799
if (!parse_time(PQgetvalue(res, 0, 1), &recovery_time))
17961800
elog(ERROR,
17971801
"result of current_timestamp is invalid: %s",
1798-
PQerrorMessage(conn));
1802+
PQgetvalue(res, 0, 1));
17991803

18001804
/* Get content for tablespace_map from stop_backup results
18011805
* in case of non-exclusive backup

0 commit comments

Comments
 (0)