1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2024-11-24 08:52:38 +02:00

[Issue #385] pg_stop_backup refactoring, part 1

This commit is contained in:
Grigory Smolkin 2021-05-18 12:12:42 +03:00
parent cf0888594f
commit 0e4b3a970a
6 changed files with 533 additions and 439 deletions

File diff suppressed because it is too large Load Diff

View File

@ -679,6 +679,11 @@ typedef struct BackupPageHeader2
uint16 checksum;
} BackupPageHeader2;
typedef struct StopBackupCallbackState {
PGconn *conn;
int server_version;
} StopBackupCallbackState;
/* Special value for compressed_size field */
#define PageIsOk 0
#define SkipCurrentPage -1

View File

@ -3,7 +3,7 @@
* pgut.c
*
* Portions Copyright (c) 2009-2013, NIPPON TELEGRAPH AND TELEPHONE CORPORATION
* Portions Copyright (c) 2017-2019, Postgres Professional
* Portions Copyright (c) 2017-2021, Postgres Professional
*
*-------------------------------------------------------------------------
*/
@ -902,6 +902,20 @@ pgut_strdup(const char *str)
return ret;
}
char *
pgut_strndup(const char *str, size_t n)
{
char *ret;
if (str == NULL)
return NULL;
if ((ret = strndup(str, n)) == NULL)
elog(ERROR, "could not duplicate string \"%s\": %s",
str, strerror(errno));
return ret;
}
FILE *
pgut_fopen(const char *path, const char *mode, bool missing_ok)
{

View File

@ -3,7 +3,7 @@
* pgut.h
*
* Portions Copyright (c) 2009-2013, NIPPON TELEGRAPH AND TELEPHONE CORPORATION
* Portions Copyright (c) 2017-2019, Postgres Professional
* Portions Copyright (c) 2017-2021, Postgres Professional
*
*-------------------------------------------------------------------------
*/
@ -61,6 +61,7 @@ extern int pgut_wait(int num, PGconn *connections[], struct timeval *timeout);
extern void *pgut_malloc(size_t size);
extern void *pgut_realloc(void *p, size_t size);
extern char *pgut_strdup(const char *str);
extern char *pgut_strndup(const char *str, size_t n);
#define pgut_new(type) ((type *) pgut_malloc(sizeof(type)))
#define pgut_newarray(type, n) ((type *) pgut_malloc(sizeof(type) * (n)))

View File

@ -733,7 +733,7 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
# to original data
master.psql(
"postgres",
"insert into t_heap as select i as id, md5(i::text) as text, "
"insert into t_heap select i as id, md5(i::text) as text, "
"md5(repeat(i::text,10))::tsvector as tsvector "
"from generate_series(256,512) i")
before = master.safe_psql("postgres", "SELECT * FROM t_heap")
@ -768,7 +768,7 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
# to original data
master.psql(
"postgres",
"insert into t_heap as select i as id, md5(i::text) as text, "
"insert into t_heap select i as id, md5(i::text) as text, "
"md5(repeat(i::text,10))::tsvector as tsvector "
"from generate_series(512,80680) i")
@ -911,6 +911,11 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
'autovacuum': 'off',
'archive_timeout': '10s'})
if self.get_version(master) < self.version_to_num('9.6.0'):
self.del_test_dir(module_name, fname)
return unittest.skip(
'Skipped because backup from replica is not supported in PG 9.5')
replica = self.make_simple_node(
base_dir=os.path.join(module_name, fname, 'replica'))
replica.cleanup()
@ -956,7 +961,7 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
master.psql(
"postgres",
"insert into t_heap as select i as id, md5(i::text) as text, "
"insert into t_heap select i as id, md5(i::text) as text, "
"md5(repeat(i::text,10))::tsvector as tsvector "
"from generate_series(0,10000) i")

View File

@ -149,7 +149,7 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
# to original data
master.psql(
"postgres",
"insert into t_heap as select i as id, md5(i::text) as text, "
"insert into t_heap select i as id, md5(i::text) as text, "
"md5(repeat(i::text,10))::tsvector as tsvector "
"from generate_series(256,512) i")
before = master.safe_psql("postgres", "SELECT * FROM t_heap")
@ -185,7 +185,7 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
# to original data
master.psql(
"postgres",
"insert into t_heap as select i as id, md5(i::text) as text, "
"insert into t_heap select i as id, md5(i::text) as text, "
"md5(repeat(i::text,10))::tsvector as tsvector "
"from generate_series(512,768) i")
@ -279,7 +279,7 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
# equal to original data
master.psql(
"postgres",
"insert into t_heap as select i as id, md5(i::text) as text, "
"insert into t_heap select i as id, md5(i::text) as text, "
"md5(repeat(i::text,10))::tsvector as tsvector "
"from generate_series(256,25120) i")