1- commita14ac459d71528c64df00c693e9c71ac70d3ba29
2- Author:anastasia <a.lubennikova @postgrespro.ru>
3- Date:Mon Oct19 14:53:06 2020 +0300
1+ commit31aad7adad5d9f977e3a3623108ff81b82181d68
2+ Author:Anton A. Melnikov <a.melnikov @postgrespro.ru>
3+ Date:Fri Oct29 08:45:13 2021 +0300
44
5- add ptrack 2.0
5+ [PGPRO-5771] Add handler for COMP_CRC32C and restore pg_comp_crc32c
6+ pointer definition.
7+
8+ Tags: ptrack
69
710diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c
8- index50ae1f16d0..721b926ad2 100644
11+ indexe09108d0ec..6858c7b670 100644
912--- a/src/backend/replication/basebackup.c
1013+++ b/src/backend/replication/basebackup.c
11- @@ -233 ,6 +233 ,13 @@ static const struct exclude_list_item excludeFiles[] =
14+ @@ -225 ,6 +225 ,13 @@ static const struct exclude_list_item excludeFiles[] =
1215 {"postmaster.pid", false},
1316 {"postmaster.opts", false},
1417
@@ -22,7 +25,7 @@ index 50ae1f16d0..721b926ad2 100644
2225 /* end of list */
2326 {NULL, false}
2427 };
25- @@ -248 ,6 +255 ,11 @@ static const struct exclude_list_item noChecksumFiles[] = {
28+ @@ -240 ,6 +247 ,11 @@ static const struct exclude_list_item noChecksumFiles[] = {
2629 {"pg_filenode.map", false},
2730 {"pg_internal.init", true},
2831 {"PG_VERSION", false},
@@ -35,7 +38,7 @@ index 50ae1f16d0..721b926ad2 100644
3538 {"config_exec_params", true},
3639 #endif
3740diff --git a/src/backend/storage/file/copydir.c b/src/backend/storage/file/copydir.c
38- index0cf598dd0c..c9c44a4ae7 100644
41+ indexda8b7cbeca..6a817f45a5 100644
3942--- a/src/backend/storage/file/copydir.c
4043+++ b/src/backend/storage/file/copydir.c
4144@@ -27,6 +27,8 @@
@@ -58,7 +61,7 @@ index 0cf598dd0c..c9c44a4ae7 100644
5861 * Be paranoid here and fsync all files to ensure the copy is really done.
5962 * But if fsync is disabled, we're done.
6063diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c
61- index0eacd461cd..c2ef404a1a 100644
64+ indexb4bca7eed6..90d479526c 100644
6265--- a/src/backend/storage/smgr/md.c
6366+++ b/src/backend/storage/smgr/md.c
6467@@ -87,6 +87,8 @@ typedef struct _MdfdVec
@@ -70,7 +73,7 @@ index 0eacd461cd..c2ef404a1a 100644
7073
7174 /* Populate a file tag describing an md.c segment file. */
7275 #define INIT_MD_FILETAG(a,xx_rnode,xx_forknum,xx_segno) \
73- @@ -435 ,6 +437 ,9 @@ mdextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
76+ @@ -463 ,6 +465 ,9 @@ mdextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
7477 register_dirty_segment(reln, forknum, v);
7578
7679 Assert(_mdnblocks(reln, forknum, v) <= ((BlockNumber) RELSEG_SIZE));
@@ -80,7 +83,7 @@ index 0eacd461cd..c2ef404a1a 100644
8083 }
8184
8285 /*
83- @@ -721 ,6 +726 ,9 @@ mdwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
86+ @@ -749 ,6 +754 ,9 @@ mdwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
8487
8588 if (!skipFsync && !SmgrIsTemp(reln))
8689 register_dirty_segment(reln, forknum, v);
@@ -91,10 +94,10 @@ index 0eacd461cd..c2ef404a1a 100644
9194
9295 /*
9396diff --git a/src/backend/storage/sync/sync.c b/src/backend/storage/sync/sync.c
94- index3ded2cdd71..3a596a59f7 100644
97+ indexbc3ceb2712..6c72d24c95 100644
9598--- a/src/backend/storage/sync/sync.c
9699+++ b/src/backend/storage/sync/sync.c
97- @@ -75 ,6 +75 ,8 @@ static MemoryContext pendingOpsCxt; /* context for the above */
100+ @@ -78 ,6 +78 ,8 @@ static MemoryContext pendingOpsCxt; /* context for the above */
98101 static CycleCtr sync_cycle_ctr = 0;
99102 static CycleCtr checkpoint_cycle_ctr = 0;
100103
@@ -103,7 +106,7 @@ index 3ded2cdd71..3a596a59f7 100644
103106 /* Intervals for calling AbsorbSyncRequests */
104107 #define FSYNCS_PER_ABSORB10
105108 #define UNLINKS_PER_ABSORB10
106- @@ -420 ,6 +422 ,9 @@ ProcessSyncRequests(void)
109+ @@ -441 ,6 +443 ,9 @@ ProcessSyncRequests(void)
107110 CheckpointStats.ckpt_longest_sync = longest;
108111 CheckpointStats.ckpt_agg_sync_time = total_elapsed;
109112
@@ -114,10 +117,10 @@ index 3ded2cdd71..3a596a59f7 100644
114117 sync_in_progress = false;
115118 }
116119diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
117- index1683629ee3..d2fc154576 100644
120+ index6652a60ec3..051cd6359d 100644
118121--- a/src/backend/utils/misc/guc.c
119122+++ b/src/backend/utils/misc/guc.c
120- @@ -620 ,7 +620 ,6 @@ static char *recovery_target_xid_string;
123+ @@ -659 ,7 +659 ,6 @@ static char *recovery_target_xid_string;
121124 static char *recovery_target_name_string;
122125 static char *recovery_target_lsn_string;
123126
@@ -126,7 +129,7 @@ index 1683629ee3..d2fc154576 100644
126129 char *role_string;
127130
128131diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c
129- indexffdc23945c..7ae95866ce 100644
132+ index831cf42d3a..891302ba2f 100644
130133--- a/src/bin/pg_checksums/pg_checksums.c
131134+++ b/src/bin/pg_checksums/pg_checksums.c
132135@@ -114,6 +114,11 @@ static const struct exclude_list_item skip[] = {
@@ -142,26 +145,26 @@ index ffdc23945c..7ae95866ce 100644
142145 {"config_exec_params", true},
143146 #endif
144147diff --git a/src/bin/pg_resetwal/pg_resetwal.c b/src/bin/pg_resetwal/pg_resetwal.c
145- index233441837f..cf7bd073bf 100644
148+ indexf8d5ecb6ad..4027bdf3df 100644
146149--- a/src/bin/pg_resetwal/pg_resetwal.c
147150+++ b/src/bin/pg_resetwal/pg_resetwal.c
148- @@ -84 ,6 +84 ,7 @@ static void RewriteControlFile(void);
151+ @@ -85 ,6 +85 ,7 @@ static void RewriteControlFile(void);
149152 static void FindEndOfXLOG(void);
150153 static void KillExistingXLOG(void);
151154 static void KillExistingArchiveStatus(void);
152155+ static void KillExistingPtrack(void);
153156 static void WriteEmptyXLOG(void);
154157 static void usage(void);
155158
156- @@ -513 ,6 +514 ,7 @@ main(int argc, char *argv[])
159+ @@ -522 ,6 +523 ,7 @@ main(int argc, char *argv[])
157160 RewriteControlFile();
158161 KillExistingXLOG();
159162 KillExistingArchiveStatus();
160163+ KillExistingPtrack();
161164 WriteEmptyXLOG();
162165
163166 printf(_("Write-ahead log reset\n"));
164- @@ -1102 ,6 +1104 ,53 @@ KillExistingArchiveStatus(void)
167+ @@ -1111 ,6 +1113 ,53 @@ KillExistingArchiveStatus(void)
165168 }
166169 }
167170
@@ -216,10 +219,10 @@ index 233441837f..cf7bd073bf 100644
216219 /*
217220 * Write an empty XLOG file, containing only the checkpoint record
218221diff --git a/src/bin/pg_rewind/filemap.c b/src/bin/pg_rewind/filemap.c
219- indexfbb97b5cf1..6cd7f2ae3e 100644
222+ index2618b4c957..bbba813fe7 100644
220223--- a/src/bin/pg_rewind/filemap.c
221224+++ b/src/bin/pg_rewind/filemap.c
222- @@ -124 ,6 +124 ,10 @@ static const struct exclude_list_item excludeFiles[] =
225+ @@ -158 ,6 +158 ,10 @@ static const struct exclude_list_item excludeFiles[] =
223226 {"postmaster.pid", false},
224227 {"postmaster.opts", false},
225228
@@ -230,11 +233,37 @@ index fbb97b5cf1..6cd7f2ae3e 100644
230233 /* end of list */
231234 {NULL, false}
232235 };
236+ diff --git a/src/common/checksum_helper.c b/src/common/checksum_helper.c
237+ index 431e247d59..3d042ebb77 100644
238+ --- a/src/common/checksum_helper.c
239+ +++ b/src/common/checksum_helper.c
240+ @@ -230,3 +230,9 @@ pg_checksum_final(pg_checksum_context *context, uint8 *output)
241+ Assert(retval <= PG_CHECKSUM_MAX_LENGTH);
242+ return retval;
243+ }
244+ +
245+ + pg_crc32c pg_comp_crc32c_handler(pg_crc32c *crc, const void *data, size_t len)
246+ + {
247+ + COMP_CRC32C(*crc, data, len);
248+ + return *crc;
249+ + }
250+ diff --git a/src/include/common/checksum_helper.h b/src/include/common/checksum_helper.h
251+ index cac7570ea1..3f7287371b 100644
252+ --- a/src/include/common/checksum_helper.h
253+ +++ b/src/include/common/checksum_helper.h
254+ @@ -68,5 +68,7 @@ extern intpg_checksum_init(pg_checksum_context *, pg_checksum_type);
255+ extern intpg_checksum_update(pg_checksum_context *, const uint8 *input,
256+ size_t len);
257+ extern intpg_checksum_final(pg_checksum_context *, uint8 *output);
258+ + extern pg_crc32c
259+ + pg_comp_crc32c_handler(pg_crc32c *crc, const void *data, size_t len);
260+
261+ #endif
233262diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
234- index72e3352398..5c2e016501 100644
263+ index3f155ce4f8..ce8dc0bee5 100644
235264--- a/src/include/miscadmin.h
236265+++ b/src/include/miscadmin.h
237- @@ -388 ,7 +388 ,7 @@ typedef enum ProcessingMode
266+ @@ -401 ,7 +401 ,7 @@ typedef enum ProcessingMode
238267 NormalProcessing/* normal processing */
239268 } ProcessingMode;
240269
@@ -244,25 +273,19 @@ index 72e3352398..5c2e016501 100644
244273 #define IsBootstrapProcessingMode() (Mode == BootstrapProcessing)
245274 #define IsInitProcessingMode()(Mode == InitProcessing)
246275diff --git a/src/include/port/pg_crc32c.h b/src/include/port/pg_crc32c.h
247- index3c6f906683..a7355f7ad1 100644
276+ indexf3c4107ff9..05b2e63775 100644
248277--- a/src/include/port/pg_crc32c.h
249278+++ b/src/include/port/pg_crc32c.h
250- @@ -69,8 +69,11 @@ extern pg_crc32c pg_comp_crc32c_armv8(pg_crc32c crc, const void *data, size_t le
251- #define FIN_CRC32C(crc) ((crc) ^= 0xFFFFFFFF)
279+ @@ -70,7 +70,6 @@ extern pg_crc32c pg_comp_crc32c_armv8(pg_crc32c crc, const void *data, size_t le
252280
253281 extern pg_crc32c pg_comp_crc32c_sb8(pg_crc32c crc, const void *data, size_t len);
254- - extern pg_crc32c (*pg_comp_crc32c) (pg_crc32c crc, const void *data, size_t len);
282+ extern pg_crc32c (*pg_comp_crc32c) (pg_crc32c crc, const void *data, size_t len);
255283-
256- + extern
257- + #ifndef FRONTEND
258- + PGDLLIMPORT
259- + #endif
260- + pg_crc32c (*pg_comp_crc32c) (pg_crc32c crc, const void *data, size_t len);
261284 #ifdef USE_SSE42_CRC32C_WITH_RUNTIME_CHECK
262285 extern pg_crc32c pg_comp_crc32c_sse42(pg_crc32c crc, const void *data, size_t len);
263286 #endif
264287diff --git a/src/include/storage/copydir.h b/src/include/storage/copydir.h
265- index5d28f59c1d..0d3f04d8af 100644
288+ index2c3936b0da..c6691c0be0 100644
266289--- a/src/include/storage/copydir.h
267290+++ b/src/include/storage/copydir.h
268291@@ -13,6 +13,9 @@
@@ -276,7 +299,7 @@ index 5d28f59c1d..0d3f04d8af 100644
276299 extern void copy_file(char *fromfile, char *tofile);
277300
278301diff --git a/src/include/storage/md.h b/src/include/storage/md.h
279- index07fd1bb7d0..5294811bc8 100644
302+ index752b440864..61c18a169f 100644
280303--- a/src/include/storage/md.h
281304+++ b/src/include/storage/md.h
282305@@ -19,6 +19,13 @@
@@ -294,10 +317,10 @@ index 07fd1bb7d0..5294811bc8 100644
294317 extern void mdinit(void);
295318 extern void mdopen(SMgrRelation reln);
296319diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
297- indexe16ab8e711..88da9686eb 100644
320+ indexfbdf34f762..455de202b6 100644
298321--- a/src/include/storage/sync.h
299322+++ b/src/include/storage/sync.h
300- @@ -50 ,6 +50 ,9 @@ typedef struct FileTag
323+ @@ -55 ,6 +55 ,9 @@ typedef struct FileTag
301324 uint32segno;
302325 } FileTag;
303326