public inbox for [email protected]  
help / color / mirror / Atom feed
From: Peter Eisentraut <[email protected]>
To: Andres Freund <[email protected]>
Cc: pgsql-hackers <[email protected]>
Subject: Re: Transparent column encryption
Date: Wed, 22 Mar 2023 10:00:45 +0100
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>

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.







view thread (9+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: Transparent column encryption
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox