1
+ commit 5255ff7a6051f56689e0db2a0fa7e9a6e4086d66
2
+ Author: Anton A. Melnikov <a.melnikov@postgrespro.ru>
3
+ Date: Mon Nov 8 11:11:45 2021 +0300
4
+
5
+ [PGPRO-5771] Add handler for COMP_CRC32C and restore pg_comp_crc32c pointer definition.
6
+
1
7
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c
2
- index 3e53b3df6fb..f76bfc2a646 100644
8
+ index 3e53b3df6f..f76bfc2a64 100644
3
9
--- a/src/backend/replication/basebackup.c
4
10
+++ b/src/backend/replication/basebackup.c
5
11
@@ -209,6 +209,13 @@ static const struct exclude_list_item excludeFiles[] =
6
12
{"postmaster.pid", false},
7
13
{"postmaster.opts", false},
8
-
14
+
9
15
+ /*
10
16
+ * Skip all transient ptrack files, but do copy ptrack.map, since it may
11
17
+ * be successfully used immediately after backup. TODO: check, test?
@@ -28,13 +34,13 @@ index 3e53b3df6fb..f76bfc2a646 100644
28
34
{"config_exec_params", true},
29
35
#endif
30
36
diff --git a/src/backend/storage/file/copydir.c b/src/backend/storage/file/copydir.c
31
- index 4a0d23b11e3..d59009a4c8c 100644
37
+ index 4a0d23b11e..d59009a4c8 100644
32
38
--- a/src/backend/storage/file/copydir.c
33
39
+++ b/src/backend/storage/file/copydir.c
34
40
@@ -27,6 +27,8 @@
35
41
#include "miscadmin.h"
36
42
#include "pgstat.h"
37
-
43
+
38
44
+ copydir_hook_type copydir_hook = NULL;
39
45
+
40
46
/*
@@ -43,88 +49,88 @@ index 4a0d23b11e3..d59009a4c8c 100644
43
49
@@ -78,6 +80,9 @@ copydir(char *fromdir, char *todir, bool recurse)
44
50
}
45
51
FreeDir(xldir);
46
-
52
+
47
53
+ if (copydir_hook)
48
54
+ copydir_hook(todir);
49
55
+
50
56
/*
51
57
* Be paranoid here and fsync all files to ensure the copy is really done.
52
58
* But if fsync is disabled, we're done.
53
59
diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c
54
- index 200cc7f657a..d0dcb5c0287 100644
60
+ index fa29e7041f..8bda639eda 100644
55
61
--- a/src/backend/storage/smgr/md.c
56
62
+++ b/src/backend/storage/smgr/md.c
57
63
@@ -39,6 +39,7 @@
58
64
#include "utils/memutils.h"
59
65
#include "pg_trace.h"
60
-
66
+
61
67
+ ProcessSyncRequests_hook_type ProcessSyncRequests_hook = NULL;
62
-
68
+
63
69
/* intervals for calling AbsorbFsyncRequests in mdsync and mdpostckpt */
64
70
#define FSYNCS_PER_ABSORB 10
65
71
@@ -114,6 +115,8 @@ typedef struct _MdfdVec
66
-
72
+
67
73
static MemoryContext MdCxt; /* context for all MdfdVec objects */
68
-
74
+
69
75
+ mdextend_hook_type mdextend_hook = NULL;
70
76
+ mdwrite_hook_type mdwrite_hook = NULL;
71
-
77
+
72
78
/*
73
79
* In some contexts (currently, standalone backends and the checkpointer)
74
- @@ -558 ,6 +561 ,9 @@ mdextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
80
+ @@ -600 ,6 +603 ,9 @@ mdextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
75
81
register_dirty_segment(reln, forknum, v);
76
-
82
+
77
83
Assert(_mdnblocks(reln, forknum, v) <= ((BlockNumber) RELSEG_SIZE));
78
84
+
79
85
+ if (mdextend_hook)
80
86
+ mdextend_hook(reln->smgr_rnode, forknum, blocknum);
81
87
}
82
-
88
+
83
89
/*
84
- @@ -851 ,6 +857 ,9 @@ mdwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
85
-
90
+ @@ -893 ,6 +899 ,9 @@ mdwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
91
+
86
92
if (!skipFsync && !SmgrIsTemp(reln))
87
93
register_dirty_segment(reln, forknum, v);
88
94
+
89
95
+ if (mdwrite_hook)
90
96
+ mdwrite_hook(reln->smgr_rnode, forknum, blocknum);
91
97
}
92
-
98
+
93
99
/*
94
- @@ -1329 ,6 +1338 ,9 @@ mdsync(void)
100
+ @@ -1371 ,6 +1380 ,9 @@ mdsync(void)
95
101
CheckpointStats.ckpt_longest_sync = longest;
96
102
CheckpointStats.ckpt_agg_sync_time = total_elapsed;
97
-
103
+
98
104
+ if (ProcessSyncRequests_hook)
99
105
+ ProcessSyncRequests_hook();
100
106
+
101
107
/* Flag successful completion of mdsync */
102
108
mdsync_in_progress = false;
103
109
}
104
110
diff --git a/src/bin/pg_resetwal/pg_resetwal.c b/src/bin/pg_resetwal/pg_resetwal.c
105
- index 6fb403a5a8a..6e31ccb3e0f 100644
111
+ index 611edf6ade..ec1c1212bd 100644
106
112
--- a/src/bin/pg_resetwal/pg_resetwal.c
107
113
+++ b/src/bin/pg_resetwal/pg_resetwal.c
108
- @@ -84 ,6 +84 ,7 @@ static void RewriteControlFile(void);
114
+ @@ -85 ,6 +85 ,7 @@ static void RewriteControlFile(void);
109
115
static void FindEndOfXLOG(void);
110
116
static void KillExistingXLOG(void);
111
117
static void KillExistingArchiveStatus(void);
112
118
+ static void KillExistingPtrack(void);
113
119
static void WriteEmptyXLOG(void);
114
120
static void usage(void);
115
-
116
- @@ -516 ,6 +517 ,7 @@ main(int argc, char *argv[])
121
+
122
+ @@ -525 ,6 +526 ,7 @@ main(int argc, char *argv[])
117
123
RewriteControlFile();
118
124
KillExistingXLOG();
119
125
KillExistingArchiveStatus();
120
126
+ KillExistingPtrack();
121
127
WriteEmptyXLOG();
122
-
128
+
123
129
printf(_("Write-ahead log reset\n"));
124
- @@ -1201 ,6 +1203 ,57 @@ KillExistingArchiveStatus(void)
130
+ @@ -1210 ,6 +1212 ,57 @@ KillExistingArchiveStatus(void)
125
131
}
126
132
}
127
-
133
+
128
134
+ /*
129
135
+ * Remove existing ptrack files
130
136
+ */
@@ -176,17 +182,17 @@ index 6fb403a5a8a..6e31ccb3e0f 100644
176
182
+ }
177
183
+ }
178
184
+
179
-
185
+
180
186
/*
181
187
* Write an empty XLOG file, containing only the checkpoint record
182
188
diff --git a/src/bin/pg_rewind/filemap.c b/src/bin/pg_rewind/filemap.c
183
- index 197163d5544..fc846e78175 100644
189
+ index 8ea7fafa27..997168fcac 100644
184
190
--- a/src/bin/pg_rewind/filemap.c
185
191
+++ b/src/bin/pg_rewind/filemap.c
186
192
@@ -118,6 +118,10 @@ static const struct exclude_list_item excludeFiles[] =
187
193
{"postmaster.pid", false},
188
194
{"postmaster.opts", false},
189
-
195
+
190
196
+ {"ptrack.map.mmap", false},
191
197
+ {"ptrack.map", false},
192
198
+ {"ptrack.map.tmp", false},
@@ -195,57 +201,77 @@ index 197163d5544..fc846e78175 100644
195
201
{NULL, false}
196
202
};
197
203
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
198
- index 80241455357..50dca7bf6f4 100644
204
+ index 7c9f319b67..1e29827030 100644
199
205
--- a/src/include/miscadmin.h
200
206
+++ b/src/include/miscadmin.h
201
- @@ -367 ,7 +367 ,7 @@ typedef enum ProcessingMode
207
+ @@ -379 ,7 +379 ,7 @@ typedef enum ProcessingMode
202
208
NormalProcessing /* normal processing */
203
209
} ProcessingMode;
204
-
210
+
205
211
- extern ProcessingMode Mode;
206
212
+ extern PGDLLIMPORT ProcessingMode Mode;
207
-
213
+
208
214
#define IsBootstrapProcessingMode() (Mode == BootstrapProcessing)
209
215
#define IsInitProcessingMode() (Mode == InitProcessing)
210
- diff --git a/src/include/port/pg_crc32c.h b/src/include/port/pg_crc32c.h
211
- index 9a26295c8e8..dc72b27a10d 100644
212
- --- a/src/include/port/pg_crc32c.h
213
- +++ b/src/include/port/pg_crc32c.h
214
- @@ -69,8 +69,11 @@ extern pg_crc32c pg_comp_crc32c_armv8(pg_crc32c crc, const void *data, size_t le
215
- #define FIN_CRC32C(crc) ((crc) ^= 0xFFFFFFFF)
216
-
217
- extern pg_crc32c pg_comp_crc32c_sb8(pg_crc32c crc, const void *data, size_t len);
218
- - extern pg_crc32c (*pg_comp_crc32c) (pg_crc32c crc, const void *data, size_t len);
219
- -
220
- + extern
221
- + #ifndef FRONTEND
222
- + PGDLLIMPORT
223
- + #endif
224
- + pg_crc32c (*pg_comp_crc32c) (pg_crc32c crc, const void *data, size_t len);
225
- #ifdef USE_SSE42_CRC32C_WITH_RUNTIME_CHECK
226
- extern pg_crc32c pg_comp_crc32c_sse42(pg_crc32c crc, const void *data, size_t len);
227
- #endif
216
+ diff --git a/src/include/storage/checksum.h b/src/include/storage/checksum.h
217
+ index 433755e279..de06d3b0cf 100644
218
+ --- a/src/include/storage/checksum.h
219
+ +++ b/src/include/storage/checksum.h
220
+ @@ -14,6 +14,7 @@
221
+ #define CHECKSUM_H
222
+
223
+ #include "storage/block.h"
224
+ + #include "port/pg_crc32c.h"
225
+
226
+ /*
227
+ * Compute the checksum for a Postgres page. The page must be aligned on a
228
+ @@ -21,4 +22,11 @@
229
+ */
230
+ extern uint16 pg_checksum_page(char *page, BlockNumber blkno);
231
+
232
+ + /*
233
+ + * Wrapper function for COMP_CRC32C macro. Was added to avoid
234
+ + * FRONTEND macro use for pg_comp_crc32c pointer in windows build.
235
+ + */
236
+ + extern pg_crc32c
237
+ + comp_crc32c(pg_crc32c *crc, const void *data, size_t len);
238
+ +
239
+ #endif /* CHECKSUM_H */
240
+ diff --git a/src/include/storage/checksum_impl.h b/src/include/storage/checksum_impl.h
241
+ index a49d27febb..459c938018 100644
242
+ --- a/src/include/storage/checksum_impl.h
243
+ +++ b/src/include/storage/checksum_impl.h
244
+ @@ -213,3 +213,9 @@ pg_checksum_page(char *page, BlockNumber blkno)
245
+ */
246
+ return (checksum % 65535) + 1;
247
+ }
248
+ +
249
+ + pg_crc32c comp_crc32c(pg_crc32c *crc, const void *data, size_t len)
250
+ + {
251
+ + COMP_CRC32C(*crc, data, len);
252
+ + return *crc;
253
+ + }
228
254
diff --git a/src/include/storage/copydir.h b/src/include/storage/copydir.h
229
- index 4fef3e21072..e55430879c3 100644
255
+ index 4fef3e2107..e55430879c 100644
230
256
--- a/src/include/storage/copydir.h
231
257
+++ b/src/include/storage/copydir.h
232
258
@@ -13,6 +13,9 @@
233
259
#ifndef COPYDIR_H
234
260
#define COPYDIR_H
235
-
261
+
236
262
+ typedef void (*copydir_hook_type) (const char *path);
237
263
+ extern PGDLLIMPORT copydir_hook_type copydir_hook;
238
264
+
239
265
extern void copydir(char *fromdir, char *todir, bool recurse);
240
266
extern void copy_file(char *fromfile, char *tofile);
241
-
267
+
242
268
diff --git a/src/include/storage/smgr.h b/src/include/storage/smgr.h
243
- index 0298ed1a2bc..24c684771d0 100644
269
+ index 0298ed1a2b..24c684771d 100644
244
270
--- a/src/include/storage/smgr.h
245
271
+++ b/src/include/storage/smgr.h
246
272
@@ -116,6 +116,17 @@ extern void AtEOXact_SMgr(void);
247
273
/* internals: move me elsewhere -- ay 7/94 */
248
-
274
+
249
275
/* in md.c */
250
276
+
251
277
+ typedef void (*mdextend_hook_type) (RelFileNodeBackend smgr_rnode,
0 commit comments