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

Commitce0425b

Browse files
committed
Adjust src/include/utils/jsonapi.h so it's not backend-only.
The major change here is that we no longer include jsonb.h intojsonapi.h. The reason that was necessary is that jsonapi.h includedseveral prototypes functions in jsonfuncs.c that depend on the Jsonbtype. Move those prototypes to a new header, jsonfuncs.h, and includeit where needed.The other change is that JsonEncodeDateTime is now declared injson.h rather than jsonapi.h.Taken together, these steps eliminate all dependencies of jsonapi.hon backend-only data types and header files, so that it canpotentially be included in frontend code.
1 parentd694e0b commitce0425b

File tree

7 files changed

+55
-33
lines changed

7 files changed

+55
-33
lines changed

‎src/backend/tsearch/to_tsany.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include"tsearch/ts_utils.h"
1818
#include"utils/builtins.h"
1919
#include"utils/jsonapi.h"
20+
#include"utils/jsonfuncs.h"
2021

2122

2223
typedefstructMorphOpaque

‎src/backend/tsearch/wparser.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include"tsearch/ts_utils.h"
2222
#include"utils/builtins.h"
2323
#include"utils/jsonapi.h"
24+
#include"utils/jsonfuncs.h"
2425
#include"utils/varlena.h"
2526

2627
/******sql-level interface******/

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include"utils/builtins.h"
2020
#include"utils/datetime.h"
2121
#include"utils/hashutils.h"
22+
#include"utils/json.h"
2223
#include"utils/jsonapi.h"
2324
#include"utils/jsonb.h"
2425
#include"utils/memutils.h"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include"utils/json.h"
3030
#include"utils/jsonapi.h"
3131
#include"utils/jsonb.h"
32+
#include"utils/jsonfuncs.h"
3233
#include"utils/lsyscache.h"
3334
#include"utils/memutils.h"
3435
#include"utils/syscache.h"

‎src/include/utils/json.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,7 @@
1818

1919
/* functions in json.c */
2020
externvoidescape_json(StringInfobuf,constchar*str);
21+
externchar*JsonEncodeDateTime(char*buf,Datumvalue,Oidtypid,
22+
constint*tzp);
2123

2224
#endif/* JSON_H */

‎src/include/utils/jsonapi.h

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#ifndefJSONAPI_H
1515
#defineJSONAPI_H
1616

17-
#include"jsonb.h"
1817
#include"lib/stringinfo.h"
1918

2019
typedefenum
@@ -132,36 +131,4 @@ extern JsonLexContext *makeJsonLexContextCstringLen(char *json,
132131
*/
133132
externboolIsValidJsonNumber(constchar*str,intlen);
134133

135-
/*
136-
* Flag types for iterate_json(b)_values to specify what elements from a
137-
* json(b) document we want to iterate.
138-
*/
139-
typedefenumJsonToIndex
140-
{
141-
jtiKey=0x01,
142-
jtiString=0x02,
143-
jtiNumeric=0x04,
144-
jtiBool=0x08,
145-
jtiAll=jtiKey |jtiString |jtiNumeric |jtiBool
146-
}JsonToIndex;
147-
148-
/* an action that will be applied to each value in iterate_json(b)_values functions */
149-
typedefvoid (*JsonIterateStringValuesAction) (void*state,char*elem_value,intelem_len);
150-
151-
/* an action that will be applied to each value in transform_json(b)_values functions */
152-
typedeftext*(*JsonTransformStringValuesAction) (void*state,char*elem_value,intelem_len);
153-
154-
externuint32parse_jsonb_index_flags(Jsonb*jb);
155-
externvoiditerate_jsonb_values(Jsonb*jb,uint32flags,void*state,
156-
JsonIterateStringValuesActionaction);
157-
externvoiditerate_json_values(text*json,uint32flags,void*action_state,
158-
JsonIterateStringValuesActionaction);
159-
externJsonb*transform_jsonb_string_values(Jsonb*jsonb,void*action_state,
160-
JsonTransformStringValuesActiontransform_action);
161-
externtext*transform_json_string_values(text*json,void*action_state,
162-
JsonTransformStringValuesActiontransform_action);
163-
164-
externchar*JsonEncodeDateTime(char*buf,Datumvalue,Oidtypid,
165-
constint*tzp);
166-
167134
#endif/* JSONAPI_H */

‎src/include/utils/jsonfuncs.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* jsonfuncs.h
4+
* Functions to process JSON data types.
5+
*
6+
* Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
7+
* Portions Copyright (c) 1994, Regents of the University of California
8+
*
9+
* src/include/utils/jsonapi.h
10+
*
11+
*-------------------------------------------------------------------------
12+
*/
13+
14+
#ifndefJSONFUNCS_H
15+
#defineJSONFUNCS_H
16+
17+
#include"utils/jsonapi.h"
18+
#include"utils/jsonb.h"
19+
20+
/*
21+
* Flag types for iterate_json(b)_values to specify what elements from a
22+
* json(b) document we want to iterate.
23+
*/
24+
typedefenumJsonToIndex
25+
{
26+
jtiKey=0x01,
27+
jtiString=0x02,
28+
jtiNumeric=0x04,
29+
jtiBool=0x08,
30+
jtiAll=jtiKey |jtiString |jtiNumeric |jtiBool
31+
}JsonToIndex;
32+
33+
/* an action that will be applied to each value in iterate_json(b)_values functions */
34+
typedefvoid (*JsonIterateStringValuesAction) (void*state,char*elem_value,intelem_len);
35+
36+
/* an action that will be applied to each value in transform_json(b)_values functions */
37+
typedeftext*(*JsonTransformStringValuesAction) (void*state,char*elem_value,intelem_len);
38+
39+
externuint32parse_jsonb_index_flags(Jsonb*jb);
40+
externvoiditerate_jsonb_values(Jsonb*jb,uint32flags,void*state,
41+
JsonIterateStringValuesActionaction);
42+
externvoiditerate_json_values(text*json,uint32flags,void*action_state,
43+
JsonIterateStringValuesActionaction);
44+
externJsonb*transform_jsonb_string_values(Jsonb*jsonb,void*action_state,
45+
JsonTransformStringValuesActiontransform_action);
46+
externtext*transform_json_string_values(text*json,void*action_state,
47+
JsonTransformStringValuesActiontransform_action);
48+
49+
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp