Re: pg_table_size errors "invalid name syntax" for table names containing spaces

From: Michel Helms <michel(at)togetherdb(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_table_size errors "invalid name syntax" for table names containing spaces
Date: 2021-06-11 06:15:57
Message-ID: CAGJ6MEz0JRcEqF5j0kM__QOaJfpE0zC=k7XrZhCR72UCPKRq6Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Ahh okay, thank you both for the clarification!

On Thu, Jun 10, 2021 at 8:43 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> "David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
> > On Thursday, June 10, 2021, Michel Helms <michel(at)togetherdb(dot)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
>

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Paquier 2021-06-11 06:26:28 Re: BUG #17055: Logical replication worker crashes when applying update of row that dose not exist in target partiti
Previous Message Amit Langote 2021-06-11 05:56:58 Re: BUG #17055: Logical replication worker crashes when applying update of row that dose not exist in target partiti