Skip to content

Commit d50a31b

Browse files
committed
Merge commit '60731f3223d19f49a796e42910860418c6691a25' into PGPRO11_DEV
2 parents 29540c2 + 60731f3 commit d50a31b

20 files changed

+160
-113
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
/tests/helpers/*pyc
3434

3535
# Extra files
36+
/src/pg_crc.c
3637
/src/datapagemap.c
3738
/src/datapagemap.h
3839
/src/logging.h

Makefile

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
PROGRAM = pg_probackup
2-
OBJS = src/backup.o src/catalog.o src/configure.o src/data.o \
3-
src/delete.o src/dir.o src/fetch.o src/help.o src/init.o \
4-
src/pg_probackup.o src/restore.o src/show.o \
5-
src/util.o src/validate.o src/datapagemap.o src/parsexlog.o \
6-
src/xlogreader.o src/streamutil.o src/receivelog.o \
7-
src/archive.o src/utils/parray.o src/utils/pgut.o src/utils/logger.o \
8-
src/utils/json.o src/utils/thread.o src/merge.o
92

10-
EXTRA_CLEAN = src/datapagemap.c src/datapagemap.h src/xlogreader.c \
11-
src/receivelog.c src/receivelog.h src/streamutil.c src/streamutil.h src/logging.h
3+
# utils
4+
OBJS = src/utils/json.o src/utils/logger.o src/utils/parray.o \
5+
src/utils/pgut.o src/utils/thread.o
126

13-
INCLUDES = src/datapagemap.h src/logging.h src/receivelog.h src/streamutil.h
7+
OBJS += src/archive.o src/backup.o src/catalog.o src/configure.o src/data.o \
8+
src/delete.o src/dir.o src/fetch.o src/help.o src/init.o src/merge.o \
9+
src/parsexlog.o src/pg_probackup.o src/restore.o src/show.o src/util.o \
10+
src/validate.o
11+
12+
# borrowed files
13+
OBJS += src/pg_crc.o src/datapagemap.o src/receivelog.o src/streamutil.o \
14+
src/xlogreader.o
15+
16+
EXTRA_CLEAN = src/pg_crc.c src/datapagemap.c src/datapagemap.h src/logging.h \
17+
src/receivelog.c src/receivelog.h src/streamutil.c src/streamutil.h \
18+
src/xlogreader.c
19+
20+
INCLUDES = src/datapagemap.h src/logging.h src/streamutil.h src/receivelog.h
1421

1522
ifdef USE_PGXS
1623
PG_CONFIG = pg_config
@@ -46,14 +53,14 @@ all: checksrcdir $(INCLUDES);
4653

4754
$(PROGRAM): $(OBJS)
4855

49-
src/xlogreader.c: $(top_srcdir)/src/backend/access/transam/xlogreader.c
50-
rm -f $@ && $(LN_S) $(srchome)/src/backend/access/transam/xlogreader.c $@
5156
src/datapagemap.c: $(top_srcdir)/src/bin/pg_rewind/datapagemap.c
5257
rm -f $@ && $(LN_S) $(srchome)/src/bin/pg_rewind/datapagemap.c $@
5358
src/datapagemap.h: $(top_srcdir)/src/bin/pg_rewind/datapagemap.h
5459
rm -f $@ && $(LN_S) $(srchome)/src/bin/pg_rewind/datapagemap.h $@
5560
src/logging.h: $(top_srcdir)/src/bin/pg_rewind/logging.h
5661
rm -f $@ && $(LN_S) $(srchome)/src/bin/pg_rewind/logging.h $@
62+
src/pg_crc.c: $(top_srcdir)/src/backend/utils/hash/pg_crc.c
63+
rm -f $@ && $(LN_S) $(srchome)/src/backend/utils/hash/pg_crc.c $@
5764
src/receivelog.c: $(top_srcdir)/src/bin/pg_basebackup/receivelog.c
5865
rm -f $@ && $(LN_S) $(srchome)/src/bin/pg_basebackup/receivelog.c $@
5966
src/receivelog.h: $(top_srcdir)/src/bin/pg_basebackup/receivelog.h
@@ -62,6 +69,8 @@ src/streamutil.c: $(top_srcdir)/src/bin/pg_basebackup/streamutil.c
6269
rm -f $@ && $(LN_S) $(srchome)/src/bin/pg_basebackup/streamutil.c $@
6370
src/streamutil.h: $(top_srcdir)/src/bin/pg_basebackup/streamutil.h
6471
rm -f $@ && $(LN_S) $(srchome)/src/bin/pg_basebackup/streamutil.h $@
72+
src/xlogreader.c: $(top_srcdir)/src/backend/access/transam/xlogreader.c
73+
rm -f $@ && $(LN_S) $(srchome)/src/backend/access/transam/xlogreader.c $@
6574

6675

6776
ifeq (,$(filter 9.5 9.6,$(MAJORVERSION)))

gen_probackup_project.pl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ BEGIN
77
if (@ARGV==1)
88
{
99
$pgsrc = shift @ARGV;
10-
if($pgsrc == "--help"){
10+
if($pgsrc eq "--help"){
1111
print STDERR "Usage $0 pg-source-dir \n";
1212
print STDERR "Like this: \n";
1313
print STDERR "$0 C:/PgProject/postgresql.10dev/postgrespro \n";
@@ -157,6 +157,7 @@ sub build_pgprobackup
157157
'thread.c'
158158
);
159159
$probackup->AddFile('src/backend/access/transam/xlogreader.c');
160+
$probackup->AddFile('src/backend/utils/hash/pg_crc.c');
160161
$probackup->AddFiles(
161162
'src/bin/pg_basebackup',
162163
'receivelog.c',

msvs/template.pg_probackup.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@
165165
</ItemDefinitionGroup>
166166
<ItemGroup>
167167
<ClCompile Include="@PGSRC@\backend\access\transam\xlogreader.c" />
168+
<ClCompile Include="@PGSRC@\backend\utils\hash\pg_crc.c" />
168169
<ClCompile Include="@PGSRC@\bin\pg_basebackup\receivelog.c" />
169170
<ClCompile Include="@PGSRC@\bin\pg_basebackup\streamutil.c" />
170171
<ClCompile Include="@PGSRC@\bin\pg_basebackup\walmethods.c" />

msvs/template.pg_probackup96.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@
165165
</ItemDefinitionGroup>
166166
<ItemGroup>
167167
<ClCompile Include="@PGSRC@\backend\access\transam\xlogreader.c" />
168+
<ClCompile Include="@PGSRC@\backend\utils\hash\pg_crc.c" />
168169
<ClCompile Include="@PGSRC@\bin\pg_basebackup\receivelog.c" />
169170
<ClCompile Include="@PGSRC@\bin\pg_basebackup\streamutil.c" />
170171
<ClCompile Include="@PGSRC@\bin\pg_rewind\datapagemap.c" />

msvs/template.pg_probackup_2.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@
160160
<!-- @PGROOT@\lib;@ADDLIBS@ @PGSRC@ @ADDINCLUDE@ -->
161161
<ItemGroup>
162162
<ClCompile Include="@PGSRC@\backend\access\transam\xlogreader.c" />
163+
<ClCompile Include="@PGSRC@\backend\utils\hash\pg_crc.c" />
163164
<ClCompile Include="@PGSRC@\bin\pg_basebackup\receivelog.c" />
164165
<ClCompile Include="@PGSRC@\bin\pg_basebackup\streamutil.c" />
165166
<ClCompile Include="@PGSRC@\bin\pg_basebackup\walmethods.c" />

src/backup.c

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ remote_copy_file(PGconn *conn, pgFile* file)
306306
to_path, strerror(errno_tmp));
307307
}
308308

309-
INIT_CRC32C(file->crc);
309+
INIT_TRADITIONAL_CRC32(file->crc);
310310

311311
/* read from stream and write to backup file */
312312
while (1)
@@ -332,14 +332,14 @@ remote_copy_file(PGconn *conn, pgFile* file)
332332
{
333333
write_buffer_size = Min(row_length, sizeof(buf));
334334
memcpy(buf, copybuf, write_buffer_size);
335-
COMP_CRC32C(file->crc, buf, write_buffer_size);
335+
COMP_TRADITIONAL_CRC32(file->crc, buf, write_buffer_size);
336336

337337
/* TODO calc checksum*/
338338
if (fwrite(buf, 1, write_buffer_size, out) != write_buffer_size)
339339
{
340340
errno_tmp = errno;
341341
/* oops */
342-
FIN_CRC32C(file->crc);
342+
FIN_TRADITIONAL_CRC32(file->crc);
343343
fclose(out);
344344
PQfinish(conn);
345345
elog(ERROR, "cannot write to \"%s\": %s", to_path,
@@ -363,7 +363,7 @@ remote_copy_file(PGconn *conn, pgFile* file)
363363
}
364364

365365
file->write_size = (int64) file->read_size;
366-
FIN_CRC32C(file->crc);
366+
FIN_TRADITIONAL_CRC32(file->crc);
367367

368368
fclose(out);
369369
}
@@ -538,8 +538,8 @@ do_backup_instance(void)
538538
}
539539

