Skip to content

Commit d0706b9

Browse files
author
Nikita Glukhov
committed
Use PG_RETURN_JSONB()/JsonbGetDatum() instead of PG_RETURN_JSONB()/PointerGetDatum()
1 parent 525dbbf commit d0706b9

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

contrib/hstore/hstore_io.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,7 +1378,7 @@ hstore_to_jsonb(PG_FUNCTION_ARGS)
13781378

13791379
res = pushJsonbValue(&state, WJB_END_OBJECT, NULL);
13801380

1381-
PG_RETURN_POINTER(JsonbValueToJsonb(res));
1381+
PG_RETURN_JSONB(JsonbValueToJsonb(res));
13821382
}
13831383

13841384
PG_FUNCTION_INFO_V1(hstore_to_jsonb_loose);
@@ -1450,5 +1450,5 @@ hstore_to_jsonb_loose(PG_FUNCTION_ARGS)
14501450

14511451
res = pushJsonbValue(&state, WJB_END_OBJECT, NULL);
14521452

1453-
PG_RETURN_POINTER(JsonbValueToJsonb(res));
1453+
PG_RETURN_JSONB(JsonbValueToJsonb(res));
14541454
}

src/backend/utils/adt/jsonb.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ jsonb_from_cstring(char *json, int len)
252252
pg_parse_json(lex, &sem);
253253

254254
/* after parsing, the item member has the composed jsonb structure */
255-
PG_RETURN_POINTER(JsonbValueToJsonb(state.res));
255+
PG_RETURN_JSONB(JsonbValueToJsonb(state.res));
256256
}
257257

258258
static size_t
@@ -1121,7 +1121,7 @@ to_jsonb(PG_FUNCTION_ARGS)
11211121

11221122
datum_to_jsonb(val, false, &result, tcategory, outfuncoid, false);
11231123

1124-
PG_RETURN_POINTER(JsonbValueToJsonb(result.res));
1124+
PG_RETURN_JSONB(JsonbValueToJsonb(result.res));
11251125
}
11261126

11271127
/*
@@ -1200,7 +1200,7 @@ jsonb_build_object(PG_FUNCTION_ARGS)
12001200

12011201
result.res = pushJsonbValue(&result.parseState, WJB_END_OBJECT, NULL);
12021202

1203-
PG_RETURN_POINTER(JsonbValueToJsonb(result.res));
1203+
PG_RETURN_JSONB(JsonbValueToJsonb(result.res));
12041204
}
12051205

12061206
/*
@@ -1216,7 +1216,7 @@ jsonb_build_object_noargs(PG_FUNCTION_ARGS)
12161216
(void) pushJsonbValue(&result.parseState, WJB_BEGIN_OBJECT, NULL);
12171217
result.res = pushJsonbValue(&result.parseState, WJB_END_OBJECT, NULL);
12181218

1219-
PG_RETURN_POINTER(JsonbValueToJsonb(result.res));
1219+
PG_RETURN_JSONB(JsonbValueToJsonb(result.res));
12201220
}
12211221

12221222
/*
@@ -1260,7 +1260,7 @@ jsonb_build_array(PG_FUNCTION_ARGS)
12601260

12611261
result.res = pushJsonbValue(&result.parseState, WJB_END_ARRAY, NULL);
12621262

1263-
PG_RETURN_POINTER(JsonbValueToJsonb(result.res));
1263+
PG_RETURN_JSONB(JsonbValueToJsonb(result.res));
12641264
}
12651265

12661266
/*
@@ -1276,7 +1276,7 @@ jsonb_build_array_noargs(PG_FUNCTION_ARGS)
12761276
(void) pushJsonbValue(&result.parseState, WJB_BEGIN_ARRAY, NULL);
12771277
result.res = pushJsonbValue(&result.parseState, WJB_END_ARRAY, NULL);
12781278

1279-
PG_RETURN_POINTER(JsonbValueToJsonb(result.res));
1279+
PG_RETURN_JSONB(JsonbValueToJsonb(result.res));
12801280
}
12811281

12821282

@@ -1380,7 +1380,7 @@ jsonb_object(PG_FUNCTION_ARGS)
13801380
close_object:
13811381
result.res = pushJsonbValue(&result.parseState, WJB_END_OBJECT, NULL);
13821382

1383-
PG_RETURN_POINTER(JsonbValueToJsonb(result.res));
1383+
PG_RETURN_JSONB(JsonbValueToJsonb(result.res));
13841384
}
13851385

13861386
/*
@@ -1477,7 +1477,7 @@ jsonb_object_two_arg(PG_FUNCTION_ARGS)
14771477
close_object:
14781478
result.res = pushJsonbValue(&result.parseState, WJB_END_OBJECT, NULL);
14791479

1480-
PG_RETURN_POINTER(JsonbValueToJsonb(result.res));
1480+
PG_RETURN_JSONB(JsonbValueToJsonb(result.res));
14811481
}
14821482

14831483

@@ -1631,7 +1631,7 @@ jsonb_agg_finalfn(PG_FUNCTION_ARGS)
16311631

16321632
out = JsonbValueToJsonb(result.res);
16331633

1634-
PG_RETURN_POINTER(out);
1634+
PG_RETURN_JSONB(out);
16351635
}
16361636

16371637
/*
@@ -1863,5 +1863,5 @@ jsonb_object_agg_finalfn(PG_FUNCTION_ARGS)
18631863

18641864
out = JsonbValueToJsonb(result.res);
18651865

1866-
PG_RETURN_POINTER(out);
1866+
PG_RETURN_JSONB(out);
18671867
}

src/backend/utils/adt/jsonfuncs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1768,7 +1768,7 @@ each_worker_jsonb(FunctionCallInfo fcinfo, const char *funcname, bool as_text)
17681768
/* Not in text mode, just return the Jsonb */
17691769
Jsonb *val = JsonbValueToJsonb(&v);
17701770

1771-
values[1] = PointerGetDatum(val);
1771+
values[1] = JsonbGetDatum(val);
17721772
}
17731773

17741774
tuple = heap_form_tuple(ret_tdesc, values, nulls);
@@ -2041,7 +2041,7 @@ elements_worker_jsonb(FunctionCallInfo fcinfo, const char *funcname,
20412041
{
20422042
Jsonb *val = JsonbValueToJsonb(&v);
20432043

2044-
values[0] = PointerGetDatum(val);
2044+
values[0] = JsonbGetDatum(val);
20452045
}
20462046
else
20472047
{
@@ -3904,7 +3904,7 @@ jsonb_strip_nulls(PG_FUNCTION_ARGS)
39043904
bool last_was_key = false;
39053905

39063906
if (JB_ROOT_IS_SCALAR(jb))
3907-
PG_RETURN_POINTER(jb);
3907+
PG_RETURN_JSONB(jb);
39083908

39093909
it = JsonbIteratorInit(&jb->root);
39103910

@@ -3941,7 +3941,7 @@ jsonb_strip_nulls(PG_FUNCTION_ARGS)
39413941

39423942
Assert(res != NULL);
39433943

3944-
PG_RETURN_POINTER(JsonbValueToJsonb(res));
3944+
PG_RETURN_JSONB(JsonbValueToJsonb(res));
39453945
}
39463946

39473947
/*

0 commit comments

Comments
 (0)