While studying the parser, I noticed that we support nchar and the n'' literal. But both concepts are undocumented. That may be intentional because nchar is just an alias for char and because all our string types are multibyte and therefore essentially national character strings.
I was looking through the archive for previous discussions and found: * Thread [1] (about making nchar a distinct type) which noted that docs are missing but nobody proposed a fix. * Thread [2] where Peter Eisentraut suggested leaving nchar undocumented until it's figured out if our implementation matches the standard. What bugs me about the missing docs is that 7081ac46ace added nchar to the intro for table 9.47[3], assuming that the reader already knows about nchar. That's the only instance of nchar in the docs (besides the keyword list). So, I think we should either remove that one nchar instance (because it doesn't add any real value) or document it properly. The attached patch does the latter. [1] https://www.postgresql.org/message-id/B1A7485194DE4FDAB8FA781AFB570079%40maumau [2] https://www.postgresql.org/message-id/1275895438.1849.1.camel%40fsopti579.F-Secure.com [3] https://www.postgresql.org/docs/16/functions-json.html#FUNCTIONS-JSON-CREATION-TABLE -- Erik
>From 314e0ffc1efb854f603e325c13a39ba871aebbf5 Mon Sep 17 00:00:00 2001 From: Erik Wienhold <e...@ewie.name> Date: Sun, 5 May 2024 02:15:53 +0200 Subject: [PATCH] Document nchar data type alias Also mention that we support national character string constants. --- doc/src/sgml/datatype.sgml | 6 +++--- doc/src/sgml/syntax.sgml | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml index 6646820d6a..3063b7e2cb 100644 --- a/doc/src/sgml/datatype.sgml +++ b/doc/src/sgml/datatype.sgml @@ -1234,9 +1234,9 @@ SELECT '52093.89'::money::numeric::float8; <para> The type name <type>varchar</type> is an alias for <type>character - varying</type>, while <type>bpchar</type> (with length specifier) and - <type>char</type> are aliases for <type>character</type>. The - <type>varchar</type> and <type>char</type> aliases are defined in the + varying</type>, while <type>bpchar</type> (with length specifier), + <type>nchar</type>, and <type>char</type> are aliases for <type>character</type>. + The <type>varchar</type> and <type>char</type> aliases are defined in the <acronym>SQL</acronym> standard; <type>bpchar</type> is a <productname>PostgreSQL</productname> extension. </para> diff --git a/doc/src/sgml/syntax.sgml b/doc/src/sgml/syntax.sgml index 4dfbbd0862..6579b2908a 100644 --- a/doc/src/sgml/syntax.sgml +++ b/doc/src/sgml/syntax.sgml @@ -334,6 +334,13 @@ SELECT 'foo' 'bar'; by <acronym>SQL</acronym>; <productname>PostgreSQL</productname> is following the standard.) </para> + + <para> + <productname>PostgreSQL</productname> also accepts national character + string constants (<literal>n'sample'</literal>) for compliance with + the <acronym>SQL</acronym> standard. Those are essentially the same as + regular string constants. + </para> </sect3> <sect3 id="sql-syntax-strings-escape"> -- 2.45.0