Re: RFC: PostgreSQL Storage I/O Transformation Hooks

From: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
To: assam258(at)gmail(dot)com
Cc: Konstantin Knizhnik <knizhnik(at)garret(dot)ru>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: RFC: PostgreSQL Storage I/O Transformation Hooks
Date: 2025-12-28 15:20:52
Message-ID: CAN4CZFOS5GinAkk_y_9-w+KB8Ls-0+ZP5ktxkOO9-nO=w7s9ZQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> Is it reasonable to ask cryptography experts to clone the entire SMGR
> implementation and maintain code they don't fully understand just to
> insert encryption logic?

You don't have to clone the md.c logic with the recent smgr extension
patch, it does the same thing your patch does: it lets you hook into
it while still keeping the original md.c implementation. The
difference is that it doesn't add additional hooks to the API, instead
it makes all of the existing smgr/md.c functions hooks.

This also means that it lets different extensions work together in a
more generic way. For example an extension that wants to retrieve data
files from cloud storage when needed (prepending the original md.c
logic), and an encryption extension that wants to decrypt data after
loading it (appending to the original md.c logic) can both work
together while keeping the original logic in place.

Or if it's about mdwritev, in this patch you added a new
mdwrite_pre_hook - but it is executed at a specific point during
mdwrite. In the generic smgr patch, mdwritev itself (or smgr_writev
more specifically) is a hook, you can change it, and then call the
previous implementation (typically mdwritev) when you want it, either
before or after your custom code.

(the latest submitted version of the smgr patch doesn't use typical
postgres-style hooks, but that's one of the things we probably should
change. The intention is the same)

There's no maintenance fee of cloning, because neither extension
cloned the original md.c logic, both extended it.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Henson Choi 2025-12-28 15:25:01 Re: RFC: PostgreSQL Storage I/O Transformation Hooks
Previous Message Henson Choi 2025-12-28 14:53:54 Re: RFC: PostgreSQL Storage I/O Transformation Hooks