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 1j0p4M-0001os-Gy for pgsql-docs@arkaria.postgresql.org; Sun, 09 Feb 2020 16:04:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j0p3M-0000lL-Iq for pgsql-docs@arkaria.postgresql.org; Sun, 09 Feb 2020 16:03:24 +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 1j0p3M-0000iq-A4 for pgsql-docs@lists.postgresql.org; Sun, 09 Feb 2020 16:03:24 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j0oqK-0000kS-2N for pgsql-docs@lists.postgresql.org; Sun, 09 Feb 2020 15:49:59 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 019FnoPJ005733; Sun, 9 Feb 2020 10:49:50 -0500 From: Tom Lane To: michael@qedcode.com cc: pgsql-docs@lists.postgresql.org Subject: Re: 9.4. String Functions and Operators page does not document that encode adds line breaks In-reply-to: <158117862544.1089.17282036641192025921@wrigleys.postgresql.org> References: <158117862544.1089.17282036641192025921@wrigleys.postgresql.org> Comments: In-reply-to PG Doc comments form message dated "Sat, 08 Feb 2020 16:17:05 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <5731.1581263390.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Sun, 09 Feb 2020 10:49:50 -0500 Message-ID: <5732.1581263390@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk PG Doc comments form writes: > It took me a long time to discover why a base 64 encoded SHA-512 hash was 89 > characters long instead of the expected 88. The documentation does not > mention that the encode function inserts newlines after 76 characters. > Please make a note of this behavior. That was done a few weeks ago in HEAD: https://www.postgresql.org/docs/devel/functions-binarystring.html The base64 format is that of RFC 2045 Section 6.8. As per the RFC, encoded lines are broken at 76 characters. However instead of the MIME CRLF end-of-line marker, only a newline is used for end-of-line. The decode function ignores carriage-return, newline, space, and tab characters. Otherwise, an error is raised when decode is supplied invalid base64 data — including when trailing padding is incorrect. > By the way, this is a very poor design decision. So far as I can tell, that RFC's requirement for line breaks has not been removed by any later RFC. So you're complaining to the wrong people. regards, tom lane