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 1vwUOM-00A373-0F for pgsql-hackers@arkaria.postgresql.org; Sun, 01 Mar 2026 00:10:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vwUOK-00BmfT-2y for pgsql-hackers@arkaria.postgresql.org; Sun, 01 Mar 2026 00:10:36 +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 1vwUOK-00BmfL-1t for pgsql-hackers@lists.postgresql.org; Sun, 01 Mar 2026 00:10:36 +0000 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vwUOH-00000001rPl-3Bus for pgsql-hackers@lists.postgresql.org; Sun, 01 Mar 2026 00:10:35 +0000 Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-3591cc98871so1383269a91.3 for ; Sat, 28 Feb 2026 16:10:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772323834; x=1772928634; 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=LtpMfjzjIqDRZ57vYMW3N7vpH9ItQmDKwuq4McbTTwc=; b=AJAUk31++sIuweSV0SYAiWTb5uXuiPEtzhthliDZK2SyC6h2xhFLIEACGuMDlOb4aJ 2fvC8tYsrCgM9tPC4r7dPCKi7OyOYn+0lPw2fEA3NTSNG+2772YTCgitTldTkxZqM047 0DU74jc/NDvEBfmqERmpgM3b3WolNTjMxJ5q1IwtOuz94jlIp3ZJ8PtnEtGofj45h6bw zCq1Zg8oVXfkx/u2MW6A7HxpeXJMbQtCAuwHaxDqs4o+J8+1a8JASFVviP4oBb57y9E7 H7bkWXrU9GtugGGjS/FDahV531keL/uGilyziUZZNASSL81GNg5JlZm6Mnvubhf64bFx F+fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772323834; x=1772928634; 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=LtpMfjzjIqDRZ57vYMW3N7vpH9ItQmDKwuq4McbTTwc=; b=JtI8iRzbnR5dSrx9ehbwp4pXr9ReDiPHCduPT0A5s8yxcV2ThhIe1Z+JvZfjcsiv/j FD543Wis8eBRflb285jLHgMpC+Lcj2fACVgB3BTDdd+xflBPgUVdiJ7eRiAbwDQk16OC cyVYeRuFT128IMUJ5QV6opVJjHTZ6svtBGKKywVnA77snlk7XuCa38LEifTpEfOGYmcb 5HiHELtsxvNCRYft9+1Adv8FKemnBIya2apI6nNii23KWYn2avQBpIo5f1st7yOQuc0x 9kVhpI0KfK+6+Wutz8e1SBslUo/bLSuSEpBKsxo2dVCxuYdIR1L2uU5GpsbV7ZQ88bNV GOZw== X-Forwarded-Encrypted: i=1; AJvYcCXHDbwjuQQ47i887wxEkDXyegyAiIZ7/DcCvDXOCdTikJNcR9ObtZs+zzQ5pSn9xK9GCNIAYaz/1iBh2UWK@lists.postgresql.org X-Gm-Message-State: AOJu0YzMRw96WOdgRblXrscxbWTOzsDtPfi/3kRdpRi/jmIgXCa9CLf3 Wnbw0neJBRfsdvfjbf8DkMKtqBj70Bh7OkECsCKZsqYFOs4+ywEWPdsF X-Gm-Gg: ATEYQzxopFguyByiZyczEK0GMOZXX6UiKzz7IO3nDBTZ3HrPBRsCcjQh2SZPc3y3qaQ w/ukrr4AqAzkamGG5MojC756aP2WYpKA1lxa3jr4+frzKKPWsZeBaAixZYXrZvZChlhBzjALwZl xAFQ9/yJI0WL4Lvfeo97XozybslK/7N2qNypQ38d65VVIsAPnhKmragYDRL6ls98yyA1brElHbk NFBret9kYsODKh4Zo6FiNsjOdhWm2OBi6U4Oz31eNgEDWX8uGsSeQPKAmeZGsMvELpYp8ycQgY5 Bm9jeKBzd4GBJitOXxWZ/k5348Z43oJOvI1oW420iuUzIuJnTKZLcVk7ZAp8znPpK11/XUN2TBJ RMjGwSv9rqUu3g65JH6XjJQseHFSH2vzti5RF0yg7AzLtx0MwNySz3swHI2mC0GtMIiW5KQBKwF GfT6qDR1+oBUKroh0= X-Received: by 2002:a17:90b:2e83:b0:359:7a11:256e with SMTP id 98e67ed59e1d1-3597a112760mr2874735a91.19.1772323833897; Sat, 28 Feb 2026 16:10:33 -0800 (PST) Received: from jrouhaud ([115.43.41.38]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-35982fb562bsm1039135a91.1.2026.02.28.16.10.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Feb 2026 16:10:31 -0800 (PST) Date: Sun, 1 Mar 2026 08:10:27 +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: 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 Mon, Jan 26, 2026 at 04:48:59PM -0600, Sami Imseih wrote: > > This was already reported by Tom Lane on his first message, although his > > complaint was about execution time error reporting while this is during > > parse-analysis. However, I think that the exact same approach can be used to > > fixed both, either updating the position of every single element (which no one > > wants) or teaching the executor (and evidently the planstate) about a new > > "query offset" so that parser_errposition and executor_errposition report the > > correct location. > > Maybe this is what you also mean, but I think it should be enough to > just tell Query > about the updated location = 0, and we don't need to touch anything else > ( the raw parestree or the copy of it in plansource ). This will > ensure that the error > tracking is relying on the original raw parsetree, and consumers of the updated > statement query location and lengths are getting the updated values based on > the cleaned up query text that is stored in prepared statements. > > I tested the below with the tests you have in v3 so far and it works. > I also tested > the error position and it looks correct. > > Not sure if I am missing something. It's hard to know what changed exactly as you show the diff against master rather than against the patch, but IIUC the problem will be for execution time error location reporting, as reported before. I think that it will still be wrong, but may now also point to an offset that isn't in the query text. I still haven't been able to hit that code path, so I can't really investigate more. In general I feel like it would be cleaner to have the same handling for a possible "location vs query offset" approach for both pare-analysis and execution, but I'm not opposed to this approach if it gets the feature accepted.