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 1vfnEF-0051T2-0l for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Jan 2026 22:51:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vfnED-006kS8-0O for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Jan 2026 22:51:09 +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 1vfnEC-006kS0-2k for pgsql-hackers@lists.postgresql.org; Tue, 13 Jan 2026 22:51:09 +0000 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vfnEB-000JFW-0R for pgsql-hackers@lists.postgresql.org; Tue, 13 Jan 2026 22:51:08 +0000 Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-bc2abdcfc6fso2996006a12.2 for ; Tue, 13 Jan 2026 14:51:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768344664; x=1768949464; darn=lists.postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ZIBQj22lmQigI+Xk1QP1Vv364t3jrVwIlLA055DFDwg=; b=XGj81qfL5xZa3FCTpLnyGrK0rYCOE6nPohlC49WGCMAspGBpPXcUnHCkRMTYc382Gq u8Pri5BWFgmZVkxnXE13SjYt/UclwLfZRQEk4yuJ5rFjX8JaA6XdUVsqpV8zZUOFNdUx g+XbYrRMgRIeCCRVQ5n3gBg0fuaV4r/wwTNaDVMPoG6lULIbw/lu2jn8F5CFI+gPAD/5 045xl3c3LRYN/2G9pzZn7sBEuN9KJUIi9AGT41cOsIsx6K2fpeEHhKt26eyJN7+4fM51 FCxcmZNPdbZol/dUYn2cs1aaVzuE0V4T4T7gegqS2nZToNz7NNXdGzcHtcjl8tR2Db2W UbJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768344664; x=1768949464; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZIBQj22lmQigI+Xk1QP1Vv364t3jrVwIlLA055DFDwg=; b=SjV7saCiGYIeywczXb6gQP1Unq8S5xlRrKzk8YWGOpzyygCRcEwGXkMTQGN3WfcetQ 1EpuaOoVkL7FxYArnki4gCHA9QR6GxNVSBgRIcQ4h4aqxPG2xDBA5iwG2GGEOy160gPC OdupjFdqHMycqKmBYO9+W6VIZrHt8wV9WXlHvsZFbJIOaApwdaaT4aVVQ7hSxJ2X3FZF d6xHGCFTU622GkSq5f9T1wy7qxyhy2PvPD5PqEUK8IxQtLzjPzHwi3ND4hu/Q3XlwX+r Y3QFa3lC76gEbzhrWx+RW9mYWGyeWsZpQvZbwyt38juQRBLnuLeEh/P1Loi4d0s9SpHy h0WA== X-Forwarded-Encrypted: i=1; AJvYcCWYmTKqhWmXLoBWbw13bEF727GBz89hl4m1mlSmw3PsfAn14ebIQxMN3+hyEJdS0/anMDSM5jkleZNyCUpu@lists.postgresql.org X-Gm-Message-State: AOJu0YyuYTVDx7gtlMicsevih9ruQrTmqcJBZFwVDkF/svdy/glhsaxE p0se2BDHfmFtE1R1te+btuMmOY0SpSh+SxH2NRahUv6aBeFmKAZ8to6r X-Gm-Gg: AY/fxX76ErbB4p3nCMBpEj/X/l0FPJeTBf6GJ18TP6JtcQKcTKc7nQvBPsRtFnEi5Yu 4Eh0OI6K6uAZ4ZZZqM+Yovq/4ZwQg4FvA+WmR1uOG/PLIXTU1WW0tMTrXD/22XpagXN42SGmdW6 SDR8Tpird5eK0e9dthnLSuUy8//G3YLA2OWyLTwGKhAE580wOv6kMOnctEaHFC4d/ZRfxGXGgih KSGmJLuLUL7N+xDsYBalqEIdXqROEFSq1/jPIxSlb3RAl8tkuOhoMQnJVwBAku73ATnFmZnwN3g q3SaP8NtYM+iPJDNSz/L9wsKNTOt7kfXdpuYnovC4/ikfrz0jdwCYMurrum4oQPB2vUBBjbCoC1 JS+Zov19834/U/qU9t0892LtP1fS/+WP405Vfcbu+Rtj3+wtUwt9PL2VL83tNasXZpmS/yoGTbz hQDp6T4yrvIRSqZQ== X-Received: by 2002:a05:6a20:7f8c:b0:361:3bda:7155 with SMTP id adf61e73a8af0-38bed0b5d11mr581725637.7.1768344663726; Tue, 13 Jan 2026 14:51:03 -0800 (PST) Received: from jrouhaud ([115.43.41.38]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a3e3c49037sm211317025ad.36.2026.01.13.14.51.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jan 2026 14:51:03 -0800 (PST) Date: Wed, 14 Jan 2026 06:50:59 +0800 From: Julien Rouhaud To: Sami Imseih Cc: Tom Lane , pgsql-hackers@lists.postgresql.org Subject: Re: Cleaning up PREPARE query strings? Message-ID: References: <928501.1766593260@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Tue, Jan 13, 2026 at 02:24:51PM -0600, Sami Imseih wrote: > I was looking a bit more here, and I found that this patch breaks if > pg_stat_statements is enabled. > > ``` > postgres=# SELECT 'bingo'\; PREPARE q1 AS SELECT 1 AS a \; SELECT 42; > server closed the connection unexpectedly > This probably means the server terminated abnormally > before or while processing the request. > The connection to the server was lost. Attempting reset: Failed. > The connection to the server was lost. Attempting reset: Failed. > !?> > ``` > > This is because the raw statement location is set to 0 with the patch which > breaks generate_nromalized_query when trying to deal with a multi command > statement. So, I don't think the way v1 is doing things will actually work. That's very strange. I'm pretty sure that I tried since the earlier approach I mentioned using doing it in CreateCachedPlan() had that exact problem. Also, src/test/recovery/t/027_stream_regress.pl does run the full regression tests with pg_stat_statements enabled, and it doesn't fail. I'm not sure what is different in your case.