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

Commitdff4f66

Browse files
author
Nikita Glukhov
committed
Avoid double compilation of jsonb_gin.c
1 parent3878d2b commitdff4f66

File tree

3 files changed

+134
-50
lines changed

3 files changed

+134
-50
lines changed

‎src/backend/utils/adt/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ OBJS = \
4545
int8.o\
4646
json.o\
4747
json_generic.o\
48-
json_gin.o\
4948
jsonb.o\
5049
jsonb_gin.o\
5150
jsonb_op.o\

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

Lines changed: 0 additions & 27 deletions
This file was deleted.

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

Lines changed: 134 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ add_gin_entry(GinEntries *entries, Datum entry)
200200
*
201201
*/
202202

203-
Datum
204-
gin_compare_jsonb(PG_FUNCTION_ARGS)
203+
staticDatum
204+
gin_compare_json_internal(FunctionCallInfofcinfo)
205205
{
206206
text*arg1=PG_GETARG_TEXT_PP(0);
207207
text*arg2=PG_GETARG_TEXT_PP(1);
@@ -227,10 +227,20 @@ gin_compare_jsonb(PG_FUNCTION_ARGS)
227227
}
228228

229229
Datum
230-
gin_extract_jsonb(PG_FUNCTION_ARGS)
230+
gin_compare_jsonb(PG_FUNCTION_ARGS)
231+
{
232+
returngin_compare_json_internal(fcinfo);
233+
}
234+
235+
Datum
236+
gin_compare_json(PG_FUNCTION_ARGS)/* XXX remove */
237+
{
238+
returngin_compare_json_internal(fcinfo);
239+
}
240+
241+
staticDatum*
242+
gin_extract_json_internal(Json*jb,int32*nentries)
231243
{
232-
Jsonb*jb= (Jsonb*)PG_GETARG_JSONB_P(0);
233-
int32*nentries= (int32*)PG_GETARG_POINTER(1);
234244
inttotal=JB_ROOT_COUNT(jb);
235245
JsonbIterator*it;
236246
JsonbValuev;
@@ -241,7 +251,7 @@ gin_extract_jsonb(PG_FUNCTION_ARGS)
241251
if (total==0)
242252
{
243253
*nentries=0;
244-
PG_RETURN_POINTER(NULL);
254+
returnNULL;
245255
}
246256

247257
if (total<0)
@@ -274,7 +284,21 @@ gin_extract_jsonb(PG_FUNCTION_ARGS)
274284

275285
*nentries=entries.count;
276286

277-
PG_RETURN_POINTER(entries.buf);
287+
returnentries.buf;
288+
}
289+
290+
Datum
291+
gin_extract_jsonb(PG_FUNCTION_ARGS)
292+
{
293+
PG_RETURN_POINTER(gin_extract_json_internal(PG_GETARG_JSONB_P(0),
294+
(int32*)PG_GETARG_POINTER(1)));
295+
}
296+
297+
Datum
298+
gin_extract_json(PG_FUNCTION_ARGS)
299+
{
300+
PG_RETURN_POINTER(gin_extract_json_internal(PG_GETARG_JSONT_P(0),
301+
(int32*)PG_GETARG_POINTER(1)));
278302
}
279303

280304
/* Append JsonPathGinPathItem to JsonPathGinPath (jsonb_ops) */
@@ -848,8 +872,8 @@ execute_jsp_gin_node(JsonPathGinNode *node, void *check, bool ternary)
848872
}
849873
}
850874

