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

Commit5c4d00b

Browse files
author
Nikita Glukhov
committed
Add JsonbRoot(), JsonbGetSize() macros
1 parent4152c5b commit5c4d00b

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ jsonb_out(PG_FUNCTION_ARGS)
139139
Jsonb*jb=PG_GETARG_JSONB(0);
140140
char*out;
141141

142-
out=JsonbToCString(NULL,&jb->root,VARSIZE(jb));
142+
out=JsonbToCString(NULL,JsonbRoot(jb),JsonbGetSize(jb));
143143

144144
PG_RETURN_CSTRING(out);
145145
}
@@ -157,7 +157,7 @@ jsonb_send(PG_FUNCTION_ARGS)
157157
StringInfojtext=makeStringInfo();
158158
intversion=1;
159159

160-
(void)JsonbToCString(jtext,&jb->root,VARSIZE(jb));
160+
(void)JsonbToCString(jtext,JsonbRoot(jb),JsonbGetSize(jb));
161161

162162
pq_begintypsend(&buf);
163163
pq_sendint(&buf,version,1);

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,7 +1426,7 @@ get_jsonb_path_all(FunctionCallInfo fcinfo, bool as_text)
14261426
{
14271427
PG_RETURN_TEXT_P(cstring_to_text(JsonbToCString(NULL,
14281428
container,
1429-
VARSIZE(jb))));
1429+
JsonbGetSize(jb))));
14301430
}
14311431
else
14321432
{
@@ -1523,8 +1523,8 @@ get_jsonb_path_all(FunctionCallInfo fcinfo, bool as_text)
15231523
if (as_text)
15241524
{
15251525
PG_RETURN_TEXT_P(cstring_to_text(JsonbToCString(NULL,
1526-
&res->root,
1527-
VARSIZE(res))));
1526+
JsonbRoot(res),
1527+
JsonbGetSize(res))));
15281528
}
15291529
else
15301530
{
@@ -3995,7 +3995,7 @@ jsonb_pretty(PG_FUNCTION_ARGS)
39953995
Jsonb*jb=PG_GETARG_JSONB(0);
39963996
StringInfostr=makeStringInfo();
39973997

3998-
JsonbToCStringIndent(str,&jb->root,VARSIZE(jb));
3998+
JsonbToCStringIndent(str,JsonbRoot(jb),JsonbGetSize(jb));
39993999

40004000
PG_RETURN_TEXT_P(cstring_to_text_with_len(str->data,str->len));
40014001
}
@@ -4006,7 +4006,7 @@ jsonb_canonical(PG_FUNCTION_ARGS)
40064006
Jsonb*jb=PG_GETARG_JSONB(0);
40074007
StringInfostr=makeStringInfo();
40084008

4009-
JsonbToCStringCanonical(str,&jb->root,VARSIZE(jb));
4009+
JsonbToCStringCanonical(str,JsonbRoot(jb),JsonbGetSize(jb));
40104010

40114011
PG_RETURN_TEXT_P(cstring_to_text_with_len(str->data,str->len));
40124012
}

‎src/include/utils/jsonb.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ typedef enum
7070
#definePG_GETARG_JSONB(x)DatumGetJsonb(PG_GETARG_DATUM(x))
7171
#definePG_RETURN_JSONB(x)PG_RETURN_DATUM(JsonbGetDatum(x))
7272

73+
#defineJsonbRoot(jsonb)(&(jsonb)->root)
74+
#defineJsonbGetSize(jsonb)VARSIZE(jsonb)
75+
7376
typedefstructJsonbPairJsonbPair;
7477
typedefstructJsonbValueJsonbValue;
7578

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp