Skip to content

Commit ff41a5d

Browse files
committed
Clean up new JSON API typedefs
The new JSON API uses a bit of an unusual typedef scheme, where for example OkeysState is a pointer to okeysState. And that's not applied consistently either. Change that to the more usual PostgreSQL style where struct typedefs are upper case, and use pointers explicitly.
1 parent 6737aa7 commit ff41a5d

File tree

3 files changed

+100
-102
lines changed

3 files changed

+100
-102
lines changed

src/backend/utils/adt/json.c

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ typedef enum /* contexts of JSON parser */
5151
static inline void json_lex(JsonLexContext *lex);
5252
static inline void json_lex_string(JsonLexContext *lex);
5353
static inline void json_lex_number(JsonLexContext *lex, char *s);
54-
static inline void parse_scalar(JsonLexContext *lex, JsonSemAction sem);
55-
static void parse_object_field(JsonLexContext *lex, JsonSemAction sem);
56-
static void parse_object(JsonLexContext *lex, JsonSemAction sem);
57-
static void parse_array_element(JsonLexContext *lex, JsonSemAction sem);
58-
static void parse_array(JsonLexContext *lex, JsonSemAction sem);
54+
static inline void parse_scalar(JsonLexContext *lex, JsonSemAction *sem);
55+
static void parse_object_field(JsonLexContext *lex, JsonSemAction *sem);
56+
static void parse_object(JsonLexContext *lex, JsonSemAction *sem);
57+
static void parse_array_element(JsonLexContext *lex, JsonSemAction *sem);
58+
static void parse_array(JsonLexContext *lex, JsonSemAction *sem);
5959
static void report_parse_error(JsonParseContext ctx, JsonLexContext *lex);
6060
static void report_invalid_token(JsonLexContext *lex);
6161
static int report_json_context(JsonLexContext *lex);
@@ -70,12 +70,11 @@ static void array_to_json_internal(Datum array, StringInfo result,
7070
bool use_line_feeds);
7171

7272
/* the null action object used for pure validation */
73-
static jsonSemAction nullSemAction =
73+
static JsonSemAction nullSemAction =
7474
{
7575
NULL, NULL, NULL, NULL, NULL,
7676
NULL, NULL, NULL, NULL, NULL
7777
};
78-
static JsonSemAction NullSemAction = &nullSemAction;
7978

8079
/* Recursive Descent parser support routines */
8180

@@ -170,7 +169,7 @@ json_in(PG_FUNCTION_ARGS)
170169

171170
/* validate it */
172171
lex = makeJsonLexContext(result, false);
173-
pg_parse_json(lex, NullSemAction);
172+
pg_parse_json(lex, &nullSemAction);
174173

175174
/* Internal representation is the same as text, for now */
176175
PG_RETURN_TEXT_P(result);
@@ -222,7 +221,7 @@ json_recv(PG_FUNCTION_ARGS)
222221

223222
/* Validate it. */
224223
lex = makeJsonLexContext(result, false);
225-
pg_parse_json(lex, NullSemAction);
224+
pg_parse_json(lex, &nullSemAction);
226225

227226
PG_RETURN_TEXT_P(result);
228227
}
@@ -260,7 +259,7 @@ makeJsonLexContext(text *json, bool need_escapes)
260259
* pointer to a state object to be passed to those routines.
261260
*/
262261
void
263-
pg_parse_json(JsonLexContext *lex, JsonSemAction sem)
262+
pg_parse_json(JsonLexContext *lex, JsonSemAction *sem)
264263
{
265264
JsonTokenType tok;
266265

@@ -296,7 +295,7 @@ pg_parse_json(JsonLexContext *lex, JsonSemAction sem)
296295
* - object field
297296
*/
298297
static inline void
299-
parse_scalar(JsonLexContext *lex, JsonSemAction sem)
298+
parse_scalar(JsonLexContext *lex, JsonSemAction *sem)
300299
{
301300
char *val = NULL;
302301
json_scalar_action sfunc = sem->scalar;
@@ -332,7 +331,7 @@ parse_scalar(JsonLexContext *lex, JsonSemAction sem)
332331
}
333332

334333
static void
335-
parse_object_field(JsonLexContext *lex, JsonSemAction sem)
334+
parse_object_field(JsonLexContext *lex, JsonSemAction *sem)
336335
{
337336
/*
338337
* an object field is "fieldname" : value where value can be a scalar,
@@ -380,7 +379,7 @@ parse_object_field(JsonLexContext *lex, JsonSemAction sem)
380379
}
381380

382381
static void
383-
parse_object(JsonLexContext *lex, JsonSemAction sem)
382+
parse_object(JsonLexContext *lex, JsonSemAction *sem)
384383
{
385384
/*
386385
* an object is a possibly empty sequence of object fields, separated by
@@ -428,7 +427,7 @@ parse_object(JsonLexContext *lex, JsonSemAction sem)
428427
}
429428

430429
static void
431-
parse_array_element(JsonLexContext *lex, JsonSemAction sem)
430+
parse_array_element(JsonLexContext *lex, JsonSemAction *sem)
432431
{
433432
json_aelem_action astart = sem->array_element_start;
434433
json_aelem_action aend = sem->array_element_end;
@@ -459,7 +458,7 @@ parse_array_element(JsonLexContext *lex, JsonSemAction sem)
459458
}
460459

461460
static void
462-
parse_array(JsonLexContext *lex, JsonSemAction sem)
461+
parse_array(JsonLexContext *lex, JsonSemAction *sem)
463462
{
464463
/*
465464
* an array is a possibly empty sequence of array elements, separated by

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy