Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ifXjr-00030v-90 for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Dec 2019 23:19:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ifXjp-0007dK-Dd for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Dec 2019 23:19:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ifXjo-0007dC-UH for pgsql-hackers@lists.postgresql.org; Thu, 12 Dec 2019 23:19:17 +0000 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ifXjh-0003Gv-EI for pgsql-hackers@postgresql.org; Thu, 12 Dec 2019 23:19:16 +0000 Received: by mail-pg1-x542.google.com with SMTP id b9so404805pgk.12 for ; Thu, 12 Dec 2019 15:19:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=oJ44S1V2ZkbG9aIR80GnE8DXsh5u2mn9JHboJ2lpHSQ=; b=jyCBbHWmGQUMW9C0WjN7wkFowKioa6lq1eCoVOYBw1QOmd7jMZzUC18LWuVNeX+rFd /9XalM0WVifOzsoueP4OI2MiNnnG4piNXyBV3vYcOol1VBViAacdz8eB8nMWR4uxtYtc VR8gZWAZe285p/LrQoMSjS4OXD4l3iqRMO8mPUKofHlc5xNvENEAVP2/e9EreNGGLz66 gF98lQtbEnKFuMd+DOoI9RXnTAF0/Umi091Ty0LMgyWVgp5kQY+wfd0olZlz0Zn6zOn+ M68rnDW1HveOK8XFgUlwDe5ScV7j8I4r1WTdWO57dyRuZF/+Xh74DTLHttPV3NA6zPLj 2cvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=oJ44S1V2ZkbG9aIR80GnE8DXsh5u2mn9JHboJ2lpHSQ=; b=ef/AYBTcmztGMaP/Mj2MxgVF2ZtlgNtxNw/ZQfnyuMwXhNnQdCm0NIg0k0j8yQKrBg 7dn10q4aLDelFGO3LlXUz+/0fdSBZsFGwepJvy/0Xa7u3BAgcBwQN7ClrNZ5ICUcckf1 b3DDovfRQVm7Ct5zgH0I5K+/I5IF1D2qxKKi2+dA5vBuewf40PdXpZaSqgJvnrLhHsbA oF044/jtJUNOplzFvaXzVccq/mckjvi6WhSkDoMbtlft2tzA2bwneQMywcxWr7jUMuwq KyWnD7Bm8nDrkX68GgbHhcaBsRLtlhRWcMDc4+jdnitCPCCp+A1rdw9JrXZJPzER5xgX VxLg== X-Gm-Message-State: APjAAAX/pzHCz0TUWGzbt30DJxrBCHtFS0kTyA8YWHWyP2u5VNjfsD/x 3fFi+5xmX6gHhG1huvvyW/ZLdA== X-Google-Smtp-Source: APXvYqwXAezBTloqacJLyEPePNFvnLoR6DHkGIiOkBg888dohmD1nPcefk/H1sybTAe3pQ6MLzZo1Q== X-Received: by 2002:aa7:8299:: with SMTP id s25mr10244467pfm.261.1576192746916; Thu, 12 Dec 2019 15:19:06 -0800 (PST) Received: from nimloth.alvh.no-ip.org ([190.121.29.3]) by smtp.gmail.com with ESMTPSA id hg11sm6959507pjb.14.2019.12.12.15.19.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Dec 2019 15:19:04 -0800 (PST) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id AF7BE30090B; Thu, 12 Dec 2019 20:19:01 -0300 (-03) Date: Thu, 12 Dec 2019 20:19:01 -0300 From: Alvaro Herrera To: Andres Freund Cc: Tom Lane , Alexey Bashtanov , Peter Eisentraut , PostgreSQL Hackers Subject: Re: log bind parameter values on error Message-ID: <20191212231901.GA24177@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20191212223252.pphhrzusu2rxmm3c@alap3.anarazel.de> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hello On 2019-Dec-12, Andres Freund wrote: > I see that you pushed this patch. Yeah, a version of it -- significantly different from what Alexey submitted last. > I'm unfortunately unhappy with the > approach taken. As previously said, handling a lot of this from exec_* > is a mistake in my opinion. Pretty much the same problem exists for > parametrized query execution from other contexts, e.g. for queries > executed inside plpgsql. By putting the responsibility to manage error > contexts etc from with exec_*, we'd need to add a copy of that to pretty > much every place executing queries. This should all be in the portal > code, with an optimization for computing the parameter values from > strings inside postgres.c, when the input is text. Hmm. I think there are two pieces of interest for this feature. One saves a text version of the params; the other is setting the error context that reports them. I agree that possibly it would work to have PortalStart be in charge of the former. However, AFAICS the error context must be set up in each place that's executing the query; I don't think it would work to try to hack it in SPI_cursor_open_internal, for example which is what plpgsql uses; rather it has to be in plpgsql/pl_exec.c itself. (For example, you cannot even put it directly in exec_dynquery_with_params -- it has to be in the callers of that routine, and surround all code until after exec_for_query.) I think the current state of affairs is already a good improvement over what was there before. Can it be improved? Sure. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services