Re: pgcrypto: PGP armor headers

From: Marko Tiikkaja <marko(at)joh(dot)to>
To: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pgcrypto: PGP armor headers
Date: 2014-09-25 14:10:30
Message-ID: 54242256.8060500@joh.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 9/25/14 4:08 PM, Heikki Linnakangas wrote:
> On 09/25/2014 04:56 PM, Marko Tiikkaja wrote:
>> On 9/25/14 3:50 PM, Heikki Linnakangas wrote:
>>> On 09/10/2014 04:35 PM, Marko Tiikkaja wrote:
>>> It might've been a tad more efficient to return
>>> the StringInfo buffer directly from pgp_armor/dearmor, and avoid the
>>> extra palloc and memcpy, but this isn't performance critical enough for
>>> it to really matter.
>>
>> I couldn't see any way of doing that without breaking the VARDATA
>> abstraction. I even went looking for similar cases in the source code,
>> but couldn't find any. If you can come up with a way, feel free to
>> change that -- I'd like to learn myself.
>
> You could first append VARHDRSZ zeros to the StringInfo, then append the
> base64-encoded data, and last replace the zeros with the real length,
> using SET_VARSIZE.

That's assuming that VARDATA() is at exactly VARHDRSZ bytes. I couldn't
find any callers making that assumption.

.marko

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2014-09-25 14:12:43 Re: INSERT ... ON CONFLICT {UPDATE | IGNORE}
Previous Message Robert Haas 2014-09-25 14:09:30 Re: Scaling shared buffer eviction