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

Commit58a9031

Browse files
author
Nikita Glukhov
committed
Add json<=>jsonb casts
1 parent5950bca commit58a9031

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3057,3 +3057,9 @@ json_null_cm_handler(PG_FUNCTION_ARGS)
30573057

30583058
PG_RETURN_POINTER(cmr);
30593059
}
3060+
3061+
Datum
3062+
json_to_jsonb(PG_FUNCTION_ARGS)
3063+
{
3064+
PG_RETURN_DATUM(JsonGetDatum(JsonGetUniquified(PG_GETARG_JSONB(0))));
3065+
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,12 @@ jsonb_typeof(PG_FUNCTION_ARGS)
235235
}
236236

237237
#ifndefJSON_C
238+
Datum
239+
jsonb_to_json(PG_FUNCTION_ARGS)
240+
{
241+
PG_RETURN_DATUM(JsonGetDatum(PG_GETARG_JSONB(0)));
242+
}
243+
238244
JsonbValue*
239245
JsonValueFromCString(char*json,intlen)
240246
{

‎src/include/catalog/pg_cast.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ DATA(insert ( 1562 1562 1687 i f ));
389389
DATA(insert (170017001703if ));
390390

391391
/* json to/from jsonb */
392-
DATA(insert (11438020ai ));
393-
DATA(insert (38021140ai ));
392+
DATA(insert (11438024161af ));
393+
DATA(insert (38021144160af ));
394394

395395
#endif/* PG_CAST_H */

‎src/include/catalog/pg_proc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4454,6 +4454,8 @@ DATA(insert OID = 323 ( json_recv PGNSP PGUID 12 1 0 0 0 f f f f t f i s 1
44544454
DESCR("I/O");
44554455
DATA(insert OID = 324 ( json_send PGNSP PGUID 12 1 0 0 0 f f f f t f i s 1 0 17 "114" _null_ _null_ _null_ _null_ _null_ json_send _null_ _null_ _null_ ));
44564456
DESCR("I/O");
4457+
DATA(insert OID = 4160 ( json PGNSP PGUID 12 1 0 0 0 f f f f t f i s 1 0 114 "3802" _null_ _null_ _null_ _null_ _null_ jsonb_to_json _null_ _null_ _null_ ));
4458+
DESCR("cast jsonb as json");
44574459
DATA(insert OID = 3153 ( array_to_json PGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 114 "2277" _null_ _null_ _null_ _null_ _null_ array_to_json _null_ _null_ _null_ ));
44584460
DESCR("map array to json");
44594461
DATA(insert OID = 3154 ( array_to_json PGNSP PGUID 12 1 0 0 0 f f f f t f s s 2 0 114 "2277 16" _null_ _null_ _null_ _null_ _null_ array_to_json_pretty _null_ _null_ _null_ ));
@@ -4922,6 +4924,8 @@ DATA(insert OID = 3804 ( jsonb_outPGNSP PGUID 12 1 0 0 0 f f f f t f i s 1 0
49224924
DESCR("I/O");
49234925
DATA(insert OID = 3803 ( jsonb_sendPGNSP PGUID 12 1 0 0 0 f f f f t f i s 1 0 17 "3802" _null_ _null_ _null_ _null_ _null_ jsonb_send _null_ _null_ _null_ ));
49244926
DESCR("I/O");
4927+
DATA(insert OID = 4161 ( jsonb PGNSP PGUID 12 1 0 0 0 f f f f t f i s 1 0 3802 "114" _null_ _null_ _null_ _null_ _null_ json_to_jsonb _null_ _null_ _null_ ));
4928+
DESCR("cast json as jsonb");
49254929

49264930
DATA(insert OID = 3263 ( jsonb_object PGNSP PGUID 12 1 0 0 0 f f f f t f i s 1 0 3802 "1009" _null_ _null_ _null_ _null_ _null_ jsonb_object _null_ _null_ _null_ ));
49274931
DESCR("map text array of key value pairs to jsonb object");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp