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 1lrKyF-00037B-AV for pgsql-bugs@arkaria.postgresql.org; Thu, 10 Jun 2021 13:43:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lrKyE-0001O4-8Y for pgsql-bugs@arkaria.postgresql.org; Thu, 10 Jun 2021 13:43:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lrKyE-0001Nw-21 for pgsql-bugs@lists.postgresql.org; Thu, 10 Jun 2021 13:43:42 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lrKyC-0002z8-28 for pgsql-bugs@lists.postgresql.org; Thu, 10 Jun 2021 13:43:41 +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 15ADhba71558161; Thu, 10 Jun 2021 09:43:37 -0400 From: Tom Lane To: "David G. Johnston" cc: Michel Helms , "pgsql-bugs@lists.postgresql.org" Subject: Re: pg_table_size errors "invalid name syntax" for table names containing spaces In-reply-to: References: Comments: In-reply-to "David G. Johnston" message dated "Thu, 10 Jun 2021 05:25:04 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1558159.1623332617.1@sss.pgh.pa.us> Date: Thu, 10 Jun 2021 09:43:37 -0400 Message-ID: <1558160.1623332617@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "David G. Johnston" writes: > On Thursday, June 10, 2021, Michel Helms wrote: >> CREATE TABLE "wei rd" (id SERIAL); >> SELECT pg_table_size('wei rd'); > You still have to double-quote the name even if its being passed around in > a string literal. Yeah. The reason for this is that you're also allowed to write qualified table names: SELECT pg_table_size('myschema.mytable'); That would seem to introduce an ambiguity: is the dot a schema separator, or just an ordinary character (in a table name that was presumably written with double quotes originally)? We resolve this by saying that the parsing rules for regclass_in are the same as they are in SQL text, so you have to double-quote anything that is not a plain identifier or needs to be protected against case-folding. Hence, you should write SELECT pg_table_size('"wei rd"'); regards, tom lane