From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Michel Helms <michel@togetherdb.com>
Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: Re: pg_table_size errors "invalid name syntax" for table names containing spaces
Date: Thu, 10 Jun 2021 09:43:37 -0400
Message-ID: <1558160.1623332617@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwb5rTHJ6fcLo8d1jWs3-6=bZ7+mg0U7Z_xJCHTU-cyNEw@mail.gmail.com>
References: <CAGJ6MEz=FRwezJSGf8c9YbV7-OTScYTQrdx=Y5OcLwWb9WNdFg@mail.gmail.com>
<CAKFQuwb5rTHJ6fcLo8d1jWs3-6=bZ7+mg0U7Z_xJCHTU-cyNEw@mail.gmail.com>
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Thursday, June 10, 2021, Michel Helms <michel@togetherdb.com> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, david.g.johnston@gmail.com, michel@togetherdb.com, pgsql-bugs@lists.postgresql.org
Subject: Re: pg_table_size errors "invalid name syntax" for table names containing spaces
In-Reply-To: <1558160.1623332617@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox