Re: [PATCH] Add error handling to byteaout.

From: Andreas Seltenreich <andreas(dot)seltenreich(at)credativ(dot)de>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCH] Add error handling to byteaout.
Date: 2015-06-03 19:41:51
Message-ID: 87wpzkr340.fsf@ex.ansel.ydns.eu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Alvaro Herrera writes:

> Why not just use an unsigned 64 bit variable? Also, perhaps
> palloc_huge() avoids the whole problem in the first place ...

Ja, that crossed my mind too, but the current limit is already far
beyond anything that is usually configured for per-backend memory use,
so I dismissed it.

> though it might only move the issue around, if you cannot ship the
> longer-than-1GB resulting escaped value.

For example, when client and server encodings do not match:

,----[ mbutils.c ]
| result = palloc(len * MAX_CONVERSION_GROWTH + 1);
`----

This results in the fun fact that the maximum size for bytea values that
are guaranteed to be pg_dumpable regardless of encoding/escaping
settings is lower than 64MB.

One thing that would also mitigate the problem is supporting a more
efficient output format. For example, there's already means for
base64-encoding in the backend:

self=# select c, length(encode(mkbytea(28),c)) from (values ('hex'),('base64')) as v(c);
c | length
--------+-----------
hex | 536870912
base64 | 362623337
(2 rows)

Maybe it is reasonable to make it available as another option for use in
bytea_output?

regards,
Andreas

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andreas Seltenreich 2015-06-03 19:42:21 Re: [PATCH] Add error handling to byteaout.
Previous Message Alvaro Herrera 2015-06-03 19:04:47 Re: Re: [GENERAL] 9.4.1 -> 9.4.2 problem: could not access status of transaction 1