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 1icUrR-0005y2-Tj for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Dec 2019 13:38:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1icUrQ-00080A-Jn for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Dec 2019 13:38:32 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1icUrQ-000803-3T for pgsql-hackers@lists.postgresql.org; Wed, 04 Dec 2019 13:38:32 +0000 Received: from mail-qt1-x841.google.com ([2607:f8b0:4864:20::841]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1icUrN-0000GC-Ci for pgsql-hackers@postgresql.org; Wed, 04 Dec 2019 13:38:30 +0000 Received: by mail-qt1-x841.google.com with SMTP id d5so7785873qto.0 for ; Wed, 04 Dec 2019 05:38:29 -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=JGpTAC5u7d2dEReyqDHCvzmX6oh+dgRcPssj6jAm/xk=; b=ZdM1/w4l+s7CNNa4jnXJqqikhfNjdbiUJSPDYPMfebxVIPvcN1hCgKPTPIe7jNcvpA PVUKzDOAGIBKEiQ3i6q5bgsqUkSTxhKUZLU+Ck67wTHjgpXSweegLkv/4SlvVt+nVulK lAB5BoMbVAid8WoUa/cBBwRVly6MFiazOetEv9UV2O9L/12b4FBDIAZagvWWYY01Dufo +/b62pRjhR0Zx0hZrx6LtAHnamqIN9ue3tlYjRm/Y/f/ufxPRwrpPC97ma80rzUSMPgV 8Hm84FtBSoYsS+81Qe1eVr4VUasG03nP12WrrAR5rOfI4W1SdUEh4ziEjdir+w3teV3F ikXQ== 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=JGpTAC5u7d2dEReyqDHCvzmX6oh+dgRcPssj6jAm/xk=; b=LR6GPPWzYVyxCtFbjEopONySpvov2H2xlXY24QPqVcv6Kl8haxcK6mvKKAsDVayPn9 +1Wz1+c2HhAyx4Y1T/darMy9LJ3UuY7sEvvl4UotTosEL1XgqD4ZrcCjzsrRDslwwZ+H cFaxc4UJlU6NlbnMxzN3MxTDJ4gjBYhpQv8tTaJktO9U754/oQlg01TZuuei/Fxs/jXq anZuay23vP9yxJLnLPQLfmMjKj/AaIyNEXvyNyk7SGqby1bwJbRE9Di6pdMGhqvtvfaU W5q3fx/LRMP+wY4s2u+xz3NZaDJgMcFCuUoOAkbSawFVLSim5/KaOPoN8MKyNBlf+S05 9v+w== X-Gm-Message-State: APjAAAVFm45VsmYN1ohSHi+u5LvWOhOz2RzPm3U1wu07qHLs0OEl2+7X PiGsaJ3J6wMxXEdMY5aur9k3hg== X-Google-Smtp-Source: APXvYqxXzBGPn4wMnBxJvXT9SB5oQRXjRObwIyN7XEkLlKbcAn9pWCoaEYlaz8upqYPAcPOCDXJK5A== X-Received: by 2002:ac8:45d0:: with SMTP id e16mr2612112qto.385.1575466708334; Wed, 04 Dec 2019 05:38:28 -0800 (PST) Received: from nimloth.alvh.no-ip.org ([190.217.182.8]) by smtp.gmail.com with ESMTPSA id x8sm3624005qki.60.2019.12.04.05.38.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2019 05:38:27 -0800 (PST) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 0A1EF300804; Wed, 4 Dec 2019 10:38:18 -0300 (-03) Date: Wed, 4 Dec 2019 10:38:17 -0300 From: Alvaro Herrera To: Andres Freund Cc: Alexey Bashtanov , Peter Eisentraut , PostgreSQL Hackers Subject: Re: log bind parameter values on error Message-ID: <20191204133817.GA27976@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20191203211739.GA12872@alvherre.pgsql> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > (Maybe do strnlen(maxlen), then count strnlen(1) starting at that point > -- so if that returns >=1, print the "..."?) So I found that I can make the code more reasonable with this simple coding, if (maxlen > 0) { s = pnstrdup(s, maxlen); ellipsis = strnlen(s, maxlen + 1) > maxlen; /* enlarge while we can do so cheaply */ enlargeStringInfo(str, maxlen); } ... but the problem is that we now compile stringinfo.c for frontend environments also, and there's no pnstrdup() in frontends. And to introduce it, we'd need a configure check (because GNU libc has it) and a src/port naive implementation and a fe_memutils.c addition. Sigh. Still, it's not that much code, so I'll just go do that and open a separate thread for it. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services