|
12 | 12 | *------------------------------------------------------------------------- |
13 | 13 | */ |
14 | 14 |
|
15 | | -#define JSON_C |
16 | | -#define JSONB "json" |
17 | | - |
18 | | -#define JSONXOID JSONOID |
19 | | - |
20 | | -#define jsonb_in _json_in |
21 | | -#define jsonb_recv _json_recv |
22 | | - |
23 | | -#define jsonb_out json_out |
24 | | -#define jsonb_send json_send |
25 | | -#define to_jsonb to_json |
26 | | -#define jsonb_agg_transfn json_agg_transfn |
27 | | -#define jsonb_agg_finalfn json_agg_finalfn |
28 | | -#define jsonb_object_agg_transfn json_object_agg_transfn |
29 | | -#define jsonb_object_agg_finalfn json_object_agg_finalfn |
30 | | -#define jsonb_build_object json_build_object |
31 | | -#define jsonb_build_object_noargs json_build_object_noargs |
32 | | -#define jsonb_build_array json_build_array |
33 | | -#define jsonb_build_array_noargs json_build_array_noargs |
34 | | -#define jsonb_object json_object |
35 | | -#define jsonb_object_two_arg json_object_two_arg |
36 | | -#define jsonb_typeof json_typeof |
37 | | - |
38 | | -#define JsonxContainerOps (&jsontContainerOps) |
39 | | -#define JsonxGetUniquified(json) (json) |
40 | | -#define JsonxPGetDatum(json) JsontPGetDatum(json) |
41 | | - |
42 | 15 | #include "postgres.h" |
43 | 16 |
|
44 | 17 | #include "catalog/pg_type.h" |
@@ -259,82 +232,3 @@ escape_json(StringInfo buf, const char *str) |
259 | 232 | } |
260 | 233 | appendStringInfoCharMacro(buf, '"'); |
261 | 234 | } |
262 | | - |
263 | | -#include "jsonb.c" |
264 | | - |
265 | | -/* |
266 | | - * SQL function array_to_json(row) |
267 | | - */ |
268 | | -Datum |
269 | | -array_to_json(PG_FUNCTION_ARGS) |
270 | | -{ |
271 | | - Datum array = PG_GETARG_DATUM(0); |
272 | | - JsonbInState result = {0}; |
273 | | - |
274 | | - array_to_jsonb_internal(array, &result, false); |
275 | | - |
276 | | - PG_RETURN_JSONT_P(JsonbValueToJsonb(result.res)); |
277 | | -} |
278 | | - |
279 | | -/* |
280 | | - * SQL function array_to_json(row, prettybool) |
281 | | - */ |
282 | | -Datum |
283 | | -array_to_json_pretty(PG_FUNCTION_ARGS) |
284 | | -{ |
285 | | - Datum array = PG_GETARG_DATUM(0); |
286 | | - bool use_line_feeds = PG_GETARG_BOOL(1); |
287 | | - JsonbInState result = {0}; |
288 | | - |
289 | | - array_to_jsonb_internal(array, &result, false); |
290 | | - |
291 | | - if (use_line_feeds) |
292 | | - { |
293 | | - result.res->val.array.elementSeparator[0] = '\n'; |
294 | | - result.res->val.array.elementSeparator[1] = ' '; |
295 | | - } |
296 | | - else |
297 | | - result.res->val.array.elementSeparator[0] = '\0'; |
298 | | - |
299 | | - PG_RETURN_JSONT_P(JsonbValueToJsonb(result.res)); |
300 | | -} |
301 | | - |
302 | | -/* |
303 | | - * SQL function row_to_json(row) |
304 | | - */ |
305 | | -Datum |
306 | | -row_to_json(PG_FUNCTION_ARGS) |
307 | | -{ |
308 | | - Datum row = PG_GETARG_DATUM(0); |
309 | | - JsonbInState result = {0}; |
310 | | - |
311 | | - composite_to_jsonb(row, &result, false); |
312 | | - |
313 | | - PG_RETURN_JSONT_P(JsonbValueToJsonb(result.res)); |
314 | | -} |
315 | | - |
316 | | -/* |
317 | | - * SQL function row_to_json(row, prettybool) |
318 | | - */ |
319 | | -Datum |
320 | | -row_to_json_pretty(PG_FUNCTION_ARGS) |
321 | | -{ |
322 | | - Datum row = PG_GETARG_DATUM(0); |
323 | | - bool use_line_feeds = PG_GETARG_BOOL(1); |
324 | | - JsonbInState result = {0}; |
325 | | - |
326 | | - composite_to_jsonb(row, &result, false); |
327 | | - |
328 | | - if (use_line_feeds) |
329 | | - { |
330 | | - result.res->val.object.fieldSeparator[0] = '\n'; |
331 | | - result.res->val.object.fieldSeparator[1] = ' '; |
332 | | - } |
333 | | - else |
334 | | - { |
335 | | - result.res->val.object.fieldSeparator[0] = ' '; |
336 | | - result.res->val.object.fieldSeparator[1] = '\0'; |
337 | | - } |
338 | | - |
339 | | - PG_RETURN_JSONT_P(JsonbValueToJsonb(result.res)); |
340 | | -} |
0 commit comments