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


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) ()


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 1 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.

121 {
122  JsonLexContext *lex;
123  JsonParseErrorType json_error;
124  JsonSemAction sem;
127  /* Set up our private parsing context. */
128  parse.context = context;
130  parse.saw_version_field = false;
132  /* Create a JSON lexing context. */
133  lex = makeJsonLexContextCstringLen(buffer, size, PG_UTF8, true);
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;
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, "parsing failed");
151  if (parse.state != JM_EXPECT_EOF)
152  json_manifest_parse_failure(context, "manifest ended unexpectedly");
154  /* Verify the manifest checksum. */
155  verify_manifest_checksum(&parse, buffer, size);
156 }
JsonLexContext * makeJsonLexContextCstringLen(char *json, int len, int encoding, bool need_escapes)
Definition: jsonapi.c:145
JsonParseErrorType pg_parse_json(JsonLexContext *lex, JsonSemAction *sem)
Definition: jsonapi.c:169
Definition: jsonapi.h:37
Definition: jsonapi.h:38
static void json_manifest_object_start(void *state)
static void json_manifest_object_field_start(void *state, char *fname, bool isnull)
static void json_manifest_parse_failure(JsonManifestParseContext *context, char *msg)
static void json_manifest_scalar(void *state, char *token, JsonTokenType tokentype)
static void json_manifest_object_end(void *state)
static void json_manifest_array_start(void *state)
static void verify_manifest_checksum(JsonManifestParseState *parse, char *buffer, size_t size)
static void json_manifest_array_end(void *state)
Definition: pg_wchar.h:232
static struct subre * parse(struct vars *v, int stopper, int type, struct state *init, struct state *final)
Definition: regcomp.c:717
json_struct_action array_end
Definition: jsonapi.h:110
json_struct_action object_start
Definition: jsonapi.h:107
json_ofield_action object_field_start
Definition: jsonapi.h:111
json_aelem_action array_element_start
Definition: jsonapi.h:113
json_scalar_action scalar
Definition: jsonapi.h:115
void * semstate
Definition: jsonapi.h:106
json_aelem_action array_element_end
Definition: jsonapi.h:114
json_struct_action array_start
Definition: jsonapi.h:109
json_struct_action object_end
Definition: jsonapi.h:108
json_ofield_action object_field_end
Definition: jsonapi.h:112

References JsonSemAction::array_element_end, JsonSemAction::array_element_start, JsonSemAction::array_end, JsonSemAction::array_start, JM_EXPECT_EOF, JM_EXPECT_TOPLEVEL_START, 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, JsonSemAction::scalar, JsonSemAction::semstate, and verify_manifest_checksum().

Referenced by parse_manifest_file().