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 1iBP1i-0007pO-NV for pgsql-hackers@arkaria.postgresql.org; Fri, 20 Sep 2019 19:57:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iBP1f-0006Nx-KI for pgsql-hackers@arkaria.postgresql.org; Fri, 20 Sep 2019 19:57:07 +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 1iBP1f-0006Ng-6T for pgsql-hackers@lists.postgresql.org; Fri, 20 Sep 2019 19:57:07 +0000 Received: from mail-qk1-x744.google.com ([2607:f8b0:4864:20::744]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iBP1a-0002Yl-PL for pgsql-hackers@postgresql.org; Fri, 20 Sep 2019 19:57:06 +0000 Received: by mail-qk1-x744.google.com with SMTP id q203so8565179qke.1 for ; Fri, 20 Sep 2019 12:57:02 -0700 (PDT) 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=rGitT0Ii9O4AYt9A3Fe2q+FADSpyjoN++2wc8cfjUjQ=; b=V92R55V66DNvaPRQT70zDrXIu+gT99vCjR2xmN2AN3BNElO+knRWhcmLk1pq3XmeGk idUCDt9Rla4twXp6Gg6d7OKLpMyNkrzsf8dkkyaxGS16hidol3qbqSsz+X8ojMVUjsMh K8l+5c705hlqm6pzmsGScjt+jd/b15mFLiq520pZFRZ7uf8h38DLAgrl4+X3cPhiMBCb hH4jFrXpHEw/GlCNg3GrV2ElrPhn28y01kFTyTPys+k/pfWzYASiFr634fXtNdsA3U54 rD2crMaxh9kzopzdDh8z+wTjb94xgXEumxOOzlYYDLEGt6C/FOfUqZLGFB/78aovrIY1 ICvQ== 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=rGitT0Ii9O4AYt9A3Fe2q+FADSpyjoN++2wc8cfjUjQ=; b=WKOPer435hrlQAwmRdCFckdZ7+HnPshSGjuyXTgYLREiM/gAt68A5MNC5c+4EOfu5K OGks2YRy7xHjVGyVhS8PPxoI64hMC1KWTut0uyMPi+YU8fx57eACph8SaNLU2cJm8hEO rB1kBiMrqbKETkti4ypWE2WZX4AE6scZNkmeG+Z5bSrjjMJ5MP86yN04VTdAsPIKIXgM efwxUnM3flHu1a0ovv78MPo5sidqdrXnosOukcY3UQ3SHH0oriQfF+IQsiVgnrETat4V +bl05ltTAsOI1wxEpHFUgWPrf6TLK9fTGCkwdIOwh2YT7vCPtce/onZp827kmOogLkEx JuAg== X-Gm-Message-State: APjAAAW5QOOzb9ksISmXGdYptoIZ2ve7dnBwXWoWnRPsSmTslJQsd/R6 Np2LenFXLFEF5RkoDwhR5J0f0g== X-Google-Smtp-Source: APXvYqyl/MuU+xj9V/8EGzWI7Bc4otnzjho/gSnkFHPWTgFlL6YjX4wcPTQqAexzaj1Sss/WSSaevA== X-Received: by 2002:ae9:ef4c:: with SMTP id d73mr5416090qkg.57.1569009420674; Fri, 20 Sep 2019 12:57:00 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([179.57.113.12]) by smtp.gmail.com with ESMTPSA id f10sm1173391qth.40.2019.09.20.12.56.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Sep 2019 12:57:00 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 86B521207A3; Fri, 20 Sep 2019 16:56:57 -0300 (-03) Date: Fri, 20 Sep 2019 16:56:57 -0300 From: Alvaro Herrera To: Andres Freund Cc: Alexey Bashtanov , Peter Eisentraut , PostgreSQL Hackers Subject: Re: log bind parameter values on error Message-ID: <20190920195657.GA20546@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190920174627.qmaditduxlrrzb5l@alap3.anarazel.de> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, thanks for looking. On 2019-Sep-20, Andres Freund wrote: > On 2019-09-18 17:58:53 -0300, Alvaro Herrera wrote: > > + > > + log_parameters_on_error (boolean) > > + > > + log_parameters_on_error configuration parameter > > + > > + > > + > > + > > + Controls whether the statement is logged with bind parameter values. > > Trailing whitespace. > > I find the "the statement" formulation a bit odd, but can't quite put my > finger on why. Yeah, I think that wording is pretty confusing. I would use "Controls whether bind parameters are logged when a statement is logged." > > +/* > > + * The top-level portal that the client is immediately working with: > > + * creating, binding, executing, or all at one using simple protocol > > + */ > > +Portal current_top_portal = NULL; > > + > > This strikes me as decidedly not nice. For one this means that we'll not > be able to use this infrastructure for binds that are done serverside, > e.g. as part of plpgsql. I'm basically inclined to think that > integrating this at the postges.c level is the wrong thing. [...] > It seems to me that this would really need to be tracked inside the > portal infrastructure. I think that's how this was done at first, then Peter E drove him away from that into the current design. > It also adds new error handling complexity, which is already quite > substantial. And spreads knowledge of portals to elog.c, which imo > shouldn't have to know about them. Makes sense. > > + appendStringInfoCharMacro(¶m_str, '\''); > > + for (p = pstring; *p; p++) > > + { > > + if (*p == '\'') /* double single quotes */ > > + appendStringInfoCharMacro(¶m_str, *p); > > + appendStringInfoCharMacro(¶m_str, *p); > > + } > > + appendStringInfoCharMacro(¶m_str, '\''); > > I know this is old code, but: This is really inefficient. Will cause a > lot of unnecessary memory-reallocations for large text outputs, because > we don't immediately grow to at least close to the required size. Agreed, but we can't blame a patch because it moves around some old crufty code. If Alexey wants to include another patch to change this to a better formulation, I'm happy to push that before or after his main patch. And if he doesn't want to, that's fine with me too. (Is doing a strlen first to enlarge the stringinfo an overall better approach?) (I wonder if it would make sense to strchr each ' and memcpy the intervening bytes ... if only that didn't break the SI abstraction completely ...) -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services