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 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;
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, "parsing failed");
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 }
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
JsonParseErrorType
Definition: jsonapi.h:37
@ JSON_SUCCESS
Definition: jsonapi.h:38
@ JM_EXPECT_TOPLEVEL_START
@ JM_EXPECT_EOF
static JsonParseErrorType json_manifest_array_start(void *state)
static JsonParseErrorType json_manifest_object_field_start(void *state, char *fname, bool isnull)
static JsonParseErrorType json_manifest_object_end(void *state)
static JsonParseErrorType json_manifest_object_start(void *state)
static JsonParseErrorType json_manifest_scalar(void *state, char *token, JsonTokenType tokentype)
static void json_manifest_parse_failure(JsonManifestParseContext *context, char *msg)
static JsonParseErrorType json_manifest_array_end(void *state)
static void verify_manifest_checksum(JsonManifestParseState *parse, char *buffer, size_t size)
@ PG_UTF8
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:715
json_struct_action array_end
Definition: jsonapi.h:118
json_struct_action object_start
Definition: jsonapi.h:115
json_ofield_action object_field_start
Definition: jsonapi.h:119
json_aelem_action array_element_start
Definition: jsonapi.h:121
json_scalar_action scalar
Definition: jsonapi.h:123
void * semstate
Definition: jsonapi.h:114
json_aelem_action array_element_end
Definition: jsonapi.h:122
json_struct_action array_start
Definition: jsonapi.h:117
json_struct_action object_end
Definition: jsonapi.h:116
json_ofield_action object_field_end
Definition: jsonapi.h:120

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