Re: Transparent column encryption

From: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Transparent column encryption
Date: 2023-03-22 09:00:45
Message-ID: 62cbdf73-e933-3020-18d2-9b854159032f@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 21.03.23 18:47, Andres Freund wrote:
> On 2023-03-21 18:05:15 +0100, Peter Eisentraut wrote:
>> On 16.03.23 17:36, Andres Freund wrote:
>>> Maybe a daft question, but why do we need a separate type and typmod for
>>> encrypted columns? Why isn't the fact that the column is encrypted exactly one
>>> new field, and we use the existing type/typmod fields?
>>
>> The way this is implemented is that for an encrypted column, the real
>> atttypid and atttypmod are one of the encrypted special types
>> (pg_encrypted_*). That way, most of the system doesn't need to care about
>> the details of encryption or whatnot, it just unpacks tuples etc. by looking
>> at atttypid, atttyplen, etc., and queries on encrypted data behave normally
>> by just looking at what operators etc. those types have. This approach
>> heavily contains the number of places that need to know about this feature
>> at all.
>
> I get that for the type, but why do we need the typmod duplicated as well?

Earlier patch versions didn't do that, but that got really confusing
about which type the typmod really belonged to, since code currently
assumes that typid+typmod makes sense. Earlier patch versions had three
fields (usertypid, keyid, encalg), and then I changed it to (usertypid,
usertypmod, keyid) and instead placed the encalg into the real typmod,
which made everything much cleaner.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2023-03-22 09:12:12 Re: Request for comment on setting binary format output per session
Previous Message David Rowley 2023-03-22 08:36:36 Re: An oversight in ExecInitAgg for grouping sets