varlena-perform.patch
text/x-patch
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
| File | + | − |
|---|---|---|
| src/backend/utils/adt/varlena.c | 14 | 6 |
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index e111d26..f24bbcd 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -442,12 +442,20 @@ textrecv(PG_FUNCTION_ARGS)
Datum
textsend(PG_FUNCTION_ARGS)
{
- text *t = PG_GETARG_TEXT_PP(0);
- StringInfoData buf;
-
- pq_begintypsend(&buf);
- pq_sendtext(&buf, VARDATA_ANY(t), VARSIZE_ANY_EXHDR(t));
- PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
+ text *t = PG_GETARG_TEXT_PP(0);
+ const char* textData = VARDATA_ANY(t);
+ const int textSize = VARSIZE_ANY_EXHDR(t);
+ char* textConverted = pg_server_to_client(textData, textSize);
+ //Logic based on pq_sendtext
+ if (textConverted == textData) {
+ PG_RETURN_BYTEA_P(t);
+ }else {
+ StringInfoData buf;
+ pq_begintypsend(&buf);
+ appendBinaryStringInfo(&buf, textConverted, strlen(textConverted));
+ pfree(textConverted);
+ PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
+ }
}