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 1w383M-000vYA-0i for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Mar 2026 07:44:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w383J-00H3Y8-2a for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Mar 2026 07:44:21 +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 1w383J-00H3Xy-1d for pgsql-hackers@lists.postgresql.org; Thu, 19 Mar 2026 07:44:21 +0000 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w383G-000000015Co-3MHF for pgsql-hackers@postgresql.org; Thu, 19 Mar 2026 07:44:21 +0000 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-43b3d9d0695so446040f8f.0 for ; Thu, 19 Mar 2026 00:44:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773906257; x=1774511057; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:content-language:references :to:from:subject:user-agent:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=JwWW7skd020ASptJZWGIETVbdQtjNsbwIzXN6zy5QWc=; b=N/0Gly94+9/Mj6CYnOh7XkmFj69OAqIiYYzn9h5dnf5np5o53KE6hS/irkzpQvX/Rh MgS0Y+592w6YBikcV+fA3IuJQr/y1u7LvWDV6Qf+sDnvI8OCn+ONUtFtRjOXnXIE+IVV 9N7mOCC/FIF57o+T07ke0coOv7bgXEPwoguz6pjA79q47jcAFoZC5ASafW7PCg9Ewe2A 3D+aURCmuQZE7xo/YnetSm9nM4iovrqNBfuHDUskB4PBWoDPl1uzmF6ET8QX7+k7jNYr OBQgE37iBMfW1GDWc0QI/RfrvYNnYyNqpup17DASMYzW1gRyC9CBiyO53tD3+vQczGNo N28g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773906257; x=1774511057; h=content-transfer-encoding:in-reply-to:content-language:references :to:from:subject:user-agent:mime-version:date:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=JwWW7skd020ASptJZWGIETVbdQtjNsbwIzXN6zy5QWc=; b=CDCv2Xa6PRWq1+kbicrwhnmjL05+ODLQA3JiKCF3bLB3fjlEEH8hrG1EYiQ1Yh8aQK NVZjFxeM/I9CvewnMOpAAWt6PizwDkp/+ofsJvzm+rmnloxff6Wq+i1tV5W1o0z0oRRO toHBwqnW2RhpSDsro0MHd0XruymvdntR/1c8p43+3lddPMQQf344Jxf0dd0XJ44Q2/gv EYDLP8lbnprqWnhXWHmcqYHUFTW3drY7ZUR7kkjac5FVN5jb5aZB6OKoVyUyqSkokh7d w2vnsh7BjaPH6qxWRStYkcBEsmMDs6WJxcoLdZHvoGRvMv3AMEZTPS9D/OWN3D1QxIQt 1hRg== X-Forwarded-Encrypted: i=1; AJvYcCXjox52o96cMhj47JoCnb/ceFUG5EhI43Pw2zQfP4C+qNtFuNbGJm8sAMtzwQXKaCe2yZRkztuh3aIIQMGt@postgresql.org X-Gm-Message-State: AOJu0Yz+erGCY2II6WTCR3dnHAn9N8fd8vY7f8T00DDifO8T7HqflpVF 6WcxHGHfEOBNUeCVqtrYDyz+BTQW98vfVT64jEl66vHPj2n9s9ZB73JH X-Gm-Gg: ATEYQzwTuBAyGx0hCiG1DancR4DuhYx/xVzfV0XB0RX8bzutr1rbddnNhuYaslOoTa3 uBTLZygiEVkU1JK9s1SmVK6+icwsIpTktyE/TfaGhdNyqXw+uuvr5eGcbVmKKdhZPMESiStMn1i 0BTKiY+dzHJW/H1tTCCc+6tW/2XxIFinfnUPC45hbfHmj43LqStpsdU3NSch+IssfVA/12L/Nje KiNnf4AtVSKImhP5we+Xtr01o+Spj2UJhJHHqj4tWGCC3R1jx15W6vX5zhhkMk+mKRkrmoJmrHC YkoUVLE756P8z0ywbUcg589IBQ004ohGXVoaT/8cH9kGIC/qaKiHWpT0q1jS/x+SsHBwuqAuCEC jP8hKOlNaWOtQaafbjxReTFGmQK07tMbm+PtdR+GezHMEC+viywcXFqR2rEuyTIw0grmxUbW80p nOQmee/qDzPWRkOVyskgKO+idvakgvxqY11Q== X-Received: by 2002:a05:6000:420a:b0:439:c24b:ec15 with SMTP id ffacd0b85a97d-43b576f0a50mr4339820f8f.5.1773906257305; Thu, 19 Mar 2026 00:44:17 -0700 (PDT) Received: from [192.168.15.192] ([80.251.191.198]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43b51899617sm14867693f8f.31.2026.03.19.00.44.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 19 Mar 2026 00:44:16 -0700 (PDT) Message-ID: <7f6e0ff9-05e9-4664-9c71-d9dd744362b9@gmail.com> Date: Thu, 19 Mar 2026 08:44:15 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Read-only connection mode for AI workflows. From: Andrei Lepikhov To: Jack Bonatakis , pgsql-hackers , Bruce Momjian , Andres Freund References: <64f1c69a-ceff-4b17-8298-58f255d075fc@gmail.com> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 16/3/26 22:01, Andrei Lepikhov wrote: > On 16/3/26 20:28, Jack Bonatakis wrote: >> On Mon, Mar 16, 2026, at 2:08 PM, Andrei Lepikhov wrote: >>> I believe the pg_readonly [1] extension does what you're looking for, so >>> you might want to give it a try. >> Please correct me if I am mistaken, but it looks like pg_readonly >> operates at the database or cluster level. Take a look at the [1] project. It's a simpler version of [2] that always switches to read-only mode. To use it, just have your connection pooler load the 'safesession' module. This will keep the session in read-only mode until it ends. There are no GUCs, and there is no way to change the mode, even for a superuser. Does this seem safe enough? We could improve it by restricting manual calls to specific utility operations, such as VACUUM or REINDEX. However, we would need some specifications first. [1] https://github.com/danolivo/safesession/ [2] https://github.com/pierreforstmann/pg_readonly -- regards, Andrei Lepikhov, pgEdge