Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w4d5H-002Nsi-0l for pgsql-hackers@arkaria.postgresql.org; Mon, 23 Mar 2026 11:04:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w4d5F-00HAsZ-1o for pgsql-hackers@arkaria.postgresql.org; Mon, 23 Mar 2026 11:04:33 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w4d5F-00HAsG-0k for pgsql-hackers@lists.postgresql.org; Mon, 23 Mar 2026 11:04:33 +0000 Received: from mail-dl1-x1236.google.com ([2607:f8b0:4864:20::1236]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w4d5D-00000000fJL-0PQK for pgsql-hackers@postgresql.org; Mon, 23 Mar 2026 11:04:33 +0000 Received: by mail-dl1-x1236.google.com with SMTP id a92af1059eb24-128b9b7e3edso6226000c88.0 for ; Mon, 23 Mar 2026 04:04:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1774263869; cv=none; d=google.com; s=arc-20240605; b=ijGBMJf7Zzcve7HaipKfnAa/XRcq893pGn0OwsE+3C3BoD7V17cH0/7cx7lyDimrRB Ogki32F2X9/03gL9odr8y/U7y+o60BOE9Zy1brJZ8ooiWG+/Id1J4aV9TSY0PysmwiV5 5gQYMKmYPHLKMjZIsy0OEz9hHQdzqMvwPN5Od0uM72QQ/V+n8JbuifFu2hr03R7QHX8p dCSaQdo3rWBVDNo9zRVlvH8l47ZjsLnnb9It6cEECvqGnQAcL1pXaf0TBoVPi/fuFQT2 EFIGsLDOFYXtyfAV8sCgIAQfA/u5QpVt50Jus6zYOdQAMJmTveQvREqikY5+JAhaN07s 5B9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=Yf0csNBRRHn9TifVXmHqg/7n3PDIRWCTt5vp/ETSBfo=; fh=1eL919fJSEyzq1dhh7V0fOeBNum0glqR6S0FJV+G0tI=; b=KKJg0MTKoeXnDFj/TgaBQiGe0f6L5K8I/lWL0y6RJ82V7Gk564Hg6Ey6MzxZXIWMRg iNhti39S45WN0jquM4Bg+uRoDM3lujZceD1QAx2GYHfdluyTeEcQD7nRPO3g+Z/7hf6r ZCFz9DlJGbr5vj2K6WM3oM1EMOGU4IeECi6YGMqZP7T148KUpo8pMLDi7vSMDRgoBEzt tgCXTH668mqID7JJfdjR5q6gWNIR5ttuRb6bd27etk7HAygRCTB1HxW1H1m2+8wisi3E Ppuj48X2PWLdLc1LZ0Kty/Yb8Nud+ijr3CmuS2S88AZNQFXF72xWzVc70IcO3AOUhMTg idFw==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1774263869; x=1774868669; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Yf0csNBRRHn9TifVXmHqg/7n3PDIRWCTt5vp/ETSBfo=; b=fMiiaXDNIhI4/wyQroraCWNueKrE7V8HrwuLhwYoP+VA3B4j7Yiby9o85Zxbitk1qM muYDaCOJc8FL4DW0pfEhsFY+e0s2X8JuS/PxxEUrsSgcFPIc8nw/p6AnPser5+5tos5/ 4jPC+340k7/wuopZPmEiGsezQ+/G9jd/qCHOFoSRfSkkNzdpcdmpcGM878Z99+01ZrfH jyVnTiG+CA1jHadYy4d67QN+8jAS+Foi0Ykr21dB/aRoLg8OOe6ItD+4riqaHybH2QcH rdJtgoIPJQszLjn8PKV9RPj8Ui4jwsFv0gwiH+Grpw7xVzg4NfLXa2DOyIYietNf6XIy HUyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774263869; x=1774868669; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Yf0csNBRRHn9TifVXmHqg/7n3PDIRWCTt5vp/ETSBfo=; b=nboaS5wzuph3FYckgSkdS0v0Kgn5659hKcTV2gPQzXY2fklMMtfkeRXd+A4wHnBg1F hw9SBDdeRoYOdHdM60TcGTg+1ORVbAMiHUf3WAo3qSfDIKTui5Ej65NS03KJv8vmuCBM nn/OBdVFfqwDngXv7LRRYQcOD8+HzIeFrU9n0URgic1k1kVnfilLPPZcf9qvhhVFpzRn XcYFdaf3pSGMSUExwNY1Saa5niLNmXcpJnpCz+lnkbEtqT7PgXWmjfUgbtcBgRku8Pn+ mitljUPF+bGh6uDqfqawlkgMaWNmqzl43HADwC1SalM43kcmlaxKU16tom7G1DZpng1E b4wQ== X-Forwarded-Encrypted: i=1; AJvYcCWYFMvAErYMEsriLFR2RJQvxfWev9QP8O2MOSQ75J2R0ruCY9SLRAT6qhL4nt3pyUgAvaWek0htQdQuHOhj@postgresql.org X-Gm-Message-State: AOJu0Ywq1t3tyMZsPE2Jtj8lS0IDkui77FR1gTrwO6iX11AK34zX1YPz pGtQPyRqnBdmjuPKhgs85hpgR/k7kLCinOTLnukSLv5CA28y/yWIbN5gWQ8UiVp/ASOfL4PLSyD spV/GxSugnDxMTATBrKMDvUWZDLmUgjY= X-Gm-Gg: ATEYQzzBPYRFnG7MiZH6C1UROiJZXSrF+KnxWb6yoi+2HLzLn2v/uOb1xTG6CPv2GE2 QPpfGahkISTQe6c2qpDs0mHu5QcdBc60ES+6/tyjOJFB/AJ0FHDmAfw6fGCR7gsWOP1oOS0TZv8 qnV9O0NInjeuTGBM8FQSSD7SiBKshoe3dSgIgB4ZUG5a2qqusWvEsA1YkYNTxzuVMkdr2B85s5r SR3nI8aM67ug3RO42dlBcCP88xG+UFOB9eKp+ULPYzklupILRjO7mUejXVrUEAux4bXcn8wLq83 YulMu7x3 X-Received: by 2002:a05:7022:4590:b0:11a:51f9:db0 with SMTP id a92af1059eb24-12a726821f2mr5623009c88.11.1774263869167; Mon, 23 Mar 2026 04:04:29 -0700 (PDT) MIME-Version: 1.0 References: <64f1c69a-ceff-4b17-8298-58f255d075fc@gmail.com> <7f6e0ff9-05e9-4664-9c71-d9dd744362b9@gmail.com> <138cfd8c-b305-4303-9700-bc53ff4fb926@eisentraut.org> In-Reply-To: From: Isaac Morland Date: Mon, 23 Mar 2026 07:04:18 -0400 X-Gm-Features: AaiRm53txHIkCWeSgrOH7lDkkjIhBpz66Jmt8Kiwe1NUHStvJvjBxIvWmHJ4Jdc Message-ID: Subject: Re: Read-only connection mode for AI workflows. To: Jelte Fennema-Nio Cc: Greg Sabino Mullane , Peter Eisentraut , Andrei Lepikhov , Jack Bonatakis , pgsql-hackers , Bruce Momjian , Andres Freund Content-Type: multipart/alternative; boundary="000000000000a8dc93064daeff3e" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000a8dc93064daeff3e Content-Type: text/plain; charset="UTF-8" On Mon, 23 Mar 2026 at 05:10, Jelte Fennema-Nio wrote: > On Fri, 20 Mar 2026 at 13:33, Greg Sabino Mullane > wrote: > > I'm a +1 to the cluster-wide change, and a -1 to the per-connection idea > that started this thread, because I still don't see the need for it when we > have an existing roles/permissions system that gets the job done. You want > your untrusted agent to read from your database? Create a specific role for > that. If our existing per-role access controls are not sufficient, improve > them. > > I think they are insufficient for two reasons: > 1. Afaik there's no simple way to take an existing role and create a > new role from it that only has the read permissions of the original > role. Especially if you want those permissions to stay in sync between > the roles. > I don't think it's possible even in principle. As soon as the supposedly read-only role calls a security definer function, the session is no longer operating with the permissions of the supposedly read-only role. I think what is wanted is, in effect, very close to the ability to pretend that one is connected to a replica rather than the primary, What is requested already exists in a sense through the use of replication, but only at the entire instance level, not one session. In other words, what you suggest below, although it might be interesting to think about whether there are any other settings that would be useful to lock down in this fashion: I think the best way to address this thread is to have a way to "lock" > settings down, like discussed in this thread[1]. Then a user could > simply run the sql to lock down the transaction_read_only and get a > read-only connection that it could give to the LLM. > --000000000000a8dc93064daeff3e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Mon, 23 Mar 2026 at 05:10, Jelte Fenne= ma-Nio <postgres@jeltef.nl>= wrote:
On Fri, 20 Mar 2026 at 13:33, Greg Sabino Mullane <htamfids@gmail.com> wrote= :
> I'm a +1 to the cluster-wide change, and a -1 to the per-connectio= n idea that started this thread, because I still don't see the need for= it when we have an existing roles/permissions system that gets the job don= e. You want your untrusted agent to read from your database? Create a speci= fic role for that. If our existing per-role access controls are not suffici= ent, improve them.

I think they are insufficient for two reasons:
1. Afaik there's no simple way to take an existing role and create a new role from it that only has the read permissions of the original
role. Especially if you want those permissions to stay in sync between
the roles.

I don't think it's possible even i= n principle. As soon as the supposedly read-only role calls a security defi= ner function, the session is no longer operating with the permissions of th= e supposedly read-only role.

I think what is wante= d is, in effect, very close to the ability to pretend that one is connected= to a replica rather than the primary, What is requested already exists in= =C2=A0a sense through the use of replication, but only at the entire instan= ce level, not one session. In other words, what you suggest below, although= it might be interesting to think about whether there are any other setting= s that would be useful to lock down in this fashion:

I think the best way to address this thread is to have a way to "lock&= quot;
settings down, like discussed in this thread[1]. Then a user could
simply run the sql to lock down the transaction_read_only and get a
read-only connection that it could give to the LLM.
--000000000000a8dc93064daeff3e--