Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1ad0308

Browse files
committed
[PGPRO-5771] Use common crc32 macro with PG master only.
Tags: ptrack
1 parent511e341 commit1ad0308

File tree

2 files changed

+84
-68
lines changed

2 files changed

+84
-68
lines changed

‎engine.c‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@
3131
#include"access/xlog.h"
3232
#include"catalog/pg_tablespace.h"
3333
#include"miscadmin.h"
34+
#ifPG_VERSION_NUM >=150000
3435
#include"storage/checksum.h"
36+
#else
37+
#include"port/pg_crc32c.h"
38+
#endif
3539
#include"storage/copydir.h"
3640
#ifPG_VERSION_NUM >=120000
3741
#include"storage/md.h"
@@ -77,7 +81,11 @@ ptrack_file_exists(const char *path)
7781
staticvoid
7882
ptrack_write_chunk(intfd,pg_crc32c*crc,char*chunk,size_tsize)
7983
{
80-
COMP_CRC32_COMMON(*crc, (char*)chunk,size);
84+
#ifPG_VERSION_NUM >=150000
85+
COMP_CRC32C_COMMON(*crc, (char*)chunk,size);
86+
#else
87+
COMP_CRC32C(*crc, (char*)chunk,size);
88+
#endif
8189

8290
if (write(fd,chunk,size)!=size)
8391
{
@@ -197,7 +205,11 @@ ptrackMapReadFromFile(const char *ptrack_path)
197205
pg_crc32c*file_crc;
198206

199207
INIT_CRC32C(crc);
200-
COMP_CRC32_COMMON(crc, (char*)ptrack_map,PtrackCrcOffset);
208+
#ifPG_VERSION_NUM >=150000
209+
COMP_CRC32C_COMMON(crc, (char*)ptrack_map,PtrackCrcOffset);
210+
#else
211+
COMP_CRC32C(crc, (char*)ptrack_map,PtrackCrcOffset);
212+
#endif
201213
FIN_CRC32C(crc);
202214

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

‎patches/master-ptrack-core.diff‎

Lines changed: 70 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
commita14ac459d71528c64df00c693e9c71ac70d3ba29
2-
Author:anastasia<a.lubennikova@postgrespro.ru>
3-
Date:Mon Oct 19 14:53:06 2020 +0300
1+
commit98d98792c0dbe589e8baee4c4100e0dc174ccacb
2+
Author:Anton A. Melnikov<a.melnikov@postgrespro.ru>
3+
Date:Wed Apr 13 09:49:33 2022 +0300
44

5-
add ptrack 2.0
5+
Apply core patch on PG master
66

77
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c
8-
index50ae1f16d0..721b926ad2 100644
8+
index67489192a2..5e22017bd1 100644
99
--- a/src/backend/replication/basebackup.c
1010
+++ b/src/backend/replication/basebackup.c
11-
@@ -233,6 +233,13 @@ static const struct exclude_list_item excludeFiles[] =
11+
@@ -197,6 +197,13 @@ static const struct exclude_list_item excludeFiles[] =
1212
{"postmaster.pid", false},
1313
{"postmaster.opts", false},
1414

@@ -22,7 +22,7 @@ index 50ae1f16d0..721b926ad2 100644
2222
/* end of list */
2323
{NULL, false}
2424
};
25-
@@ -248,6 +255,11 @@ static const struct exclude_list_item noChecksumFiles[] = {
25+
@@ -212,6 +219,11 @@ static const struct exclude_list_item noChecksumFiles[] = {
2626
{"pg_filenode.map", false},
2727
{"pg_internal.init", true},
2828
{"PG_VERSION", false},
@@ -35,7 +35,7 @@ index 50ae1f16d0..721b926ad2 100644
3535
{"config_exec_params", true},
3636
#endif
3737
diff --git a/src/backend/storage/file/copydir.c b/src/backend/storage/file/copydir.c
38-
index0cf598dd0c..c9c44a4ae7 100644
38+
index658fd95ba9..eee38eba17 100644
3939
--- a/src/backend/storage/file/copydir.c
4040
+++ b/src/backend/storage/file/copydir.c
4141
@@ -27,6 +27,8 @@
@@ -58,7 +58,7 @@ index 0cf598dd0c..c9c44a4ae7 100644
5858
* Be paranoid here and fsync all files to ensure the copy is really done.
5959
* But if fsync is disabled, we're done.
6060
diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c
61-
index0eacd461cd..c2ef404a1a 100644
61+
index286dd3f755..2c496b3a6d 100644
6262
--- a/src/backend/storage/smgr/md.c
6363
+++ b/src/backend/storage/smgr/md.c
6464
@@ -87,6 +87,8 @@ typedef struct _MdfdVec
@@ -70,7 +70,7 @@ index 0eacd461cd..c2ef404a1a 100644
7070

7171
/* Populate a file tag describing an md.c segment file. */
7272
#define INIT_MD_FILETAG(a,xx_rnode,xx_forknum,xx_segno) \
73-
@@ -435,6 +437,9 @@ mdextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
73+
@@ -465,6 +467,9 @@ mdextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
7474
register_dirty_segment(reln, forknum, v);
7575

7676
Assert(_mdnblocks(reln, forknum, v) <= ((BlockNumber) RELSEG_SIZE));
@@ -80,7 +80,7 @@ index 0eacd461cd..c2ef404a1a 100644
8080
}
8181

8282
/*
83-
@@ -721,6 +726,9 @@ mdwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
83+
@@ -757,6 +762,9 @@ mdwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
8484

8585
if (!skipFsync && !SmgrIsTemp(reln))
8686
register_dirty_segment(reln, forknum, v);
@@ -91,10 +91,10 @@ index 0eacd461cd..c2ef404a1a 100644
9191

9292
/*
9393
diff --git a/src/backend/storage/sync/sync.c b/src/backend/storage/sync/sync.c
94-
index3ded2cdd71..3a596a59f7 100644
94+
indexc695d816fc..77e2ab1996 100644
9595
--- a/src/backend/storage/sync/sync.c
9696
+++ b/src/backend/storage/sync/sync.c
97-
@@ -75,6 +75,8 @@ static MemoryContext pendingOpsCxt; /* context for the above */
97+
@@ -81,6 +81,8 @@ static MemoryContext pendingOpsCxt; /* context for the above */
9898
static CycleCtr sync_cycle_ctr = 0;
9999
static CycleCtr checkpoint_cycle_ctr = 0;
100100

@@ -103,7 +103,7 @@ index 3ded2cdd71..3a596a59f7 100644
103103
/* Intervals for calling AbsorbSyncRequests */
104104
#define FSYNCS_PER_ABSORB10
105105
#define UNLINKS_PER_ABSORB10
106-
@@ -420,6 +422,9 @@ ProcessSyncRequests(void)
106+
@@ -478,6 +480,9 @@ ProcessSyncRequests(void)
107107
CheckpointStats.ckpt_longest_sync = longest;
108108
CheckpointStats.ckpt_agg_sync_time = total_elapsed;
109109

@@ -113,23 +113,11 @@ index 3ded2cdd71..3a596a59f7 100644
113113
/* Flag successful completion of ProcessSyncRequests */
114114
sync_in_progress = false;
115115
}
116-
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
117-
index 1683629ee3..d2fc154576 100644
118-
--- a/src/backend/utils/misc/guc.c
119-
+++ b/src/backend/utils/misc/guc.c
120-
@@ -620,7 +620,6 @@ static char *recovery_target_xid_string;
121-
static char *recovery_target_name_string;
122-
static char *recovery_target_lsn_string;
123-
124-
-
125-
/* should be static, but commands/variable.c needs to get at this */
126-
char *role_string;
127-
128116
diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c
129-
indexffdc23945c..7ae95866ce 100644
117+
index21dfe1b6ee..266ac1ef40 100644
130118
--- a/src/bin/pg_checksums/pg_checksums.c
131119
+++ b/src/bin/pg_checksums/pg_checksums.c
132-
@@ -114,6 +114,11 @@ static const struct exclude_list_item skip[] = {
120+
@@ -118,6 +118,11 @@ static const struct exclude_list_item skip[] = {
133121
{"pg_filenode.map", false},
134122
{"pg_internal.init", true},
135123
{"PG_VERSION", false},
@@ -142,27 +130,27 @@ index ffdc23945c..7ae95866ce 100644
142130
{"config_exec_params", true},
143131
#endif
144132
diff --git a/src/bin/pg_resetwal/pg_resetwal.c b/src/bin/pg_resetwal/pg_resetwal.c
145-
index233441837f..cf7bd073bf 100644
133+
indexd4772a2965..66456f7e44 100644
146134
--- a/src/bin/pg_resetwal/pg_resetwal.c
147135
+++ b/src/bin/pg_resetwal/pg_resetwal.c
148-
@@ -84,6 +84,7 @@ static void RewriteControlFile(void);
136+
@@ -85,6 +85,7 @@ static void RewriteControlFile(void);
149137
static void FindEndOfXLOG(void);
150138
static void KillExistingXLOG(void);
151139
static void KillExistingArchiveStatus(void);
152140
+static void KillExistingPtrack(void);
153141
static void WriteEmptyXLOG(void);
154142
static void usage(void);
155143

156-
@@ -513,6 +514,7 @@ main(int argc, char *argv[])
144+
@@ -488,6 +489,7 @@ main(int argc, char *argv[])
157145
RewriteControlFile();
158146
KillExistingXLOG();
159147
KillExistingArchiveStatus();
160148
+KillExistingPtrack();
161149
WriteEmptyXLOG();
162150

163151
printf(_("Write-ahead log reset\n"));
164-
@@ -1102,6 +1104,53 @@ KillExistingArchiveStatus(void)
165-
}
152+
@@ -1036,6 +1038,53 @@ KillExistingArchiveStatus(void)
153+
pg_fatal("could not close directory \"%s\": %m", ARCHSTATDIR);
166154
}
167155

168156
+/*
@@ -216,10 +204,10 @@ index 233441837f..cf7bd073bf 100644
216204
/*
217205
* Write an empty XLOG file, containing only the checkpoint record
218206
diff --git a/src/bin/pg_rewind/filemap.c b/src/bin/pg_rewind/filemap.c
219-
indexfbb97b5cf1..6cd7f2ae3e 100644
207+
indexd61067f6b2..27ec23137d 100644
220208
--- a/src/bin/pg_rewind/filemap.c
221209
+++ b/src/bin/pg_rewind/filemap.c
222-
@@ -124,6 +124,10 @@ static const struct exclude_list_item excludeFiles[] =
210+
@@ -157,6 +157,10 @@ static const struct exclude_list_item excludeFiles[] =
223211
{"postmaster.pid", false},
224212
{"postmaster.opts", false},
225213

@@ -230,39 +218,55 @@ index fbb97b5cf1..6cd7f2ae3e 100644
230218
/* end of list */
231219
{NULL, false}
232220
};
233-
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
234-
index 72e3352398..5c2e016501 100644
235-
--- a/src/include/miscadmin.h
236-
+++ b/src/include/miscadmin.h
237-
@@ -388,7 +388,7 @@ typedef enum ProcessingMode
238-
NormalProcessing/* normal processing */
239-
} ProcessingMode;
221+
diff --git a/src/include/storage/checksum.h b/src/include/storage/checksum.h
222+
index 1904fabd5a..f9306a6d01 100644
223+
--- a/src/include/storage/checksum.h
224+
+++ b/src/include/storage/checksum.h
225+
@@ -14,6 +14,7 @@
226+
#define CHECKSUM_H
240227

