Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kmN6d-000347-2n for pgsql-docs@arkaria.postgresql.org; Mon, 07 Dec 2020 20:27:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kmN6b-0004hB-1x for pgsql-docs@arkaria.postgresql.org; Mon, 07 Dec 2020 20:27:33 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kmN6a-0004h3-KU for pgsql-docs@lists.postgresql.org; Mon, 07 Dec 2020 20:27:32 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kmN6Y-0007JC-1W for pgsql-docs@lists.postgresql.org; Mon, 07 Dec 2020 20:27:31 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 0B7KRM9U3153760; Mon, 7 Dec 2020 15:27:22 -0500 From: Tom Lane To: Laurenz Albe cc: bugs-postgresql@antipoul.fr, pgsql-docs@lists.postgresql.org Subject: Re: Mention invalid null byte sequence In-reply-to: <0f0470f6d8c543793d2b71913cb230daea1aef3a.camel@cybertec.at> References: <160720552914.710.16625261471128631268@wrigleys.postgresql.org> <0f0470f6d8c543793d2b71913cb230daea1aef3a.camel@cybertec.at> Comments: In-reply-to Laurenz Albe message dated "Mon, 07 Dec 2020 10:02:43 +0100" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <3153723.1607372795.0@sss.pgh.pa.us> Date: Mon, 07 Dec 2020 15:27:22 -0500 Message-ID: <3153759.1607372842@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3153723.1607372795.1@sss.pgh.pa.us> Laurenz Albe writes: > On Sat, 2020-12-05 at 21:58 +0000, PG Doc comments form wrote: >> The following documentation comment has been logged on the website: >> Page: https://www.postgresql.org/docs/13/datatype-character.html >> Description: >> >> So it should written in the character type that null byte are not accepted, >> it would make like easier to migrate to PostgreSQL :) > +1; how about the attached patch? I had thought that this was already documented, but after digging around I can only find it mentioned in the contexts of saying that literal strings and quoted identifiers can't contain \0. So yeah, we need to improve that. I agree with the submitter that the place one would expect to read about this is in datatype-character.html. So I'd propose the attached. Maybe there's reason to repeat the info in charset.sgml, but it seems like more of a datatype limitation than a character set issue. regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="document-that-you-cant-store-NUL.patch"; charset="us-ascii" Content-ID: <3153723.1607372795.2@sss.pgh.pa.us> Content-Description: document-that-you-cant-store-NUL.patch diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml index 5c8a92e250..9eb19a1c61 100644 --- a/doc/src/sgml/datatype.sgml +++ b/doc/src/sgml/datatype.sgml @@ -1209,6 +1209,14 @@ SELECT '52093.89'::money::numeric::float8; regular expressions. + + The characters that can be stored in any of these data types are + determined by the database character set, which is selected when + the database is created. Regardless of the specific character set, + the character with code zero (sometimes called NUL) cannot be stored. + For more information refer to . + + The storage requirement for a short string (up to 126 bytes) is 1 byte plus the actual string, which includes the space padding in the case of @@ -1246,10 +1254,7 @@ SELECT '52093.89'::money::numeric::float8; Refer to for information about the syntax of string literals, and to - for information about available operators and functions. The - database character set determines the character set used to store - textual values; for more information on character set support, - refer to . + for information about available operators and functions. ------- =_aaaaaaaaaa0--