Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit85829c9

Browse files
committed
Make nullSemAction const, add 'const' decorators to related functions
To make it more clear that these should never be modified.Reviewed-by: Andres FreundDiscussion:https://www.postgresql.org/message-id/54c29fb0-edf2-48ea-9814-44e918bbd6e8@iki.fi
1 parent1e35951 commit85829c9

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

‎src/backend/utils/adt/jsonfuncs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ static JsonParseErrorType transform_string_values_scalar(void *state, char *toke
514514
* returned when escontext is an ErrorSaveContext).
515515
*/
516516
bool
517-
pg_parse_json_or_errsave(JsonLexContext*lex,JsonSemAction*sem,
517+
pg_parse_json_or_errsave(JsonLexContext*lex,constJsonSemAction*sem,
518518
Node*escontext)
519519
{
520520
JsonParseErrorTyperesult;

‎src/common/jsonapi.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,15 @@ static char JSON_PROD_GOAL[] = {JSON_TOKEN_END, JSON_NT_JSON, 0};
213213
staticinlineJsonParseErrorTypejson_lex_string(JsonLexContext*lex);
214214
staticinlineJsonParseErrorTypejson_lex_number(JsonLexContext*lex,constchar*s,
215215
bool*num_err,size_t*total_len);
216-
staticinlineJsonParseErrorTypeparse_scalar(JsonLexContext*lex,JsonSemAction*sem);
217-
staticJsonParseErrorTypeparse_object_field(JsonLexContext*lex,JsonSemAction*sem);
218-
staticJsonParseErrorTypeparse_object(JsonLexContext*lex,JsonSemAction*sem);
219-
staticJsonParseErrorTypeparse_array_element(JsonLexContext*lex,JsonSemAction*sem);
220-
staticJsonParseErrorTypeparse_array(JsonLexContext*lex,JsonSemAction*sem);
216+
staticinlineJsonParseErrorTypeparse_scalar(JsonLexContext*lex,constJsonSemAction*sem);
217+
staticJsonParseErrorTypeparse_object_field(JsonLexContext*lex,constJsonSemAction*sem);
218+
staticJsonParseErrorTypeparse_object(JsonLexContext*lex,constJsonSemAction*sem);
219+
staticJsonParseErrorTypeparse_array_element(JsonLexContext*lex,constJsonSemAction*sem);
220+
staticJsonParseErrorTypeparse_array(JsonLexContext*lex,constJsonSemAction*sem);
221221
staticJsonParseErrorTypereport_parse_error(JsonParseContextctx,JsonLexContext*lex);
222222

223223
/* the null action object used for pure validation */
224-
JsonSemActionnullSemAction=
224+
constJsonSemActionnullSemAction=
225225
{
226226
NULL,NULL,NULL,NULL,NULL,
227227
NULL,NULL,NULL,NULL,NULL
@@ -519,7 +519,7 @@ freeJsonLexContext(JsonLexContext *lex)
519519
* other differences.
520520
*/
521521
JsonParseErrorType
522-
pg_parse_json(JsonLexContext*lex,JsonSemAction*sem)
522+
pg_parse_json(JsonLexContext*lex,constJsonSemAction*sem)
523523
{
524524
#ifdefFORCE_JSON_PSTACK
525525

@@ -648,7 +648,7 @@ json_count_array_elements(JsonLexContext *lex, int *elements)
648648
*/
649649
JsonParseErrorType
650650
pg_parse_json_incremental(JsonLexContext*lex,
651-
JsonSemAction*sem,
651+
constJsonSemAction*sem,
652652
constchar*json,
653653
size_tlen,
654654
boolis_last)
@@ -1005,7 +1005,7 @@ pg_parse_json_incremental(JsonLexContext *lex,
10051005
* - object field
10061006
*/
10071007
staticinlineJsonParseErrorType
1008-
parse_scalar(JsonLexContext*lex,JsonSemAction*sem)
1008+
parse_scalar(JsonLexContext*lex,constJsonSemAction*sem)
10091009
{
10101010
char*val=NULL;
10111011
json_scalar_actionsfunc=sem->scalar;
@@ -1049,7 +1049,7 @@ parse_scalar(JsonLexContext *lex, JsonSemAction *sem)
10491049
}
10501050

10511051
staticJsonParseErrorType
1052-
parse_object_field(JsonLexContext*lex,JsonSemAction*sem)
1052+
parse_object_field(JsonLexContext*lex,constJsonSemAction*sem)
10531053
{
10541054
/*
10551055
* An object field is "fieldname" : value where value can be a scalar,
@@ -1111,7 +1111,7 @@ parse_object_field(JsonLexContext *lex, JsonSemAction *sem)
11111111
}
11121112

11131113
staticJsonParseErrorType
1114-
parse_object(JsonLexContext*lex,JsonSemAction*sem)
1114+
parse_object(JsonLexContext*lex,constJsonSemAction*sem)
11151115
{
11161116
/*
11171117
* an object is a possibly empty sequence of object fields, separated by
@@ -1185,7 +1185,7 @@ parse_object(JsonLexContext *lex, JsonSemAction *sem)
11851185
}
11861186

11871187
staticJsonParseErrorType
1188-
parse_array_element(JsonLexContext*lex,JsonSemAction*sem)
1188+
parse_array_element(JsonLexContext*lex,constJsonSemAction*sem)
11891189
{
11901190
json_aelem_actionastart=sem->array_element_start;
11911191
json_aelem_actionaend=sem->array_element_end;
@@ -1229,7 +1229,7 @@ parse_array_element(JsonLexContext *lex, JsonSemAction *sem)
12291229
}
12301230

12311231
staticJsonParseErrorType
1232-
parse_array(JsonLexContext*lex,JsonSemAction*sem)
1232+
parse_array(JsonLexContext*lex,constJsonSemAction*sem)
12331233
{
12341234
/*
12351235
* an array is a possibly empty sequence of array elements, separated by

‎src/include/common/jsonapi.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,16 @@ typedef struct JsonSemAction
153153
* does nothing and just continues.
154154
*/
155155
externJsonParseErrorTypepg_parse_json(JsonLexContext*lex,
156-
JsonSemAction*sem);
156+
constJsonSemAction*sem);
157157

158158
externJsonParseErrorTypepg_parse_json_incremental(JsonLexContext*lex,
159-
JsonSemAction*sem,
159+
constJsonSemAction*sem,
160160
constchar*json,
161161
size_tlen,
162162
boolis_last);
163163

164164
/* the null action object used for pure validation */
165-
externPGDLLIMPORTJsonSemActionnullSemAction;
165+
externPGDLLIMPORTconstJsonSemActionnullSemAction;
166166

167167
/*
168168
* json_count_array_elements performs a fast secondary parse to determine the

‎src/include/utils/jsonfuncs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ typedef text *(*JsonTransformStringValuesAction) (void *state, char *elem_value,
4141
externJsonLexContext*makeJsonLexContext(JsonLexContext*lex,text*json,boolneed_escapes);
4242

4343
/* try to parse json, and errsave(escontext) on failure */
44-
externboolpg_parse_json_or_errsave(JsonLexContext*lex,JsonSemAction*sem,
44+
externboolpg_parse_json_or_errsave(JsonLexContext*lex,constJsonSemAction*sem,
4545
structNode*escontext);
4646

4747
#definepg_parse_json_or_ereport(lex,sem) \

‎src/test/modules/test_json_parser/test_json_parser_incremental.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ main(int argc, char **argv)
8484
size_tchunk_size=DEFAULT_CHUNK_SIZE;
8585
structstatstatbuf;
8686
off_tbytes_left;
87-
JsonSemAction*testsem=&nullSemAction;
87+
constJsonSemAction*testsem=&nullSemAction;
8888
char*testfile;
8989
intc;
9090
boolneed_strings= false;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp