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 1ieQEO-00022c-Tk for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Dec 2019 21:06:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ieQEN-0000zU-K6 for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Dec 2019 21:06:11 +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 1ieQEN-0000ys-4m for pgsql-hackers@lists.postgresql.org; Mon, 09 Dec 2019 21:06:11 +0000 Received: from mail-vs1-xe44.google.com ([2607:f8b0:4864:20::e44]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ieQEG-000768-RH for pgsql-hackers@postgresql.org; Mon, 09 Dec 2019 21:06:09 +0000 Received: by mail-vs1-xe44.google.com with SMTP id t12so11399713vso.13 for ; Mon, 09 Dec 2019 13:06:04 -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=JDQ9280C9nZnjzkyFnho5sX6QRafPVWqahQxFTtusmM=; b=gIjs53rpFOR3xU5hnGM2RGLUtu0WVHh9BKGfYYhNuEoBNC2NLG+vZ6Pkl2ahxiPCBH 4ZIhgapQo0YCG+9J7GVXClMoTkTUVbj0coERP1L3VvQoJsk6RwtK+yyFQgj/kfTCySJp kA+9oyqAx45QBrYjqXL7kG2/+ML/baFcu5O4+knloDobY2UJAOXsKj9g2D/llhD3PWF4 JwGtQsKGxG4+OmOEp0MYeBu1ysAmVDl7wOmCC1rjtKSJMdi/3X756M1PNczZIdkMBlqs RRLT9FT+l74101zOKBc6OjF/jwB717mCVyOSoZ8OStxEL2Bb7WiOlW2yEuMLU8cYD+tZ LyHg== 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=JDQ9280C9nZnjzkyFnho5sX6QRafPVWqahQxFTtusmM=; b=poKdNt6VMMEY+iippS0brSLVQLTszbTVaDVwsoxthiC751/qmaHqRbq/bdGk9zejdW gG30h8kO3tSLOqKnQVtpC8BM259eLFgh8PU0q7+8pstE0EGzlkDrsp5d/PJCJ2J3FzaS tEzVXvMFJEYVmm0DVkGkPGC5wfMI3vti2c8U2E1LDP8SW7acdZP8MkgCRLTmBW+2NMd6 3hkfJBitdy3qPUK8VMA+Tk/m7QWZm12Tw+3Fzvup1jPPzBL3voWkyEHuQtUBGe09Zz4L H1gd5iHRQOfp1EBNNv75Rc10H/nJKgGwSGQmh5PxEtJTXcUstRc9220YAdzG+pb06kYp vGyg== X-Gm-Message-State: APjAAAUDAbEPnz432sxg4v0HyXGmNYRaUmsbC3eiC1p2fA1yoCLBZzWy CsUGV+u50mzNgY1mcrWzTgVw/Q== X-Google-Smtp-Source: APXvYqzEY32tmPoolb2QPjOcEgBbT7IDWGYYojJ25+gnd/CWj8zFTQ8eAMB3PLpT0wTTdtguQ9CDjQ== X-Received: by 2002:a67:e3c8:: with SMTP id k8mr837275vsm.121.1575925563063; Mon, 09 Dec 2019 13:06:03 -0800 (PST) Received: from nimloth.alvh.no-ip.org ([190.121.29.3]) by smtp.gmail.com with ESMTPSA id s124sm790338vkb.42.2019.12.09.13.06.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2019 13:06:02 -0800 (PST) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id C3FEA30091E; Mon, 9 Dec 2019 18:05:58 -0300 (-03) Date: Mon, 9 Dec 2019 18:05:58 -0300 From: Alvaro Herrera To: Tom Lane Cc: Andres Freund , Alexey Bashtanov , Peter Eisentraut , PostgreSQL Hackers Subject: Re: log bind parameter values on error Message-ID: <20191209210558.GA29684@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <8464.1575924424@sss.pgh.pa.us> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2019-Dec-09, Tom Lane wrote: > Alvaro Herrera writes: > > Also: > > * v18 and v19 now alwys do a "strlen(s)", i.e. they scan the whole input > > string -- pointless when maxlen is given. We could avoid that for > > very large input strings by doing strnlen(maxlen + MAX_MULTIBYTE_CHAR_LEN) > > so that we capture our input string plus one additional multibyte > > char. > > BTW, as far as that goes, it seems to me this patch is already suffering > from a lot of premature micro-optimization. Is there even any evidence > to justify that complicated chunk-at-a-time copying strategy, rather than > doing quote-doubling the same way we do it everywhere else? The fact that > that effectively scans the input string twice means that it's not an > ironclad win compared to the naive way, and it seems like it could lose > significantly for a case with lots of quote marks. Moreover, for the > lengths of strings I expect we're mostly dealing with here, it would be > impossible to measure any savings even assuming there is some. If I were > the committer I think I'd just flush that and do it the same way as we > do it in existing code. It's been us committers (Andres and I) that have derailed this patch with some apparently overcomplicated logic. There was nothing of that stuff in the original. See Andres review comments https://postgr.es/m/20190920203905.xkv5udsd5dxfs6tr@alap3.anarazel.de There's also a comment nearby about growing the stringinfo to a reasonable guess of the final size, rather than letting it grow normally, to avoid multiple reallocs. That's why we had all that stuff there. He has looked at execution profiles much more than I have, so I take his word from it. The stuff about truncating to N chars was of my own devising. If we don't want truncation in log_parameters_on_error either, we could do away with the stringinfo changes altogether. (I stand by my opinion that we should truncate, but if there are contrary votes I'm happy to stand down and just get the suggested feature pushed.) -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services