241-
-extern ProcessingMode Mode;
242-
+extern PGDLLIMPORT ProcessingMode Mode;
228+
#include "storage/block.h"
229+
+#include "port/pg_crc32c.h"
243230

244-
#define IsBootstrapProcessingMode() (Mode == BootstrapProcessing)
245-
#define IsInitProcessingMode()(Mode == InitProcessing)
246-
diff --git a/src/include/port/pg_crc32c.h b/src/include/port/pg_crc32c.h
247-
index 3c6f906683..a7355f7ad1 100644
248-
--- a/src/include/port/pg_crc32c.h
249-
+++ 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)
231+
/*
232+
* Compute the checksum for a Postgres page. The page must be aligned on a
233+
@@ -21,4 +22,18 @@
234+
*/
235+
extern uint16 pg_checksum_page(char *page, BlockNumber blkno);
252236

253-
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);
255-
-
256-
+extern
257-
+#ifndef FRONTEND
258-
+PGDLLIMPORT
237+
+#ifdef WIN32
238+
+/*
239+
+ * Wrapper function for COMP_CRC32C macro. Was added to avoid
240+
+ * FRONTEND macro use for pg_comp_crc32c pointer in windows build.
241+
+ */
242+
+extern void
243+
+comp_crc32c(pg_crc32c *crc, const void *data, size_t len);
244+
+
245+
+#define COMP_CRC32C_COMMON(crc, data, len)\
246+
+comp_crc32c(&(crc), data, len)
247+
+#else
248+
+#define COMP_CRC32C_COMMONCOMP_CRC32C
249+
+#endif/* WIN32 */
250+
+
251+
#endif/* CHECKSUM_H */
252+
diff --git a/src/include/storage/checksum_impl.h b/src/include/storage/checksum_impl.h
253+
index 015f0f1f83..1c5a0ba351 100644
254+
--- a/src/include/storage/checksum_impl.h
255+
+++ b/src/include/storage/checksum_impl.h
256+
@@ -213,3 +213,11 @@ pg_checksum_page(char *page, BlockNumber blkno)
257+
*/
258+
return (uint16) ((checksum % 65535) + 1);
259+
}
260+
+
261+
+#ifdef WIN32
262+
+void
263+
+comp_crc32c(pg_crc32c *crc, const void *data, size_t len)
264+
+{
265+
+COMP_CRC32C(*crc, data, len);
266+
+}
259267
+#endif
260-
+pg_crc32c (*pg_comp_crc32c) (pg_crc32c crc, const void *data, size_t len);
261-
#ifdef USE_SSE42_CRC32C_WITH_RUNTIME_CHECK
262-
extern pg_crc32c pg_comp_crc32c_sse42(pg_crc32c crc, const void *data, size_t len);
263-
#endif
264268
diff --git a/src/include/storage/copydir.h b/src/include/storage/copydir.h
265-
index5d28f59c1d..0d3f04d8af 100644
269+
index50a26edeb0..af1602f515 100644
266270
--- a/src/include/storage/copydir.h
267271
+++ b/src/include/storage/copydir.h
268272
@@ -13,6 +13,9 @@
@@ -276,7 +280,7 @@ index 5d28f59c1d..0d3f04d8af 100644
276280
extern void copy_file(char *fromfile, char *tofile);
277281

278282
diff --git a/src/include/storage/md.h b/src/include/storage/md.h
279-
index07fd1bb7d0..5294811bc8 100644
283+
index6e46d8d96a..f0967ef484 100644
280284
--- a/src/include/storage/md.h
281285
+++ b/src/include/storage/md.h
282286
@@ -19,6 +19,13 @@
@@ -294,10 +298,10 @@ index 07fd1bb7d0..5294811bc8 100644
294298
extern void mdinit(void);
295299
extern void mdopen(SMgrRelation reln);
296300
diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
297-
indexe16ab8e711..88da9686eb 100644
301+
index9737e1eb67..914ad86328 100644
298302
--- a/src/include/storage/sync.h
299303
+++ b/src/include/storage/sync.h
300-
@@ -50,6 +50,9 @@ typedef struct FileTag
304+
@@ -55,6 +55,9 @@ typedef struct FileTag
301305
uint32segno;
302306
} FileTag;
303307

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp