Skip to content

Commit eceec7b

Browse files
author
Nikita Glukhov
committed
Return back json_out(), json_send()
1 parent ce81cb5 commit eceec7b

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/backend/utils/adt/json.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,32 @@ json_in(PG_FUNCTION_ARGS)
4747
PG_RETURN_TEXT_P(result);
4848
}
4949

50+
/*
51+
* Output.
52+
*/
53+
Datum
54+
json_out(PG_FUNCTION_ARGS)
55+
{
56+
/* we needn't detoast because text_to_cstring will handle that */
57+
Datum txt = PG_GETARG_DATUM(0);
58+
59+
PG_RETURN_CSTRING(TextDatumGetCString(txt));
60+
}
61+
62+
/*
63+
* Binary send.
64+
*/
65+
Datum
66+
json_send(PG_FUNCTION_ARGS)
67+
{
68+
text *t = PG_GETARG_TEXT_PP(0);
69+
StringInfoData buf;
70+
71+
pq_begintypsend(&buf);
72+
pq_sendtext(&buf, VARDATA_ANY(t), VARSIZE_ANY_EXHDR(t));
73+
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
74+
}
75+
5076
/*
5177
* Binary receive.
5278
*/

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy