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 1w2V8n-000LZn-2h for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Mar 2026 14:11:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w2V8m-001uOi-0u for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Mar 2026 14:11:24 +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 1w2V8l-001uOa-3D for pgsql-hackers@lists.postgresql.org; Tue, 17 Mar 2026 14:11:23 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w2V8j-00000000c6f-0Frb for pgsql-hackers@postgresql.org; Tue, 17 Mar 2026 14:11:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=momjian.us; s=2026010100; h=In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-ID:Content-Description; bh=5kJLKVi60hvpNkO6sPDg6NMiduASp3y9jum68vNKqK8=; b=e7TtNHjEvp16IwMPy60FXcZda8 pQPPToeNx2vUVqpoBBsrjwDyHxTjuGHEnKj2xj6RaobgPHQagCJ/dZ5RGD0/KWkqn9+c43f7Qw+vP qvWckte43ENx5pgBbGMTLGAKauY8sGPrlDa57LnIFGbKrWY0ie9Zn+zEe+pzsFCoAWXQRaAT9CB9Z IziHfxx6eK2ZkQ635FidPmVxoBiHXM9fjGII0hxVNV7yPf5/Vajwio5fIan0FfgKIKve3oe2S23q/ QSiyH9eVvP1xjnhgTO1NwNY6BJ2nz90X+eDyJ6FAXCZ3h7DMX5boianm3fybLosAEoxbFzvZ8/MT7 a5ejVLSw==; Received: from bruce by momjian.us with local (Exim 4.98.2) (envelope-from ) id 1w2V8i-00000005M4L-2Tt3; Tue, 17 Mar 2026 10:11:20 -0400 Date: Tue, 17 Mar 2026 10:11:20 -0400 From: Bruce Momjian To: Andrei Lepikhov Cc: Jack Bonatakis , pgsql-hackers Subject: Re: Read-only connection mode for AI workflows. Message-ID: References: <64f1c69a-ceff-4b17-8298-58f255d075fc@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Mar 17, 2026 at 03:05:08PM +0100, Andrei Lepikhov wrote: > On 17/3/26 14:52, Bruce Momjian wrote: > > On Tue, Mar 17, 2026 at 11:04:25AM +0100, Andrei Lepikhov wrote: > > > On 16/3/26 22:25, Bruce Momjian wrote: > > > > On Mon, Mar 16, 2026 at 10:01:22PM +0100, Andrei Lepikhov wrote: > > > > > > I do think the underlying problem of safely exposing databases to > > > > > > automated agents is becoming increasingly common, so it seems like a > > > > > > useful area to explore. > > > > > > > > I agree the need a read-only sessions is going to get more urgent with > > > > MCP. Why doesn't the community code have a read-only session option > > > > that can't be changed? > > > > > > The pg_readonly project aims to answer this question: if it is easy and > > > cheap to implement as an extension, why do we need to touch the core? > > > > I think it is a fundamental feature the database should have by default. > > > > Why wasn’t read-only mode set up like this from the start? - I haven’t seen > any other DBMSs, aside from SQLite, offer this kind of guarantee. I have no idea why. I guess there just wasn't much demand, but now there clearly is with MCP. > If we want to move forward, it makes sense to use a session parameter and > add backend code to prevent violations. Agreed. > Postgres architecture looks well-suited for this feature. However, the > request is to block all backend changes, not just the usual XactReadOnly > limitations, but also things like vacuum, etc (temporary tables?). Should we > also consider cluster-wide restrictions? No, I don't think cluster-wide is in demand, but I might be wrong. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com Do not let urgent matters crowd out time for investment in the future.