Skip to content

Commit e27a6a9

Browse files
committed
[Issue #400] PostgreSQL 14 support
1 parent e68132d commit e27a6a9

File tree

7 files changed

+37
-8
lines changed

7 files changed

+37
-8
lines changed

src/backup.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ pgdata_basic_setup(ConnectionOptions conn_opt, PGNodeInfo *nodeInfo)
725725
elog(WARNING, "Current PostgreSQL role is superuser. "
726726
"It is not recommended to run backup or checkdb as superuser.");
727727

728-
StrNCpy(current.server_version, nodeInfo->server_version_str,
728+
strlcpy(current.server_version, nodeInfo->server_version_str,
729729
sizeof(current.server_version));
730730

731731
return cur_conn;
@@ -761,7 +761,7 @@ do_backup(pgSetBackupParams *set_backup_params,
761761
current.status = BACKUP_STATUS_RUNNING;
762762
current.start_time = current.backup_id;
763763

764-
StrNCpy(current.program_version, PROGRAM_VERSION,
764+
strlcpy(current.program_version, PROGRAM_VERSION,
765765
sizeof(current.program_version));
766766

767767
current.compress_alg = instance_config.compress_alg;

src/catalog.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2648,14 +2648,14 @@ readBackupControlFile(const char *path)
26482648

26492649
if (program_version)
26502650
{
2651-
StrNCpy(backup->program_version, program_version,
2651+
strlcpy(backup->program_version, program_version,
26522652
sizeof(backup->program_version));
26532653
pfree(program_version);
26542654
}
26552655

26562656
if (server_version)
26572657
{
2658-
StrNCpy(backup->server_version, server_version,
2658+
strlcpy(backup->server_version, server_version,
26592659
sizeof(backup->server_version));
26602660
pfree(server_version);
26612661
}

src/merge.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ merge_chain(parray *parent_chain, pgBackup *full_backup, pgBackup *dest_backup,
735735
* We cannot set backup status to OK just yet,
736736
* because it still has old start_time.
737737
*/
738-
StrNCpy(full_backup->program_version, PROGRAM_VERSION,
738+
strlcpy(full_backup->program_version, PROGRAM_VERSION,
739739
sizeof(full_backup->program_version));
740740
full_backup->parent_backup = INVALID_BACKUP_ID;
741741
full_backup->start_lsn = dest_backup->start_lsn;

src/parsexlog.c

+12
Original file line numberDiff line numberDiff line change
@@ -1798,6 +1798,18 @@ extractPageInfo(XLogReaderState *record, XLogReaderData *reader_data,
17981798
* source system.
17991799
*/
18001800
}
1801+
else if (rmid == RM_XACT_ID &&
1802+
((rminfo & XLOG_XACT_OPMASK) == XLOG_XACT_COMMIT ||
1803+
(rminfo & XLOG_XACT_OPMASK) == XLOG_XACT_COMMIT_PREPARED ||
1804+
(rminfo & XLOG_XACT_OPMASK) == XLOG_XACT_ABORT ||
1805+
(rminfo & XLOG_XACT_OPMASK) == XLOG_XACT_ABORT_PREPARED))
1806+
{
1807+
/*
1808+
* These records can include "dropped rels". We can safely ignore
1809+
* them, we will see that they are missing and copy them from the
1810+
* source.
1811+
*/
1812+
}
18011813
else if (info & XLR_SPECIAL_REL_UPDATE)
18021814
{
18031815
/*

src/show.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ show_instance_plain(const char *instance_name, parray *backup_list, bool show_na
552552
time2iso(row->recovery_time, lengthof(row->recovery_time),
553553
backup->recovery_time, false);
554554
else
555-
StrNCpy(row->recovery_time, "----", sizeof(row->recovery_time));
555+
strlcpy(row->recovery_time, "----", sizeof(row->recovery_time));
556556
widths[cur] = Max(widths[cur], strlen(row->recovery_time));
557557
cur++;
558558

@@ -587,7 +587,7 @@ show_instance_plain(const char *instance_name, parray *backup_list, bool show_na
587587
pretty_time_interval(difftime(backup->end_time, backup->start_time),
588588
row->duration, lengthof(row->duration));
589589
else
590-
StrNCpy(row->duration, "----", sizeof(row->duration));
590+
strlcpy(row->duration, "----", sizeof(row->duration));
591591
widths[cur] = Max(widths[cur], strlen(row->duration));
592592
cur++;
593593

src/utils/pgut.c

+14-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
#include "libpq/pqsignal.h"
1717
#include "pqexpbuffer.h"
1818

19+
#if PG_VERSION_NUM >= 140000
20+
#include "common/string.h"
21+
#endif
22+
1923
#include <time.h>
2024

2125
#include "pgut.h"
@@ -75,7 +79,16 @@ prompt_for_password(const char *username)
7579
password = NULL;
7680
}
7781

78-
#if PG_VERSION_NUM >= 100000
82+
#if PG_VERSION_NUM >= 140000
83+
if (username == NULL)
84+
password = simple_prompt("Password: ", false);
85+
else
86+
{
87+
char message[256];
88+
snprintf(message, lengthof(message), "Password for user %s: ", username);
89+
password = simple_prompt(message , false);
90+
}
91+
#elif PG_VERSION_NUM >= 100000
7992
password = (char *) pgut_malloc(sizeof(char) * 100 + 1);
8093
if (username == NULL)
8194
simple_prompt("Password: ", password, 100, false);

tests/helpers/ptrack_helpers.py

+4
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ def slow_start(self, replica=False):
139139
except testgres.QueryException as e:
140140
if 'database system is starting up' in e.message:
141141
pass
142+
elif 'FATAL: the database system is not accepting connections' in e.message:
143+
pass
144+
elif replica and 'Hot standby mode is disabled' in e.message:
145+
raise e
142146
else:
143147
raise e
144148

0 commit comments

Comments
 (0)