PostgreSQL Source Code  git master
parse_manifest.h File Reference
#include "access/xlogdefs.h"
#include "common/checksum_helper.h"
#include "mb/pg_wchar.h"
Include dependency graph for parse_manifest.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  JsonManifestParseContext
 

Typedefs

typedef struct JsonManifestParseContext JsonManifestParseContext
 
typedef void(* json_manifest_perfile_callback) (JsonManifestParseContext *, char *pathname, size_t size, pg_checksum_type checksum_type, int checksum_length, uint8 *checksum_payload)
 
typedef void(* json_manifest_perwalrange_callback) (JsonManifestParseContext *, TimeLineID tli, XLogRecPtr start_lsn, XLogRecPtr end_lsn)
 
typedef void(* json_manifest_error_callback) (JsonManifestParseContext *, const char *fmt,...) pg_attribute_printf(2
 
typedef void(* pg_attribute_noreturn) ()
 

Functions

void json_parse_manifest (JsonManifestParseContext *context, char *buffer, size_t size)
 

Typedef Documentation

◆ json_manifest_error_callback

typedef void(* json_manifest_error_callback) (JsonManifestParseContext *, const char *fmt,...) pg_attribute_printf(2

Definition at line 31 of file parse_manifest.h.

◆ json_manifest_perfile_callback

typedef void(* json_manifest_perfile_callback) (JsonManifestParseContext *, char *pathname, size_t size, pg_checksum_type checksum_type, int checksum_length, uint8 *checksum_payload)

Definition at line 24 of file parse_manifest.h.

◆ json_manifest_perwalrange_callback

typedef void(* json_manifest_perwalrange_callback) (JsonManifestParseContext *, TimeLineID tli, XLogRecPtr start_lsn, XLogRecPtr end_lsn)

Definition at line 28 of file parse_manifest.h.

◆ JsonManifestParseContext

Definition at line 22 of file parse_manifest.h.

◆ pg_attribute_noreturn

typedef void(* pg_attribute_noreturn) ()

Definition at line 33 of file parse_manifest.h.

Function Documentation

◆ json_parse_manifest()

void json_parse_manifest ( JsonManifestParseContext context,
char *  buffer,
size_t  size 
)

Definition at line 119 of file parse_manifest.c.

References JsonSemAction::array_element_end, JsonSemAction::array_element_start, JsonSemAction::array_end, JsonSemAction::array_start, JsonManifestParseState::context, JM_EXPECT_EOF, JM_EXPECT_TOPLEVEL_START, json_errdetail(), json_manifest_array_end(), json_manifest_array_start(), json_manifest_object_end(), json_manifest_object_field_start(), json_manifest_object_start(), json_manifest_parse_failure(), json_manifest_scalar(), JSON_SUCCESS, makeJsonLexContextCstringLen(), JsonSemAction::object_end, JsonSemAction::object_field_end, JsonSemAction::object_field_start, JsonSemAction::object_start, parse(), pg_parse_json(), PG_UTF8, JsonManifestParseState::saw_version_field, JsonSemAction::scalar, JsonSemAction::semstate, JsonManifestParseState::state, and verify_manifest_checksum().

Referenced by parse_manifest_file().

121 {
122  JsonLexContext *lex;
123  JsonParseErrorType json_error;
124  JsonSemAction sem;
126 
127  /* Set up our private parsing context. */
128  parse.context = context;
130  parse.saw_version_field = false;
131 
132  /* Create a JSON lexing context. */
133  lex = makeJsonLexContextCstringLen(buffer, size, PG_UTF8, true);
134 
135  /* Set up semantic actions. */
136  sem.semstate = &parse;
142  sem.object_field_end = NULL;
143  sem.array_element_start = NULL;
144  sem.array_element_end = NULL;
146 
147  /* Run the actual JSON parser. */
148  json_error = pg_parse_json(lex, &sem);
149  if (json_error != JSON_SUCCESS)
150  json_manifest_parse_failure(context, json_errdetail(json_error, lex));
151  if (parse.state != JM_EXPECT_EOF)
152  json_manifest_parse_failure(context, "manifest ended unexpectedly");
153 
154  /* Verify the manifest checksum. */
155  verify_manifest_checksum(&parse, buffer, size);
156 }
json_struct_action array_end
Definition: jsonapi.h:110
static void json_manifest_scalar(void *state, char *token, JsonTokenType tokentype)
json_struct_action object_end
Definition: jsonapi.h:108
JsonManifestParseContext * context
json_struct_action object_start
Definition: jsonapi.h:107
char * json_errdetail(JsonParseErrorType error, JsonLexContext *lex)
Definition: jsonapi.c:1056
json_scalar_action scalar
Definition: jsonapi.h:115
static void verify_manifest_checksum(JsonManifestParseState *parse, char *buffer, size_t size)
JsonLexContext * makeJsonLexContextCstringLen(char *json, int len, int encoding, bool need_escapes)
Definition: jsonapi.c:155
static void json_manifest_parse_failure(JsonManifestParseContext *context, char *msg)
JsonManifestSemanticState state
JsonParseErrorType pg_parse_json(JsonLexContext *lex, JsonSemAction *sem)
Definition: jsonapi.c:179
json_ofield_action object_field_end
Definition: jsonapi.h:112
static void json_manifest_object_start(void *state)
static void json_manifest_array_start(void *state)
JsonParseErrorType
Definition: jsonapi.h:36
json_aelem_action array_element_start
Definition: jsonapi.h:113
json_struct_action array_start
Definition: jsonapi.h:109
static void json_manifest_object_field_start(void *state, char *fname, bool isnull)
json_ofield_action object_field_start
Definition: jsonapi.h:111
static void json_manifest_object_end(void *state)
void * semstate
Definition: jsonapi.h:106
static void json_manifest_array_end(void *state)
json_aelem_action array_element_end
Definition: jsonapi.h:114
static struct subre * parse(struct vars *, int, int, struct state *, struct state *)
Definition: regcomp.c:648