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 1w2rqx-000gLr-33 for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Mar 2026 14:26:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w2rqw-00BRcq-2E for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Mar 2026 14:26:30 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w2rqw-00BRci-1L for pgsql-hackers@lists.postgresql.org; Wed, 18 Mar 2026 14:26:30 +0000 Received: from fhigh-a5-smtp.messagingengine.com ([103.168.172.156]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w2rqs-00000000N5h-3yqq for pgsql-hackers@postgresql.org; Wed, 18 Mar 2026 14:26:29 +0000 Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.phl.internal (Postfix) with ESMTP id E12881400033; Wed, 18 Mar 2026 10:26:27 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Wed, 18 Mar 2026 10:26:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1773843987; x=1773930387; bh=cl21efaJ9PMa/ICo4mzbublT3MXP3iTjz8mbdBbDHK8=; b= AN6TKBap1vtyqn3urYThkgBmiV27063TFrRaYP9//z1kUqAwq5xSv1gH6WuVkHCg fJC2JWgQyLD7cjBPS5DO0qEechWYdiybXzdtB33Z7zoEs9aPpS4IAfbIYM3sWhEY VAMmoum2BlftfHk9aW2q7scLDe70AnXkXe76ZfPS6cn5zh7WWuGbgD6/ODaUN4hR BJoZsSJdHj4Fp0jQ4jNezJg1lGjUV9KqO0MAhDwPPFeOvRP065JU6nJKHzs1xaIJ J4OviJV78gP9s9/qb+EUbAX0ifK/S3+EbWRcArPDx0puRt8lqkr36MwlKBOgHcg5 3vmQjJk5LnQalEdGeo1JbA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1773843987; x= 1773930387; bh=cl21efaJ9PMa/ICo4mzbublT3MXP3iTjz8mbdBbDHK8=; b=o rrPKamhIGgJIVw+rgGkK7ILa8D4QriogzfrTx8oG+U/xLvxSMeMC1+3VU1+2ducY Nt9ydSF9GGxxmYVVk5pkpOCn4QsKZybh7e2Z8qB+CBN0dnqA77SrlLzLJ9WHSZMV XremwJlwv3g3XjA6MgabvodO1eTzM56a4zgLiRhFgFLf1BfAerkb8YeiaMlJaqPC TjO/jk+GNS2M/Oet4DIEqc092lLn1AZdvGMDl7Z151NjSI7lSxkSHlc+1gC3YMpP h4ZcDfnnzdMCtWvYlcFKeA6aS02W38dFVaDrQHlc7Lk7yJ4tp2K3AQENeI1c8Pwd +OjqSC4Qd/Ni8vs3CKMZA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdeftdegfeejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkfhggtggugfgjsehtkefstddttdejnecuhfhrohhmpeetnhgurhgv shcuhfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucggtffrrg htthgvrhhnpedtleelvdfgjedvffeiueekfeeuleffhfegfffhgfffkeevueehieehhfei gffhvdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe grnhgurhgvshesrghnrghrrgiivghlrdguvgdpnhgspghrtghpthhtohephedpmhhouggv pehsmhhtphhouhhtpdhrtghpthhtohepjhgrtghksegsohhnrghtrghkrdhishdprhgtph htthhopehpvghtvghrsegvihhsvghnthhrrghuthdrohhrghdprhgtphhtthhopehlvghp ihhhohhvsehgmhgrihhlrdgtohhmpdhrtghpthhtohepsghruhgtvgesmhhomhhjihgrnh druhhspdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrshesphhoshhtghhrvghsqhhl rdhorhhg X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 18 Mar 2026 10:26:27 -0400 (EDT) Date: Wed, 18 Mar 2026 10:26:26 -0400 From: Andres Freund To: Peter Eisentraut Cc: Andrei Lepikhov , Bruce Momjian , 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 Hi, On 2026-03-18 14:48:41 +0100, Peter Eisentraut wrote: > On 17.03.26 15:05, 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. > > If we want to move forward, it makes sense to use a session parameter > > and add backend code to prevent violations. > > 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? > > Read-only mode is a transaction property, not an access control system. > > If you want to control who can read what, there is an access control system > for that. If it's insufficient, let's enhance it. But let's keep these > things separate. I don't agree that this need can be entirely addressed by access control. Regardless of the AI angle it's quite useful to be able to put a server into read only mode, e.g. in preparation for a planned failover where you can continue to allow reads but don't want any more writes. Or in preparation for a shutdown you want to prevent further writes (so the shutdown checkpoint is quick), but you do want to allow further reads (to reduce the scope of the downtime, by allowing reads while doing a CHECKPOINT before the actual shutdown). It doesn't make sense to implement stuff like that by changing all the access controls of the system, because it'll often be a temporary thing. So you have to figure out all the DDL to temporarily revoke permissions, have to somehow wait till those changes have taken hold for everything, then you have to figure out DDL to revert all those changes. Greetings, Andres