Skip to content

Commit 0975051

Browse files
authored
Merge 9f284da into 42ea77d
2 parents 42ea77d + 9f284da commit 0975051

File tree

2 files changed

+75
-29
lines changed

2 files changed

+75
-29
lines changed

engine.c

+12
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@
3535
#endif
3636
#include "catalog/pg_tablespace.h"
3737
#include "miscadmin.h"
38+
#if PG_VERSION_NUM >= 160000
39+
#include "storage/checksum.h"
40+
#else
3841
#include "port/pg_crc32c.h"
42+
#endif
3943
#ifdef PGPRO_EE
4044
/* For file_is_in_cfs_tablespace() only. */
4145
#include "common/cfs_common.h"
@@ -81,7 +85,11 @@ ptrack_file_exists(const char *path)
8185
static void
8286
ptrack_write_chunk(int fd, pg_crc32c *crc, char *chunk, size_t size)
8387
{
88+
#if PG_VERSION_NUM >= 160000
89+
COMP_CRC32C_COMMON(*crc, (char *) chunk, size);
90+
#else
8491
COMP_CRC32C(*crc, (char *) chunk, size);
92+
#endif
8593

8694
if (write(fd, chunk, size) != size)
8795
{
@@ -248,7 +256,11 @@ ptrackMapReadFromFile(const char *ptrack_path)
248256
pg_crc32c *file_crc;
249257

250258
INIT_CRC32C(crc);
259+
#if PG_VERSION_NUM >= 160000
260+
COMP_CRC32C_COMMON(crc, (char *) ptrack_map, PtrackCrcOffset);
261+
#else
251262
COMP_CRC32C(crc, (char *) ptrack_map, PtrackCrcOffset);
263+
#endif
252264
FIN_CRC32C(crc);
253265

254266
file_crc = (pg_crc32c *) ((char *) ptrack_map + PtrackCrcOffset);

patches/master-ptrack-core.diff

+63-29
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
diff --git a/src/backend/backup/basebackup.c b/src/backend/backup/basebackup.c
2-
index 715428029b3..81f3218540a 100644
2+
index 3fb9451643..3d528fd007 100644
33
--- a/src/backend/backup/basebackup.c
44
+++ b/src/backend/backup/basebackup.c
5-
@@ -197,6 +197,13 @@ static const struct exclude_list_item excludeFiles[] =
5+
@@ -199,6 +199,13 @@ static const struct exclude_list_item excludeFiles[] =
66
{"postmaster.pid", false},
77
{"postmaster.opts", false},
88

@@ -16,7 +16,7 @@ index 715428029b3..81f3218540a 100644
1616
/* end of list */
1717
{NULL, false}
1818
};
19-
@@ -212,6 +219,11 @@ static const struct exclude_list_item noChecksumFiles[] = {
19+
@@ -214,6 +221,11 @@ static const struct exclude_list_item noChecksumFiles[] = {
2020
{"pg_filenode.map", false},
2121
{"pg_internal.init", true},
2222
{"PG_VERSION", false},
@@ -29,7 +29,7 @@ index 715428029b3..81f3218540a 100644
2929
{"config_exec_params", true},
3030
#endif
3131
diff --git a/src/backend/storage/file/copydir.c b/src/backend/storage/file/copydir.c
32-
index 658fd95ba95..eee38eba176 100644
32+
index e04bc3941a..996b5de616 100644
3333
--- a/src/backend/storage/file/copydir.c
3434
+++ b/src/backend/storage/file/copydir.c
3535
@@ -27,6 +27,8 @@
@@ -41,7 +41,7 @@ index 658fd95ba95..eee38eba176 100644
4141
/*
4242
* copydir: copy a directory
4343
*
44-
@@ -78,6 +80,9 @@ copydir(char *fromdir, char *todir, bool recurse)
44+
@@ -75,6 +77,9 @@ copydir(const char *fromdir, const char *todir, bool recurse)
4545
}
4646
FreeDir(xldir);
4747

@@ -52,7 +52,7 @@ index 658fd95ba95..eee38eba176 100644
5252
* Be paranoid here and fsync all files to ensure the copy is really done.
5353
* But if fsync is disabled, we're done.
5454
diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c
55-
index 3deac496eed..07c4ee2ba03 100644
55+
index 352958e1fe..9dc6bf29f4 100644
5656
--- a/src/backend/storage/smgr/md.c
5757
+++ b/src/backend/storage/smgr/md.c
5858
@@ -87,6 +87,8 @@ typedef struct _MdfdVec
@@ -64,7 +64,7 @@ index 3deac496eed..07c4ee2ba03 100644
6464

6565
/* Populate a file tag describing an md.c segment file. */
6666
#define INIT_MD_FILETAG(a,xx_rlocator,xx_forknum,xx_segno) \
67-
@@ -484,6 +486,9 @@ mdextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
67+
@@ -498,6 +500,9 @@ mdextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
6868
register_dirty_segment(reln, forknum, v);
6969

7070
Assert(_mdnblocks(reln, forknum, v) <= ((BlockNumber) RELSEG_SIZE));
@@ -74,7 +74,7 @@ index 3deac496eed..07c4ee2ba03 100644
7474
}
7575

7676
/*
77-
@@ -773,6 +778,9 @@ mdwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
77+
@@ -787,6 +792,9 @@ mdwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
7878

7979
if (!skipFsync && !SmgrIsTemp(reln))
8080
register_dirty_segment(reln, forknum, v);
@@ -85,7 +85,7 @@ index 3deac496eed..07c4ee2ba03 100644
8585

8686
/*
8787
diff --git a/src/backend/storage/sync/sync.c b/src/backend/storage/sync/sync.c
88-
index 9d6a9e91090..990d0722229 100644
88+
index 768d1dbfc4..17cbc6bb2a 100644
8989
--- a/src/backend/storage/sync/sync.c
9090
+++ b/src/backend/storage/sync/sync.c
9191
@@ -81,6 +81,8 @@ static MemoryContext pendingOpsCxt; /* context for the above */
@@ -108,7 +108,7 @@ index 9d6a9e91090..990d0722229 100644
108108
sync_in_progress = false;
109109
}
110110
diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c
111-
index 324ccf77834..e82cae5f325 100644
111+
index aa21007497..96fe58ee3e 100644
112112
--- a/src/bin/pg_checksums/pg_checksums.c
113113
+++ b/src/bin/pg_checksums/pg_checksums.c
114114
@@ -118,6 +118,11 @@ static const struct exclude_list_item skip[] = {
@@ -124,7 +124,7 @@ index 324ccf77834..e82cae5f325 100644
124124
{"config_exec_params", true},
125125
#endif
126126
diff --git a/src/bin/pg_resetwal/pg_resetwal.c b/src/bin/pg_resetwal/pg_resetwal.c
127-
index d4772a29650..3318f64359d 100644
127+
index e7ef2b8bd0..ca7f8cdbc2 100644
128128
--- a/src/bin/pg_resetwal/pg_resetwal.c
129129
+++ b/src/bin/pg_resetwal/pg_resetwal.c
130130
@@ -85,6 +85,7 @@ static void RewriteControlFile(void);
@@ -143,7 +143,7 @@ index d4772a29650..3318f64359d 100644
143143
WriteEmptyXLOG();
144144

145145
printf(_("Write-ahead log reset\n"));
146-
@@ -1036,6 +1038,41 @@ KillExistingArchiveStatus(void)
146+
@@ -1029,6 +1031,41 @@ KillExistingArchiveStatus(void)
147147
pg_fatal("could not close directory \"%s\": %m", ARCHSTATDIR);
148148
}
149149

@@ -186,7 +186,7 @@ index d4772a29650..3318f64359d 100644
186186
/*
187187
* Write an empty XLOG file, containing only the checkpoint record
188188
diff --git a/src/bin/pg_rewind/filemap.c b/src/bin/pg_rewind/filemap.c
189-
index 269ed6446e6..6318a8c1f55 100644
189+
index bd5c598e20..a568156c5f 100644
190190
--- a/src/bin/pg_rewind/filemap.c
191191
+++ b/src/bin/pg_rewind/filemap.c
192192
@@ -157,6 +157,10 @@ static const struct exclude_list_item excludeFiles[] =
@@ -200,21 +200,55 @@ index 269ed6446e6..6318a8c1f55 100644
200200
/* end of list */
201201
{NULL, false}
202202
};
203-
diff --git a/src/include/port/pg_crc32c.h b/src/include/port/pg_crc32c.h
204-
index d7668651ba8..33994a27f5f 100644
205-
--- a/src/include/port/pg_crc32c.h
206-
+++ b/src/include/port/pg_crc32c.h
207-
@@ -69,7 +69,7 @@ extern pg_crc32c pg_comp_crc32c_armv8(pg_crc32c crc, const void *data, size_t le
208-
#define FIN_CRC32C(crc) ((crc) ^= 0xFFFFFFFF)
203+
diff --git a/src/include/storage/checksum.h b/src/include/storage/checksum.h
204+
index 4afd25a0af..c2afee20b5 100644
205+
--- a/src/include/storage/checksum.h
206+
+++ b/src/include/storage/checksum.h
207+
@@ -14,6 +14,7 @@
208+
#define CHECKSUM_H
209209

210-
extern pg_crc32c pg_comp_crc32c_sb8(pg_crc32c crc, const void *data, size_t len);
211-
-extern pg_crc32c (*pg_comp_crc32c) (pg_crc32c crc, const void *data, size_t len);
212-
+extern PGDLLIMPORT pg_crc32c (*pg_comp_crc32c) (pg_crc32c crc, const void *data, size_t len);
210+
#include "storage/block.h"
211+
+#include "port/pg_crc32c.h"
213212

214-
#ifdef USE_SSE42_CRC32C_WITH_RUNTIME_CHECK
215-
extern pg_crc32c pg_comp_crc32c_sse42(pg_crc32c crc, const void *data, size_t len);
213+
/*
214+
* Compute the checksum for a Postgres page. The page must be aligned on a
215+
@@ -21,4 +22,18 @@
216+
*/
217+
extern uint16 pg_checksum_page(char *page, BlockNumber blkno);
218+
219+
+#ifdef WIN32
220+
+/*
221+
+ * Wrapper function for COMP_CRC32C macro. Was added to avoid
222+
+ * FRONTEND macro use for pg_comp_crc32c pointer in windows build.
223+
+ */
224+
+extern void
225+
+comp_crc32c(pg_crc32c *crc, const void *data, size_t len);
226+
+
227+
+#define COMP_CRC32C_COMMON(crc, data, len) \
228+
+ comp_crc32c(&(crc), data, len)
229+
+#else
230+
+#define COMP_CRC32C_COMMON COMP_CRC32C
231+
+#endif /* WIN32 */
232+
+
233+
#endif /* CHECKSUM_H */
234+
diff --git a/src/include/storage/checksum_impl.h b/src/include/storage/checksum_impl.h
235+
index 7b157161a2..a69425f6cc 100644
236+
--- a/src/include/storage/checksum_impl.h
237+
+++ b/src/include/storage/checksum_impl.h
238+
@@ -213,3 +213,11 @@ pg_checksum_page(char *page, BlockNumber blkno)
239+
*/
240+
return (uint16) ((checksum % 65535) + 1);
241+
}
242+
+
243+
+#ifdef WIN32
244+
+void
245+
+comp_crc32c(pg_crc32c *crc, const void *data, size_t len)
246+
+{
247+
+ COMP_CRC32C(*crc, data, len);
248+
+}
249+
+#endif
216250
diff --git a/src/include/storage/copydir.h b/src/include/storage/copydir.h
217-
index 50a26edeb06..af1602f5154 100644
251+
index a8be5b21e0..020874f96c 100644
218252
--- a/src/include/storage/copydir.h
219253
+++ b/src/include/storage/copydir.h
220254
@@ -13,6 +13,9 @@
@@ -224,11 +258,11 @@ index 50a26edeb06..af1602f5154 100644
224258
+typedef void (*copydir_hook_type) (const char *path);
225259
+extern PGDLLIMPORT copydir_hook_type copydir_hook;
226260
+
227-
extern void copydir(char *fromdir, char *todir, bool recurse);
228-
extern void copy_file(char *fromfile, char *tofile);
261+
extern void copydir(const char *fromdir, const char *todir, bool recurse);
262+
extern void copy_file(const char *fromfile, const char *tofile);
229263

230264
diff --git a/src/include/storage/md.h b/src/include/storage/md.h
231-
index 10aa1b0109b..1415675824e 100644
265+
index 8f32af9ef3..f8b427ceca 100644
232266
--- a/src/include/storage/md.h
233267
+++ b/src/include/storage/md.h
234268
@@ -19,6 +19,13 @@
@@ -246,7 +280,7 @@ index 10aa1b0109b..1415675824e 100644
246280
extern void mdinit(void);
247281
extern void mdopen(SMgrRelation reln);
248282
diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
249-
index 049af878dec..7689d49a24e 100644
283+
index cfbcfa6797..2a432440db 100644
250284
--- a/src/include/storage/sync.h
251285
+++ b/src/include/storage/sync.h
252286
@@ -55,6 +55,9 @@ typedef struct FileTag

0 commit comments

Comments
 (0)