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

Commitf649da1

Browse files
author
Nikita Glukhov
committed
Add jsonb support for custom toasters
1 parent694c56b commitf649da1

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include"postgres.h"
1212

13+
#include"access/toasterapi.h"
1314
#include"miscadmin.h"
1415
#include"utils/builtins.h"
1516
#include"utils/jsonb.h"
@@ -101,9 +102,24 @@ JsonExpandDatum(Datum value, JsonContainerOps *ops, Json *tmp)
101102
Json*
102103
DatumGetJson(Datumvalue,JsonContainerOps*ops,Json*tmp)
103104
{
104-
Json*json=JsonExpandDatum(value,ops,tmp);
105+
Json*json;
105106

106-
//JsonInit(json);
107+
if (VARATT_IS_CUSTOM(value))
108+
{
109+
Oidtoasterid=VARATT_CUSTOM_GET_TOASTERID(value);
110+
TsrRoutine*toaster=SearchTsrCache(toasterid);
111+
JsonToastRoutine*routine=toaster->get_vtable(toasterid);
112+
113+
if (routine->magic==JSON_TOASTER_MAGIC)
114+
{
115+
json=JsonExpand(tmp,value, false,routine->ops);
116+
routine->ops->init(JsonRoot(json),value);
117+
118+
returnjson;
119+
}
120+
}
121+
122+
json=JsonExpandDatum(value,ops,tmp);
107123
json->root.ops->init(&json->root,json->obj.value);
108124

109125
returnjson;

‎src/include/utils/json_generic.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,4 +310,12 @@ extern int lengthCompareJsonbString(const char *val1, int len1,
310310

311311
externJsonContainerOpsjsonbContainerOps;
312312

313+
#defineJSON_TOASTER_MAGIC 0x20211223
314+
315+
typedefstructJsonToastRoutine
316+
{
317+
uint32magic;
318+
JsonContainerOps*ops;
319+
}JsonToastRoutine;
320+
313321
#endif/* UTILS_JSON_GENERIC_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp