From e700131e6369506f6c2e87ecff61c441cf86121a Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Mon, 29 Jun 2026 13:37:54 +0200 Subject: [PATCH v1 01/15] Some const qualifications added in passing --- src/backend/access/transam/timeline.c | 4 +-- src/backend/access/transam/twophase.c | 4 +-- src/bin/pg_basebackup/receivelog.c | 2 +- src/bin/pg_combinebackup/reconstruct.c | 40 +++++++++++++------------- src/include/access/timeline.h | 4 +-- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/backend/access/transam/timeline.c b/src/backend/access/transam/timeline.c index 68e5f692d26..d49e52993b7 100644 --- a/src/backend/access/transam/timeline.c +++ b/src/backend/access/transam/timeline.c @@ -303,7 +303,7 @@ findNewestTimeLine(TimeLineID startTLI) */ void writeTimeLineHistory(TimeLineID newTLI, TimeLineID parentTLI, - XLogRecPtr switchpoint, char *reason) + XLogRecPtr switchpoint, const char *reason) { char path[MAXPGPATH]; char tmppath[MAXPGPATH]; @@ -461,7 +461,7 @@ writeTimeLineHistory(TimeLineID newTLI, TimeLineID parentTLI, * to avoid emplacing a bogus file. */ void -writeTimeLineHistoryFile(TimeLineID tli, char *content, int size) +writeTimeLineHistoryFile(TimeLineID tli, const char *content, int size) { char path[MAXPGPATH]; char tmppath[MAXPGPATH]; diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c index 1035e8b3fc7..e27efcaab47 100644 --- a/src/backend/access/transam/twophase.c +++ b/src/backend/access/transam/twophase.c @@ -240,7 +240,7 @@ static void MarkAsPreparingGuts(GlobalTransaction gxact, FullTransactionId fxid, const char *gid, TimestampTz prepared_at, Oid owner, Oid databaseid); static void RemoveTwoPhaseFile(FullTransactionId fxid, bool giveWarning); -static void RecreateTwoPhaseFile(FullTransactionId fxid, void *content, int len); +static void RecreateTwoPhaseFile(FullTransactionId fxid, const void *content, int len); /* * Register shared memory for two-phase state. @@ -1745,7 +1745,7 @@ RemoveTwoPhaseFile(FullTransactionId fxid, bool giveWarning) * Note: content and len don't include CRC. */ static void -RecreateTwoPhaseFile(FullTransactionId fxid, void *content, int len) +RecreateTwoPhaseFile(FullTransactionId fxid, const void *content, int len) { char path[MAXPGPATH]; pg_crc32c statefile_crc; diff --git a/src/bin/pg_basebackup/receivelog.c b/src/bin/pg_basebackup/receivelog.c index 77894b721e1..4925e992741 100644 --- a/src/bin/pg_basebackup/receivelog.c +++ b/src/bin/pg_basebackup/receivelog.c @@ -272,7 +272,7 @@ existsTimeLineHistoryFile(StreamCtl *stream) } static bool -writeTimeLineHistoryFile(StreamCtl *stream, char *filename, char *content) +writeTimeLineHistoryFile(StreamCtl *stream, const char *filename, const char *content) { int size = strlen(content); char histfname[MAXFNAMELEN]; diff --git a/src/bin/pg_combinebackup/reconstruct.c b/src/bin/pg_combinebackup/reconstruct.c index 3349aa2441d..0541e6dacab 100644 --- a/src/bin/pg_combinebackup/reconstruct.c +++ b/src/bin/pg_combinebackup/reconstruct.c @@ -49,23 +49,23 @@ typedef struct rfile static void debug_reconstruction(int n_source, rfile **sources, bool dry_run); -static unsigned find_reconstructed_block_length(rfile *s); -static rfile *make_incremental_rfile(char *filename); -static rfile *make_rfile(char *filename, bool missing_ok); -static void write_reconstructed_file(char *input_filename, - char *output_filename, +static unsigned find_reconstructed_block_length(const rfile *s); +static rfile *make_incremental_rfile(const char *filename); +static rfile *make_rfile(const char *filename, bool missing_ok); +static void write_reconstructed_file(const char *input_filename, + const char *output_filename, unsigned block_length, rfile **sourcemap, - off_t *offsetmap, + const off_t *offsetmap, pg_checksum_context *checksum_ctx, CopyMethod copy_method, bool debug, bool dry_run); -static void read_bytes(rfile *rf, void *buffer, unsigned length); -static void write_block(int fd, char *output_filename, - uint8 *buffer, +static void read_bytes(const rfile *rf, void *buffer, unsigned length); +static void write_block(int fd, const char *output_filename, + const uint8 *buffer, pg_checksum_context *checksum_ctx); -static void read_block(rfile *s, off_t off, uint8 *buffer); +static void read_block(const rfile *s, off_t off, uint8 *buffer); /* * Reconstruct a full file from an incremental file and a chain of prior @@ -436,7 +436,7 @@ debug_reconstruction(int n_source, rfile **sources, bool dry_run) * necessary to include those blocks. */ static unsigned -find_reconstructed_block_length(rfile *s) +find_reconstructed_block_length(const rfile *s) { unsigned block_length = s->truncation_block_length; unsigned i; @@ -453,7 +453,7 @@ find_reconstructed_block_length(rfile *s) * blocks it contains. */ static rfile * -make_incremental_rfile(char *filename) +make_incremental_rfile(const char *filename) { rfile *rf; unsigned magic; @@ -508,7 +508,7 @@ make_incremental_rfile(char *filename) * Allocate and perform basic initialization of an rfile. */ static rfile * -make_rfile(char *filename, bool missing_ok) +make_rfile(const char *filename, bool missing_ok) { rfile *rf; @@ -532,7 +532,7 @@ make_rfile(char *filename, bool missing_ok) * Read the indicated number of bytes from an rfile into the buffer. */ static void -read_bytes(rfile *rf, void *buffer, unsigned length) +read_bytes(const rfile *rf, void *buffer, unsigned length) { int rb = read(rf->fd, buffer, length); @@ -550,11 +550,11 @@ read_bytes(rfile *rf, void *buffer, unsigned length) * Write out a reconstructed file. */ static void -write_reconstructed_file(char *input_filename, - char *output_filename, +write_reconstructed_file(const char *input_filename, + const char *output_filename, unsigned block_length, rfile **sourcemap, - off_t *offsetmap, + const off_t *offsetmap, pg_checksum_context *checksum_ctx, CopyMethod copy_method, bool debug, @@ -750,8 +750,8 @@ write_reconstructed_file(char *input_filename, * provided only for the error message. */ static void -write_block(int fd, char *output_filename, - uint8 *buffer, pg_checksum_context *checksum_ctx) +write_block(int fd, const char *output_filename, + const uint8 *buffer, pg_checksum_context *checksum_ctx) { int wb; @@ -774,7 +774,7 @@ write_block(int fd, char *output_filename, * Read a block of data (BLCKSZ bytes) into the buffer. */ static void -read_block(rfile *s, off_t off, uint8 *buffer) +read_block(const rfile *s, off_t off, uint8 *buffer) { int rb; diff --git a/src/include/access/timeline.h b/src/include/access/timeline.h index 97f1d619c35..76b852d07ab 100644 --- a/src/include/access/timeline.h +++ b/src/include/access/timeline.h @@ -33,8 +33,8 @@ extern List *readTimeLineHistory(TimeLineID targetTLI); extern bool existsTimeLineHistory(TimeLineID probeTLI); extern TimeLineID findNewestTimeLine(TimeLineID startTLI); extern void writeTimeLineHistory(TimeLineID newTLI, TimeLineID parentTLI, - XLogRecPtr switchpoint, char *reason); -extern void writeTimeLineHistoryFile(TimeLineID tli, char *content, int size); + XLogRecPtr switchpoint, const char *reason); +extern void writeTimeLineHistoryFile(TimeLineID tli, const char *content, int size); extern void restoreTimeLineHistoryFiles(TimeLineID begin, TimeLineID end); extern bool tliInHistory(TimeLineID tli, List *expectedTLEs); extern TimeLineID tliOfPointInHistory(XLogRecPtr ptr, List *history); base-commit: b7e4e3e7fa73458ecca5cd10f341743fd12a4faa -- 2.54.0