mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-02-11 19:20:40 +08:00
parse_manifest: Use const char *
This adapts the manifest parsing code to take advantage of the const-ified jsonapi. Reviewed-by: Andrew Dunstan <andrew@dunslane.net> Discussion: https://www.postgresql.org/message-id/flat/f732b014-f614-4600-a437-dba5a2c3738b%40eisentraut.org
This commit is contained in:
parent
15cd9a3881
commit
02bbc3c83a
@ -132,7 +132,7 @@ static void manifest_process_version(JsonManifestParseContext *context,
|
||||
static void manifest_process_system_identifier(JsonManifestParseContext *context,
|
||||
uint64 manifest_system_identifier);
|
||||
static void manifest_process_file(JsonManifestParseContext *context,
|
||||
char *pathname,
|
||||
const char *pathname,
|
||||
size_t size,
|
||||
pg_checksum_type checksum_type,
|
||||
int checksum_length,
|
||||
@ -1043,7 +1043,7 @@ manifest_process_system_identifier(JsonManifestParseContext *context,
|
||||
*/
|
||||
static void
|
||||
manifest_process_file(JsonManifestParseContext *context,
|
||||
char *pathname, size_t size,
|
||||
const char *pathname, size_t size,
|
||||
pg_checksum_type checksum_type,
|
||||
int checksum_length,
|
||||
uint8 *checksum_payload)
|
||||
|
@ -46,7 +46,7 @@
|
||||
*/
|
||||
#define SH_PREFIX manifest_files
|
||||
#define SH_ELEMENT_TYPE manifest_file
|
||||
#define SH_KEY_TYPE char *
|
||||
#define SH_KEY_TYPE const char *
|
||||
#define SH_KEY pathname
|
||||
#define SH_HASH_KEY(tb, key) hash_string(key)
|
||||
#define SH_EQUAL(tb, a, b) (strcmp(a, b) == 0)
|
||||
@ -60,7 +60,7 @@ static void combinebackup_version_cb(JsonManifestParseContext *context,
|
||||
static void combinebackup_system_identifier_cb(JsonManifestParseContext *context,
|
||||
uint64 manifest_system_identifier);
|
||||
static void combinebackup_per_file_cb(JsonManifestParseContext *context,
|
||||
char *pathname, size_t size,
|
||||
const char *pathname, size_t size,
|
||||
pg_checksum_type checksum_type,
|
||||
int checksum_length,
|
||||
uint8 *checksum_payload);
|
||||
@ -267,7 +267,7 @@ combinebackup_system_identifier_cb(JsonManifestParseContext *context,
|
||||
*/
|
||||
static void
|
||||
combinebackup_per_file_cb(JsonManifestParseContext *context,
|
||||
char *pathname, size_t size,
|
||||
const char *pathname, size_t size,
|
||||
pg_checksum_type checksum_type,
|
||||
int checksum_length, uint8 *checksum_payload)
|
||||
{
|
||||
|
@ -22,7 +22,7 @@
|
||||
typedef struct manifest_file
|
||||
{
|
||||
uint32 status; /* hash status */
|
||||
char *pathname;
|
||||
const char *pathname;
|
||||
size_t size;
|
||||
pg_checksum_type checksum_type;
|
||||
int checksum_length;
|
||||
@ -31,7 +31,7 @@ typedef struct manifest_file
|
||||
|
||||
#define SH_PREFIX manifest_files
|
||||
#define SH_ELEMENT_TYPE manifest_file
|
||||
#define SH_KEY_TYPE char *
|
||||
#define SH_KEY_TYPE const char *
|
||||
#define SH_SCOPE extern
|
||||
#define SH_RAW_ALLOCATOR pg_malloc0
|
||||
#define SH_DECLARE
|
||||
|
@ -52,7 +52,7 @@
|
||||
typedef struct manifest_file
|
||||
{
|
||||
uint32 status; /* hash status */
|
||||
char *pathname;
|
||||
const char *pathname;
|
||||
size_t size;
|
||||
pg_checksum_type checksum_type;
|
||||
int checksum_length;
|
||||
@ -70,7 +70,7 @@ typedef struct manifest_file
|
||||
*/
|
||||
#define SH_PREFIX manifest_files
|
||||
#define SH_ELEMENT_TYPE manifest_file
|
||||
#define SH_KEY_TYPE char *
|
||||
#define SH_KEY_TYPE const char *
|
||||
#define SH_KEY pathname
|
||||
#define SH_HASH_KEY(tb, key) hash_string(key)
|
||||
#define SH_EQUAL(tb, a, b) (strcmp(a, b) == 0)
|
||||
@ -123,7 +123,7 @@ static void verifybackup_version_cb(JsonManifestParseContext *context,
|
||||
static void verifybackup_system_identifier(JsonManifestParseContext *context,
|
||||
uint64 manifest_system_identifier);
|
||||
static void verifybackup_per_file_cb(JsonManifestParseContext *context,
|
||||
char *pathname, size_t size,
|
||||
const char *pathname, size_t size,
|
||||
pg_checksum_type checksum_type,
|
||||
int checksum_length,
|
||||
uint8 *checksum_payload);
|
||||
@ -155,7 +155,7 @@ static void report_backup_error(verifier_context *context,
|
||||
pg_attribute_printf(2, 3);
|
||||
static void report_fatal_error(const char *pg_restrict fmt,...)
|
||||
pg_attribute_printf(1, 2) pg_attribute_noreturn();
|
||||
static bool should_ignore_relpath(verifier_context *context, char *relpath);
|
||||
static bool should_ignore_relpath(verifier_context *context, const char *relpath);
|
||||
|
||||
static void progress_report(bool finished);
|
||||
static void usage(void);
|
||||
@ -546,7 +546,7 @@ verifybackup_system_identifier(JsonManifestParseContext *context,
|
||||
*/
|
||||
static void
|
||||
verifybackup_per_file_cb(JsonManifestParseContext *context,
|
||||
char *pathname, size_t size,
|
||||
const char *pathname, size_t size,
|
||||
pg_checksum_type checksum_type,
|
||||
int checksum_length, uint8 *checksum_payload)
|
||||
{
|
||||
@ -852,7 +852,7 @@ verify_file_checksum(verifier_context *context, manifest_file *m,
|
||||
char *fullpath, uint8 *buffer)
|
||||
{
|
||||
pg_checksum_context checksum_ctx;
|
||||
char *relpath = m->pathname;
|
||||
const char *relpath = m->pathname;
|
||||
int fd;
|
||||
int rc;
|
||||
size_t bytes_read = 0;
|
||||
@ -1016,13 +1016,13 @@ report_fatal_error(const char *pg_restrict fmt,...)
|
||||
* "aa/bb" is not a prefix of "aa/bbb", but it is a prefix of "aa/bb/cc".
|
||||
*/
|
||||
static bool
|
||||
should_ignore_relpath(verifier_context *context, char *relpath)
|
||||
should_ignore_relpath(verifier_context *context, const char *relpath)
|
||||
{
|
||||
SimpleStringListCell *cell;
|
||||
|
||||
for (cell = context->ignore_list.head; cell != NULL; cell = cell->next)
|
||||
{
|
||||
char *r = relpath;
|
||||
const char *r = relpath;
|
||||
char *v = cell->val;
|
||||
|
||||
while (*v != '\0' && *r == *v)
|
||||
|
@ -112,7 +112,7 @@ static void json_manifest_finalize_system_identifier(JsonManifestParseState *par
|
||||
static void json_manifest_finalize_file(JsonManifestParseState *parse);
|
||||
static void json_manifest_finalize_wal_range(JsonManifestParseState *parse);
|
||||
static void verify_manifest_checksum(JsonManifestParseState *parse,
|
||||
char *buffer, size_t size,
|
||||
const char *buffer, size_t size,
|
||||
pg_cryptohash_ctx *incr_ctx);
|
||||
static void json_manifest_parse_failure(JsonManifestParseContext *context,
|
||||
char *msg);
|
||||
@ -183,7 +183,7 @@ json_parse_manifest_incremental_shutdown(JsonManifestParseIncrementalState *incs
|
||||
|
||||
void
|
||||
json_parse_manifest_incremental_chunk(
|
||||
JsonManifestParseIncrementalState *incstate, char *chunk, size_t size,
|
||||
JsonManifestParseIncrementalState *incstate, const char *chunk, size_t size,
|
||||
bool is_last)
|
||||
{
|
||||
JsonParseErrorType res,
|
||||
@ -206,7 +206,7 @@ json_parse_manifest_incremental_chunk(
|
||||
if (!is_last)
|
||||
{
|
||||
if (pg_cryptohash_update(incstate->manifest_ctx,
|
||||
(uint8 *) chunk, size) < 0)
|
||||
(const uint8 *) chunk, size) < 0)
|
||||
context->error_cb(context, "could not update checksum of manifest");
|
||||
}
|
||||
else
|
||||
@ -225,7 +225,7 @@ json_parse_manifest_incremental_chunk(
|
||||
* invoked and is expected not to return.
|
||||
*/
|
||||
void
|
||||
json_parse_manifest(JsonManifestParseContext *context, char *buffer,
|
||||
json_parse_manifest(JsonManifestParseContext *context, const char *buffer,
|
||||
size_t size)
|
||||
{
|
||||
JsonLexContext *lex;
|
||||
@ -810,7 +810,7 @@ json_manifest_finalize_wal_range(JsonManifestParseState *parse)
|
||||
* parse incr_ctx will be NULL.
|
||||
*/
|
||||
static void
|
||||
verify_manifest_checksum(JsonManifestParseState *parse, char *buffer,
|
||||
verify_manifest_checksum(JsonManifestParseState *parse, const char *buffer,
|
||||
size_t size, pg_cryptohash_ctx *incr_ctx)
|
||||
{
|
||||
JsonManifestParseContext *context = parse->context;
|
||||
@ -858,7 +858,7 @@ verify_manifest_checksum(JsonManifestParseState *parse, char *buffer,
|
||||
{
|
||||
manifest_ctx = incr_ctx;
|
||||
}
|
||||
if (pg_cryptohash_update(manifest_ctx, (uint8 *) buffer, penultimate_newline + 1) < 0)
|
||||
if (pg_cryptohash_update(manifest_ctx, (const uint8 *) buffer, penultimate_newline + 1) < 0)
|
||||
context->error_cb(context, "could not update checksum of manifest");
|
||||
if (pg_cryptohash_final(manifest_ctx, manifest_checksum_actual,
|
||||
sizeof(manifest_checksum_actual)) < 0)
|
||||
|
@ -27,7 +27,7 @@ typedef void (*json_manifest_version_callback) (JsonManifestParseContext *,
|
||||
typedef void (*json_manifest_system_identifier_callback) (JsonManifestParseContext *,
|
||||
uint64 manifest_system_identifier);
|
||||
typedef void (*json_manifest_per_file_callback) (JsonManifestParseContext *,
|
||||
char *pathname,
|
||||
const char *pathname,
|
||||
size_t size, pg_checksum_type checksum_type,
|
||||
int checksum_length, uint8 *checksum_payload);
|
||||
typedef void (*json_manifest_per_wal_range_callback) (JsonManifestParseContext *,
|
||||
@ -48,10 +48,10 @@ struct JsonManifestParseContext
|
||||
};
|
||||
|
||||
extern void json_parse_manifest(JsonManifestParseContext *context,
|
||||
char *buffer, size_t size);
|
||||
const char *buffer, size_t size);
|
||||
extern JsonManifestParseIncrementalState *json_parse_manifest_incremental_init(JsonManifestParseContext *context);
|
||||
extern void json_parse_manifest_incremental_chunk(
|
||||
JsonManifestParseIncrementalState *incstate, char *chunk, size_t size,
|
||||
JsonManifestParseIncrementalState *incstate, const char *chunk, size_t size,
|
||||
bool is_last);
|
||||
extern void json_parse_manifest_incremental_shutdown(JsonManifestParseIncrementalState *incstate);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user