851-
Datum
852-
gin_extract_jsonb_query(PG_FUNCTION_ARGS)
875+
staticDatum
876+
gin_extract_json_query_internal(FunctionCallInfofcinfo,boolis_jsonb)
853877
{
854878
int32*nentries= (int32*)PG_GETARG_POINTER(1);
855879
StrategyNumberstrategy=PG_GETARG_UINT16(2);
@@ -860,7 +884,9 @@ gin_extract_jsonb_query(PG_FUNCTION_ARGS)
860884
{
861885
/* Query is a jsonb, so just apply gin_extract_jsonb... */
862886
entries= (Datum*)
863-
DatumGetPointer(DirectFunctionCall2(gin_extract_jsonb,
887+
DatumGetPointer(DirectFunctionCall2(is_jsonb ?
888+
gin_extract_jsonb :
889+
gin_extract_json,
864890
PG_GETARG_DATUM(0),
865891
PointerGetDatum(nentries)));
866892
/* ...although "contains {}" requires a full index scan */
@@ -931,7 +957,19 @@ gin_extract_jsonb_query(PG_FUNCTION_ARGS)
931957
}
932958

933959
Datum
934-
gin_consistent_jsonb(PG_FUNCTION_ARGS)
960+
gin_extract_jsonb_query(PG_FUNCTION_ARGS)
961+
{
962+
returngin_extract_json_query_internal(fcinfo, true);
963+
}
964+
965+
Datum
966+
gin_extract_json_query(PG_FUNCTION_ARGS)
967+
{
968+
returngin_extract_json_query_internal(fcinfo, false);
969+
}
970+
971+
staticDatum
972+
gin_consistent_json_internal(FunctionCallInfofcinfo)
935973
{
936974
bool*check= (bool*)PG_GETARG_POINTER(0);
937975
StrategyNumberstrategy=PG_GETARG_UINT16(1);
@@ -1015,7 +1053,19 @@ gin_consistent_jsonb(PG_FUNCTION_ARGS)
10151053
}
10161054

10171055
Datum
1018-
gin_triconsistent_jsonb(PG_FUNCTION_ARGS)
1056+
gin_consistent_jsonb(PG_FUNCTION_ARGS)
1057+
{
1058+
returngin_consistent_json_internal(fcinfo);
1059+
}
1060+
1061+
Datum
1062+
gin_consistent_json(PG_FUNCTION_ARGS)
1063+
{
1064+
returngin_consistent_json_internal(fcinfo);
1065+
}
1066+
1067+
staticDatum
1068+
gin_triconsistent_json_internal(FunctionCallInfofcinfo)
10191069
{
10201070
GinTernaryValue*check= (GinTernaryValue*)PG_GETARG_POINTER(0);
10211071
StrategyNumberstrategy=PG_GETARG_UINT16(1);
@@ -1079,6 +1129,18 @@ gin_triconsistent_jsonb(PG_FUNCTION_ARGS)
10791129
PG_RETURN_GIN_TERNARY_VALUE(res);
10801130
}
10811131

1132+
Datum
1133+
gin_triconsistent_jsonb(PG_FUNCTION_ARGS)
1134+
{
1135+
returngin_triconsistent_json_internal(fcinfo);
1136+
}
1137+
1138+
Datum
1139+
gin_triconsistent_json(PG_FUNCTION_ARGS)
1140+
{
1141+
returngin_triconsistent_json_internal(fcinfo);
1142+
}
1143+
10821144
/*
10831145
*
10841146
* jsonb_path_ops GIN opclass support functions
@@ -1091,11 +1153,9 @@ gin_triconsistent_jsonb(PG_FUNCTION_ARGS)
10911153
*
10921154
*/
10931155

1094-
Datum
1095-
gin_extract_jsonb_path(PG_FUNCTION_ARGS)
1156+
staticDatum*
1157+
gin_extract_json_path_internal(Json*jb,int32*nentries)
10961158
{
1097-
Jsonb*jb=PG_GETARG_JSONB_P(0);
1098-
int32*nentries= (int32*)PG_GETARG_POINTER(1);
10991159
inttotal=JB_ROOT_COUNT(jb);
11001160
JsonbIterator*it;
11011161
JsonbValuev;
@@ -1108,7 +1168,7 @@ gin_extract_jsonb_path(PG_FUNCTION_ARGS)
11081168
if (total==0)
11091169
{
11101170
*nentries=0;
1111-
PG_RETURN_POINTER(NULL);
1171+
returnNULL;
11121172
}
11131173

11141174
if (total<0)
@@ -1181,11 +1241,25 @@ gin_extract_jsonb_path(PG_FUNCTION_ARGS)
11811241

11821242
*nentries=entries.count;
11831243

1184-
PG_RETURN_POINTER(entries.buf);
1244+
returnentries.buf;
11851245
}
11861246

11871247
Datum
1188-
gin_extract_jsonb_query_path(PG_FUNCTION_ARGS)
1248+
gin_extract_jsonb_path(PG_FUNCTION_ARGS)
1249+
{
1250+
PG_RETURN_POINTER(gin_extract_json_path_internal(PG_GETARG_JSONB_P(0),
1251+
(int32*)PG_GETARG_POINTER(1)));
1252+
}
1253+
1254+
Datum
1255+
gin_extract_json_path(PG_FUNCTION_ARGS)
1256+
{
1257+
PG_RETURN_POINTER(gin_extract_json_path_internal(PG_GETARG_JSONT_P(0),
1258+
(int32*)PG_GETARG_POINTER(1)));
1259+
}
1260+
1261+
staticDatum
1262+
gin_extract_json_query_path_internal(FunctionCallInfofcinfo,boolis_jsonb)
11891263
{
11901264
int32*nentries= (int32*)PG_GETARG_POINTER(1);
11911265
StrategyNumberstrategy=PG_GETARG_UINT16(2);
@@ -1196,7 +1270,9 @@ gin_extract_jsonb_query_path(PG_FUNCTION_ARGS)
11961270
{
11971271
/* Query is a jsonb, so just apply gin_extract_jsonb_path ... */
11981272
entries= (Datum*)
1199-
DatumGetPointer(DirectFunctionCall2(gin_extract_jsonb_path,
1273+
DatumGetPointer(DirectFunctionCall2(is_jsonb ?
1274+
gin_extract_jsonb_path :
1275+
gin_extract_json_path,
12001276
PG_GETARG_DATUM(0),
12011277
PointerGetDatum(nentries)));
12021278

@@ -1225,7 +1301,19 @@ gin_extract_jsonb_query_path(PG_FUNCTION_ARGS)
12251301
}
12261302

12271303
Datum
1228-
gin_consistent_jsonb_path(PG_FUNCTION_ARGS)
1304+
gin_extract_jsonb_query_path(PG_FUNCTION_ARGS)
1305+
{
1306+
returngin_extract_json_query_path_internal(fcinfo, true);
1307+
}
1308+
1309+
Datum
1310+
gin_extract_json_query_path(PG_FUNCTION_ARGS)
1311+
{
1312+
returngin_extract_json_query_path_internal(fcinfo, false);
1313+
}
1314+
1315+
staticDatum
1316+
gin_consistent_json_path_internal(FunctionCallInfofcinfo)
12291317
{
12301318
bool*check= (bool*)PG_GETARG_POINTER(0);
12311319
StrategyNumberstrategy=PG_GETARG_UINT16(1);
@@ -1277,7 +1365,19 @@ gin_consistent_jsonb_path(PG_FUNCTION_ARGS)
12771365
}
12781366

12791367
Datum
1280-
gin_triconsistent_jsonb_path(PG_FUNCTION_ARGS)
1368+
gin_consistent_jsonb_path(PG_FUNCTION_ARGS)
1369+
{
1370+
returngin_consistent_json_path_internal(fcinfo);
1371+
}
1372+
1373+
Datum
1374+
gin_consistent_json_path(PG_FUNCTION_ARGS)
1375+
{
1376+
returngin_consistent_json_path_internal(fcinfo);
1377+
}
1378+
1379+
staticDatum
1380+
gin_triconsistent_json_path_internal(FunctionCallInfofcinfo)
12811381
{
12821382
GinTernaryValue*check= (GinTernaryValue*)PG_GETARG_POINTER(0);
12831383
StrategyNumberstrategy=PG_GETARG_UINT16(1);
@@ -1324,6 +1424,18 @@ gin_triconsistent_jsonb_path(PG_FUNCTION_ARGS)
13241424
PG_RETURN_GIN_TERNARY_VALUE(res);
13251425
}
13261426

1427+
Datum
1428+
gin_triconsistent_jsonb_path(PG_FUNCTION_ARGS)
1429+
{
1430+
returngin_triconsistent_json_path_internal(fcinfo);
1431+
}
1432+
1433+
Datum
1434+
gin_triconsistent_json_path(PG_FUNCTION_ARGS)
1435+
{
1436+
returngin_triconsistent_json_path_internal(fcinfo);
1437+
}
1438+
13271439
/*
13281440
* Construct a jsonb_ops GIN key from a flag byte and a textual representation
13291441
* (which need not be null-terminated). This function is responsible

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp