@@ -1,14 +1,14 @@ commita14ac459d71528c64df00c693e9c71ac70d3ba29 Author:anastasia <a.lubennikova @postgrespro.ru> Date:Mon Oct 19 14:53:06 2020 +0300 commit98d98792c0dbe589e8baee4c4100e0dc174ccacb Author:Anton A. Melnikov <a.melnikov @postgrespro.ru> Date:Wed Apr 13 09:49:33 2022 +0300 add ptrack 2.0 Apply core patch on PG master diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c index50ae1f16d0..721b926ad2 100644 index67489192a2..5e22017bd1 100644 --- a/src/backend/replication/basebackup.c +++ b/src/backend/replication/basebackup.c @@ -233 ,6 +233 ,13 @@ static const struct exclude_list_item excludeFiles[] = @@ -197 ,6 +197 ,13 @@ static const struct exclude_list_item excludeFiles[] = {"postmaster.pid", false}, {"postmaster.opts", false}, Expand All @@ -22,7 +22,7 @@ index 50ae1f16d0..721b926ad2 100644 /* end of list */ {NULL, false} }; @@ -248 ,6 +255 ,11 @@ static const struct exclude_list_item noChecksumFiles[] = { @@ -212 ,6 +219 ,11 @@ static const struct exclude_list_item noChecksumFiles[] = { {"pg_filenode.map", false}, {"pg_internal.init", true}, {"PG_VERSION", false}, Expand All @@ -35,7 +35,7 @@ index 50ae1f16d0..721b926ad2 100644 {"config_exec_params", true}, #endif diff --git a/src/backend/storage/file/copydir.c b/src/backend/storage/file/copydir.c index0cf598dd0c..c9c44a4ae7 100644 index658fd95ba9..eee38eba17 100644 --- a/src/backend/storage/file/copydir.c +++ b/src/backend/storage/file/copydir.c @@ -27,6 +27,8 @@ Expand All @@ -58,7 +58,7 @@ index 0cf598dd0c..c9c44a4ae7 100644 * Be paranoid here and fsync all files to ensure the copy is really done. * But if fsync is disabled, we're done. diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c index0eacd461cd..c2ef404a1a 100644 index286dd3f755..2c496b3a6d 100644 --- a/src/backend/storage/smgr/md.c +++ b/src/backend/storage/smgr/md.c @@ -87,6 +87,8 @@ typedef struct _MdfdVec Expand All @@ -70,7 +70,7 @@ index 0eacd461cd..c2ef404a1a 100644 /* Populate a file tag describing an md.c segment file. */ #define INIT_MD_FILETAG(a,xx_rnode,xx_forknum,xx_segno) \ @@ -435 ,6 +437 ,9 @@ mdextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, @@ -465 ,6 +467 ,9 @@ mdextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, register_dirty_segment(reln, forknum, v); Assert(_mdnblocks(reln, forknum, v) <= ((BlockNumber) RELSEG_SIZE)); Expand All @@ -80,7 +80,7 @@ index 0eacd461cd..c2ef404a1a 100644 } /* @@ -721 ,6 +726 ,9 @@ mdwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, @@ -757 ,6 +762 ,9 @@ mdwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, if (!skipFsync && !SmgrIsTemp(reln)) register_dirty_segment(reln, forknum, v); Expand All @@ -91,10 +91,10 @@ index 0eacd461cd..c2ef404a1a 100644 /* diff --git a/src/backend/storage/sync/sync.c b/src/backend/storage/sync/sync.c index3ded2cdd71..3a596a59f7 100644 indexc695d816fc..77e2ab1996 100644 --- a/src/backend/storage/sync/sync.c +++ b/src/backend/storage/sync/sync.c @@ -75 ,6 +75 ,8 @@ static MemoryContext pendingOpsCxt; /* context for the above */ @@ -81 ,6 +81 ,8 @@ static MemoryContext pendingOpsCxt; /* context for the above */ static CycleCtr sync_cycle_ctr = 0; static CycleCtr checkpoint_cycle_ctr = 0; Expand All @@ -103,7 +103,7 @@ index 3ded2cdd71..3a596a59f7 100644 /* Intervals for calling AbsorbSyncRequests */ #define FSYNCS_PER_ABSORB10 #define UNLINKS_PER_ABSORB10 @@ -420 ,6 +422 ,9 @@ ProcessSyncRequests(void) @@ -478 ,6 +480 ,9 @@ ProcessSyncRequests(void) CheckpointStats.ckpt_longest_sync = longest; CheckpointStats.ckpt_agg_sync_time = total_elapsed; Expand All @@ -113,23 +113,11 @@ index 3ded2cdd71..3a596a59f7 100644 /* Flag successful completion of ProcessSyncRequests */ sync_in_progress = false; } diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 1683629ee3..d2fc154576 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -620,7 +620,6 @@ static char *recovery_target_xid_string; static char *recovery_target_name_string; static char *recovery_target_lsn_string; - /* should be static, but commands/variable.c needs to get at this */ char *role_string; diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c indexffdc23945c..7ae95866ce 100644 index21dfe1b6ee..266ac1ef40 100644 --- a/src/bin/pg_checksums/pg_checksums.c +++ b/src/bin/pg_checksums/pg_checksums.c @@ -114 ,6 +114 ,11 @@ static const struct exclude_list_item skip[] = { @@ -118 ,6 +118 ,11 @@ static const struct exclude_list_item skip[] = { {"pg_filenode.map", false}, {"pg_internal.init", true}, {"PG_VERSION", false}, Expand All @@ -142,27 +130,27 @@ index ffdc23945c..7ae95866ce 100644 {"config_exec_params", true}, #endif diff --git a/src/bin/pg_resetwal/pg_resetwal.c b/src/bin/pg_resetwal/pg_resetwal.c index233441837f..cf7bd073bf 100644 indexd4772a2965..66456f7e44 100644 --- a/src/bin/pg_resetwal/pg_resetwal.c +++ b/src/bin/pg_resetwal/pg_resetwal.c @@ -84 ,6 +84 ,7 @@ static void RewriteControlFile(void); @@ -85 ,6 +85 ,7 @@ static void RewriteControlFile(void); static void FindEndOfXLOG(void); static void KillExistingXLOG(void); static void KillExistingArchiveStatus(void); +static void KillExistingPtrack(void); static void WriteEmptyXLOG(void); static void usage(void); @@ -513 ,6 +514 ,7 @@ main(int argc, char *argv[]) @@ -488 ,6 +489 ,7 @@ main(int argc, char *argv[]) RewriteControlFile(); KillExistingXLOG(); KillExistingArchiveStatus(); +KillExistingPtrack(); WriteEmptyXLOG(); printf(_("Write-ahead log reset\n")); @@ -1102 ,6 +1104 ,53 @@ KillExistingArchiveStatus(void) } @@ -1036 ,6 +1038 ,53 @@ KillExistingArchiveStatus(void) pg_fatal("could not close directory \"%s\": %m", ARCHSTATDIR); } +/* Expand Down Expand Up @@ -216,10 +204,10 @@ index 233441837f..cf7bd073bf 100644 /* * Write an empty XLOG file, containing only the checkpoint record diff --git a/src/bin/pg_rewind/filemap.c b/src/bin/pg_rewind/filemap.c indexfbb97b5cf1..6cd7f2ae3e 100644 indexd61067f6b2..27ec23137d 100644 --- a/src/bin/pg_rewind/filemap.c +++ b/src/bin/pg_rewind/filemap.c @@ -124 ,6 +124 ,10 @@ static const struct exclude_list_item excludeFiles[] = @@ -157 ,6 +157 ,10 @@ static const struct exclude_list_item excludeFiles[] = {"postmaster.pid", false}, {"postmaster.opts", false}, Expand All @@ -230,39 +218,55 @@ index fbb97b5cf1..6cd7f2ae3e 100644 /* end of list */ {NULL, false} }; diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h index 72e3352398..5c2e016501 100644 --- a/src/include/miscadmin.h +++ b/src/include/miscadmin.h @@ -388,7 +388,7 @@ typedef enum ProcessingMode NormalProcessing/* normal processing */ } ProcessingMode; diff --git a/src/include/storage/checksum.h b/src/include/storage/checksum.h index 1904fabd5a..f9306a6d01 100644 --- a/src/include/storage/checksum.h +++ b/src/include/storage/checksum.h @@ -14,6 +14,7 @@ #define CHECKSUM_H -extern ProcessingMode Mode; +extern PGDLLIMPORT ProcessingMode Mode; #include "storage/block.h" +#include "port/pg_crc32c.h" #define IsBootstrapProcessingMode() (Mode == BootstrapProcessing) #define IsInitProcessingMode()(Mode == InitProcessing) diff --git a/src/include/port/pg_crc32c.h b/src/include/port/pg_crc32c.h index 3c6f906683..a7355f7ad1 100644 --- a/src/include/port/pg_crc32c.h +++ b/src/include/port/pg_crc32c.h @@ -69,8 +69,11 @@ extern pg_crc32c pg_comp_crc32c_armv8(pg_crc32c crc, const void *data, size_t le #define FIN_CRC32C(crc) ((crc) ^= 0xFFFFFFFF) /* * Compute the checksum for a Postgres page. The page must be aligned on a @@ -21,4 +22,18 @@ */ extern uint16 pg_checksum_page(char *page, BlockNumber blkno); extern pg_crc32c pg_comp_crc32c_sb8(pg_crc32c crc, const void *data, size_t len); -extern pg_crc32c (*pg_comp_crc32c) (pg_crc32c crc, const void *data, size_t len); - +extern +#ifndef FRONTEND +PGDLLIMPORT +#ifdef WIN32 +/* + * Wrapper function for COMP_CRC32C macro. Was added to avoid + * FRONTEND macro use for pg_comp_crc32c pointer in windows build. + */ +extern void +comp_crc32c(pg_crc32c *crc, const void *data, size_t len); + +#define COMP_CRC32C_COMMON(crc, data, len)\ +comp_crc32c(&(crc), data, len) +#else +#define COMP_CRC32C_COMMONCOMP_CRC32C +#endif/* WIN32 */ + #endif/* CHECKSUM_H */ diff --git a/src/include/storage/checksum_impl.h b/src/include/storage/checksum_impl.h index 015f0f1f83..1c5a0ba351 100644 --- a/src/include/storage/checksum_impl.h +++ b/src/include/storage/checksum_impl.h @@ -213,3 +213,11 @@ pg_checksum_page(char *page, BlockNumber blkno) */ return (uint16) ((checksum % 65535) + 1); } + +#ifdef WIN32 +void +comp_crc32c(pg_crc32c *crc, const void *data, size_t len) +{ +COMP_CRC32C(*crc, data, len); +} +#endif +pg_crc32c (*pg_comp_crc32c) (pg_crc32c crc, const void *data, size_t len); #ifdef USE_SSE42_CRC32C_WITH_RUNTIME_CHECK extern pg_crc32c pg_comp_crc32c_sse42(pg_crc32c crc, const void *data, size_t len); #endif diff --git a/src/include/storage/copydir.h b/src/include/storage/copydir.h index5d28f59c1d..0d3f04d8af 100644 index50a26edeb0..af1602f515 100644 --- a/src/include/storage/copydir.h +++ b/src/include/storage/copydir.h @@ -13,6 +13,9 @@ Expand All @@ -276,7 +280,7 @@ index 5d28f59c1d..0d3f04d8af 100644 extern void copy_file(char *fromfile, char *tofile); diff --git a/src/include/storage/md.h b/src/include/storage/md.h index07fd1bb7d0..5294811bc8 100644 index6e46d8d96a..f0967ef484 100644 --- a/src/include/storage/md.h +++ b/src/include/storage/md.h @@ -19,6 +19,13 @@ Expand All @@ -294,10 +298,10 @@ index 07fd1bb7d0..5294811bc8 100644 extern void mdinit(void); extern void mdopen(SMgrRelation reln); diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h indexe16ab8e711..88da9686eb 100644 index9737e1eb67..914ad86328 100644 --- a/src/include/storage/sync.h +++ b/src/include/storage/sync.h @@ -50 ,6 +50 ,9 @@ typedef struct FileTag @@ -55 ,6 +55 ,9 @@ typedef struct FileTag uint32segno; } FileTag; Expand Down