diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c index 238b671f7a..00b74118fb 100644 --- a/src/bin/pg_basebackup/pg_basebackup.c +++ b/src/bin/pg_basebackup/pg_basebackup.c @@ -41,6 +41,7 @@ #include "receivelog.h" #include "replication/basebackup.h" #include "streamutil.h" +#include "utils/jsonapi.h" #define ERRCODE_DATA_CORRUPTED "XX001" @@ -2019,10 +2020,40 @@ BaseBackup(void) pg_log_info("base backup completed"); } +void +jsonOFieldAction(void *state, char *fname, bool isnull) +{ + fprintf(stderr, " FIELD \"%s\", null %d\n", fname, isnull); fflush(stderr); + pfree(fname); +} + +void +jsonScalarAction(void *state, char *token, JsonTokenType tokentype) +{ + fprintf(stderr, " SCALAR TYPE %u: %s\n", tokentype, token); fflush(stderr); + pfree(token); +} int main(int argc, char **argv) { + if (true) + { + char json[] = "{\"number\": 123, \"string\": \"val\\tue-丏\", \"bool\": true, \"null\": null}"; + JsonSemAction sem = {.semstate = NULL, .scalar = jsonScalarAction, .object_field_start = jsonOFieldAction}; + JsonLexContext *lex; + + fprintf(stderr, "START\n"); fflush(stderr); + + lex = makeJsonLexContextCstringLen(json, strlen(json), true); + + pg_parse_json(lex, &sem); + + fprintf(stderr, "END\n"); fflush(stderr); + + exit(0); + } + static struct option long_options[] = { {"help", no_argument, NULL, '?'}, {"version", no_argument, NULL, 'V'},