540540
/*
541-
* It`s illegal to take PTRACK backup if LSN from ptrack_control() is not equal to
542-
* stort_backup LSN of previous backup
541+
* It`s illegal to take PTRACK backup if LSN from ptrack_control() is not
542+
* equal to stop_lsn of previous backup.
543543
*/
544544
if (current.backup_mode == BACKUP_MODE_DIFF_PTRACK)
545545
{
@@ -1193,7 +1193,8 @@ pg_ptrack_support(void)
11931193

11941194
/* Now we support only ptrack versions upper than 1.5 */
11951195
if (strcmp(PQgetvalue(res_db, 0, 0), "1.5") != 0 &&
1196-
strcmp(PQgetvalue(res_db, 0, 0), "1.6") != 0)
1196+
strcmp(PQgetvalue(res_db, 0, 0), "1.6") != 0 &&
1197+
strcmp(PQgetvalue(res_db, 0, 0), "1.7") != 0)
11971198
{
11981199
elog(WARNING, "Update your ptrack to the version 1.5 or upper. Current version is %s", PQgetvalue(res_db, 0, 0));
11991200
PQclear(res_db);
@@ -1283,7 +1284,9 @@ pg_ptrack_clear(void)
12831284
tblspcOid = atoi(PQgetvalue(res_db, i, 2));
12841285

12851286
tmp_conn = pgut_connect(dbname);
1286-
res = pgut_execute(tmp_conn, "SELECT pg_catalog.pg_ptrack_clear()", 0, NULL);
1287+
res = pgut_execute(tmp_conn, "SELECT pg_catalog.pg_ptrack_clear()",
1288+
0, NULL);
1289+
PQclear(res);
12871290

12881291
sprintf(params[0], "%i", dbOid);
12891292
sprintf(params[1], "%i", tblspcOid);
@@ -1512,7 +1515,8 @@ wait_wal_lsn(XLogRecPtr lsn, bool is_start_lsn, bool wait_prev_segment)
15121515
if (wait_prev_segment)
15131516
elog(LOG, "Looking for segment: %s", wal_segment);
15141517
else
1515-
elog(LOG, "Looking for LSN: %X/%X in segment: %s", (uint32) (lsn >> 32), (uint32) lsn, wal_segment);
1518+
elog(LOG, "Looking for LSN: %X/%X in segment: %s",
1519+
(uint32) (lsn >> 32), (uint32) lsn, wal_segment);
15161520

15171521
#ifdef HAVE_LIBZ
15181522
snprintf(gz_wal_segment_path, sizeof(gz_wal_segment_path), "%s.gz",
@@ -2137,7 +2141,7 @@ backup_files(void *arg)
21372141
continue;
21382142
}
21392143
}
2140-
else
2144+
else
21412145
{
21422146
bool skip = false;
21432147

@@ -2147,7 +2151,7 @@ backup_files(void *arg)
21472151
{
21482152
calc_file_checksum(file);
21492153
/* ...and checksum is the same... */
2150-
if (EQ_CRC32C(file->crc, (*prev_file)->crc))
2154+
if (EQ_TRADITIONAL_CRC32(file->crc, (*prev_file)->crc))
21512155
skip = true; /* ...skip copying file. */
21522156
}
21532157
if (skip ||
@@ -2648,7 +2652,8 @@ get_last_ptrack_lsn(void)
26482652
uint32 lsn_lo;
26492653
XLogRecPtr lsn;
26502654

2651-
res = pgut_execute(backup_conn, "select pg_catalog.pg_ptrack_control_lsn()", 0, NULL);
2655+
res = pgut_execute(backup_conn, "select pg_catalog.pg_ptrack_control_lsn()",
2656+
0, NULL);
26522657

26532658
/* Extract timeline and LSN from results of pg_start_backup() */
26542659
XLogDataFromLSN(PQgetvalue(res, 0, 0), &lsn_hi, &lsn_lo);

src/data.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ compress_and_backup_page(pgFile *file, BlockNumber blknum,
416416
blknum, header.compressed_size, write_buffer_size); */
417417

418418
/* Update CRC */
419-
COMP_CRC32C(*crc, write_buffer, write_buffer_size);
419+
COMP_TRADITIONAL_CRC32(*crc, write_buffer, write_buffer_size);
420420

421421
/* write data page */
422422
if(fwrite(write_buffer, 1, write_buffer_size, out) != write_buffer_size)
@@ -476,13 +476,13 @@ backup_data_file(backup_files_arg* arguments,
476476
/* reset size summary */
477477
file->read_size = 0;
478478
file->write_size = 0;
479-
INIT_CRC32C(file->crc);
479+
INIT_TRADITIONAL_CRC32(file->crc);
480480

481481
/* open backup mode file for read */
482482
in = fopen(file->path, PG_BINARY_R);
483483
if (in == NULL)
484484
{
485-
FIN_CRC32C(file->crc);
485+
FIN_TRADITIONAL_CRC32(file->crc);
486486

487487
/*
488488
* If file is not found, this is not en error.
@@ -587,7 +587,7 @@ backup_data_file(backup_files_arg* arguments,
587587
to_path, strerror(errno));
588588
fclose(in);
589589

590-
FIN_CRC32C(file->crc);
590+
FIN_TRADITIONAL_CRC32(file->crc);
591591

592592
/*
593593
* If we have pagemap then file in the backup can't be a zero size.
@@ -839,7 +839,7 @@ copy_file(const char *from_root, const char *to_root, pgFile *file)
839839
struct stat st;
840840
pg_crc32 crc;
841841

842-
INIT_CRC32C(crc);
842+
INIT_TRADITIONAL_CRC32(crc);
843843

844844
/* reset size summary */
845845
file->read_size = 0;
@@ -849,7 +849,7 @@ copy_file(const char *from_root, const char *to_root, pgFile *file)
849849
in = fopen(file->path, PG_BINARY_R);
850850
if (in == NULL)
851851
{
852-
FIN_CRC32C(crc);
852+
FIN_TRADITIONAL_CRC32(crc);
853853
file->crc = crc;
854854

855855
/* maybe deleted, it's not error */
@@ -898,7 +898,7 @@ copy_file(const char *from_root, const char *to_root, pgFile *file)
898898
strerror(errno_tmp));
899899
}
900900
/* update CRC */
901-
COMP_CRC32C(crc, buf, read_len);
901+
COMP_TRADITIONAL_CRC32(crc, buf, read_len);
902902

903903
file->read_size += read_len;
904904
}
@@ -925,14 +925,14 @@ copy_file(const char *from_root, const char *to_root, pgFile *file)
925925
strerror(errno_tmp));
926926
}
927927
/* update CRC */
928-
COMP_CRC32C(crc, buf, read_len);
928+
COMP_TRADITIONAL_CRC32(crc, buf, read_len);
929929

