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-21 17:05:15
Message-ID: b6f978bc-4d13-fd61-742b-69d3835b8c26@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.

>> Do we need to decouple tuple descriptors from pg_attribute altogether?
>
> Yes. Very clearly. The amount of memory and runtime we spent on tupledescs is
> disproportionate. A second angle is that we build tupledescs way way too
> frequently. The executor infers them everywhere, so not even prepared
> statements protect against that.
>
>
>> How do we decide what goes into the tuple descriptor and what does not? I'm
>> interested in addressing this, because obviously we do want the ability to
>> add more features in the future, but I don't know what the direction should
>> be.
>
> We've had some prior discussion around this, see e.g.
> https://postgr.es/m/20210819114435.6r532qbadcsyfscp%40alap3.anarazel.de

This sounds like a good plan.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2023-03-21 17:10:08 Re: Add SHELL_EXIT_CODE to psql
Previous Message Andres Freund 2023-03-21 16:43:23 Re: Save a few bytes in pg_attribute