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 1ovnfi-0007Az-Ef for pgsql-bugs@arkaria.postgresql.org; Thu, 17 Nov 2022 22:47:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ovnfg-0004A3-T2 for pgsql-bugs@arkaria.postgresql.org; Thu, 17 Nov 2022 22:47:48 +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 1ovnff-00045U-QF for pgsql-bugs@lists.postgresql.org; Thu, 17 Nov 2022 22:47:48 +0000 Received: from ook.raf.org ([139.99.156.21]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ovnfc-00031V-Qp for pgsql-bugs@lists.postgresql.org; Thu, 17 Nov 2022 22:47:46 +0000 Received: from localhost (localhost [127.0.0.1]) by ook.raf.org (Postfix) with ESMTP id B4E4D5DE15 for ; Fri, 18 Nov 2022 09:47:34 +1100 (AEDT) X-Virus-Scanned: Debian amavisd-new at ook.raf.org Received: from ook.raf.org ([127.0.0.1]) by localhost (ook.raf.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dihGtAHSsBL6 for ; Fri, 18 Nov 2022 09:47:33 +1100 (AEDT) Received: by ook.raf.org (Postfix, from userid 1001) id D3DFA5DEC9; Fri, 18 Nov 2022 09:47:32 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raf.org; s=001; t=1668725253; bh=M4ANTY2GHu3fbAE6EPhHE6+G0EKoSC24z/IC63sbKbU=; h=Date:From:To:Subject:References:In-Reply-To:From; b=sc2ax/EZSXn1t9ZD8kjV7jNCbF8GEeU5PMhHn0suWpXSmYpPS76VVM8daOlgNrapY 2W1dD/NHeH53OgGKke0DZrUomqjWEg6fWd9xl5H75hxMWc6CfQQl40mqn40jC9JnYS vuBrWgIPWXwWg9lvBMd3XnpKSiZZNxdgMB/4k+yWjlT/2X7Z57DbXBh+OVueCy2h7T 4aY9aYUMkavCpyCT7bZxu9yg6bM7ixvxcnY0j7stq/QJkxeW09zA/NS4tKJmX//y7I 31QhjlcWfmpeiGfhHkTOda1SSEy6hTqzlsCeRDagWGhxN2sMRtl2pPGrE/eoOB2yfy iT46HlB+sbjzQ== Date: Fri, 18 Nov 2022 09:47:32 +1100 From: raf To: pgsql-bugs@lists.postgresql.org Subject: Re: Inaccurate documentation about identifiers Message-ID: References: <1954348.1668715270@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1954348.1668715270@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Nov 17, 2022 at 03:01:10PM -0500, Tom Lane wrote: > Jeff Davis writes: > > On Wed, 2022-11-16 at 08:36 -0500, Brennan Vincent wrote: > >> However, it seems that all non-ASCII characters are considered > >> "letters" > > > You're correct: it seems to allow any byte with the high bit set; > > including, for example, a zero-width space. > > Yes, see scan.l: > > ident_start [A-Za-z\200-\377_] > ident_cont [A-Za-z\200-\377_0-9\$] > > identifier {ident_start}{ident_cont}* > > > I don't think we want to change the documentation here, because that > > would amount to a promise that we support such identifiers forever. > > I also don't think we want to change the code, because it opens up > > several problems and I'm not sure it's worth trying to solve them. > > Right. IIRC, the SQL spec would have us allow only things that actually > are letters per Unicode or other relevant spec, but (1) that's rather > encoding-dependent and (2) the hit to parsing speed would likely be > non-negligible. Still, we might do it someday if someone can find > a way around those concerns. (Accepting whitespace, in particular, > is Not Great.) I think benign neglect in the docs is the best path. > > regards, tom lane I think a lot of programming languages probably only use ASCII for operators and whitespace. I have a domain specific micro language that explicitly treats all 8-bit bytes as "letters" when parsing the names of things as a cheap way to "support" ASCII-compatible encodings like UTF-8 and ISO-8859-* (but it's useless for UTF-16, GB 18030, Big5, ...). The only way to do it right would be to decode everything. But then you'd probably lose the ability to include emojis in identifiers. I wonder if anyone's doing that in postgresql. :-) Does the SQL spec require accepting *only* real letters as letters, or does it require accepting *at least* real letters as letters. :-) Just a bit of wishful thinking. cheers, raf