930930
file->read_size += read_len;
931931
}
932932

933933
file->write_size = (int64) file->read_size;
934934
/* finish CRC calculation and store into pgFile */
935-
FIN_CRC32C(crc);
935+
FIN_TRADITIONAL_CRC32(crc);
936936
file->crc = crc;
937937

938938
/* update file permission */
@@ -1350,7 +1350,7 @@ calc_file_checksum(pgFile *file)
13501350
pg_crc32 crc;
13511351

13521352
Assert(S_ISREG(file->mode));
1353-
INIT_CRC32C(crc);
1353+
INIT_TRADITIONAL_CRC32(crc);
13541354

13551355
/* reset size summary */
13561356
file->read_size = 0;
@@ -1360,7 +1360,7 @@ calc_file_checksum(pgFile *file)
13601360
in = fopen(file->path, PG_BINARY_R);
13611361
if (in == NULL)
13621362
{
1363-
FIN_CRC32C(crc);
1363+
FIN_TRADITIONAL_CRC32(crc);
13641364
file->crc = crc;
13651365

13661366
/* maybe deleted, it's not error */
@@ -1387,7 +1387,7 @@ calc_file_checksum(pgFile *file)
13871387
break;
13881388

13891389
/* update CRC */
1390-
COMP_CRC32C(crc, buf, read_len);
1390+
COMP_TRADITIONAL_CRC32(crc, buf, read_len);
13911391

13921392
file->write_size += read_len;
13931393
file->read_size += read_len;
@@ -1402,7 +1402,7 @@ calc_file_checksum(pgFile *file)
14021402
}
14031403

14041404
/* finish CRC calculation and store into pgFile */
1405-
FIN_CRC32C(crc);
1405+
FIN_TRADITIONAL_CRC32(crc);
14061406
file->crc = crc;
14071407

14081408
fclose(in);
@@ -1501,8 +1501,8 @@ validate_one_page(Page page, pgFile *file,
15011501
lsn = PageXLogRecPtrGet(phdr->pd_lsn);
15021502

15031503
if (lsn > stop_lsn)
1504-
elog(WARNING, "File: %s, block %u, checksum is not enabled."
1505-
"page is from future: pageLSN %X/%X stopLSN %X/%X",
1504+
elog(WARNING, "File: %s, block %u, checksum is not enabled. "
1505+
"Page is from future: pageLSN %X/%X stopLSN %X/%X",
15061506
file->path, blknum, (uint32) (lsn >> 32), (uint32) lsn,
15071507
(uint32) (stop_lsn >> 32), (uint32) stop_lsn);
15081508
else
@@ -1515,8 +1515,8 @@ validate_one_page(Page page, pgFile *file,
15151515
lsn = PageXLogRecPtrGet(phdr->pd_lsn);
15161516

15171517
if (lsn > stop_lsn)
1518-
elog(WARNING, "File: %s, block %u, checksum is correct."
1519-
"page is from future: pageLSN %X/%X stopLSN %X/%X",
1518+
elog(WARNING, "File: %s, block %u, checksum is correct. "
1519+
"Page is from future: pageLSN %X/%X stopLSN %X/%X",
15201520
file->path, blknum, (uint32) (lsn >> 32), (uint32) lsn,
15211521
(uint32) (stop_lsn >> 32), (uint32) stop_lsn);
15221522
else

0 commit comments

Comments
 (0)