pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedpg_table_size errors "invalid name syntax" for table names containing spaces
4+ messages / 3 participants
[nested] [flat]
* pg_table_size errors "invalid name syntax" for table names containing spaces
@ 2021-06-10 08:57 Michel Helms <michel@togetherdb.com>
2021-06-10 12:25 ` Re: pg_table_size errors "invalid name syntax" for table names containing spaces David G. Johnston <david.g.johnston@gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: Michel Helms @ 2021-06-10 08:57 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org
Hi
Sorry I am not used to mailing lists so please excuse me if I am not doing
this correctly.
Also I am operating on PostgreSQL 13.2, so not the newest version, but I
have no way to upgrade right now or to test on the most recent version and
it should be really easy to test for anyone who has the recent version
running.
Without further ado, this fails for me and I think it shouldn't:
CREATE TABLE "wei rd" (id SERIAL);
SELECT pg_table_size('wei rd');
So just creating a table containing spaces, the pg_table_size, also
pg_total_relation_size and maybe other administrative functions fail with
error message "invalid name syntax".
Thanks
Michel from TogetherDB
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: pg_table_size errors "invalid name syntax" for table names containing spaces
2021-06-10 08:57 pg_table_size errors "invalid name syntax" for table names containing spaces Michel Helms <michel@togetherdb.com>
@ 2021-06-10 12:25 ` David G. Johnston <david.g.johnston@gmail.com>
2021-06-10 13:43 ` Re: pg_table_size errors "invalid name syntax" for table names containing spaces Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 4+ messages in thread
From: David G. Johnston @ 2021-06-10 12:25 UTC (permalink / raw)
To: Michel Helms <michel@togetherdb.com>; +Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
On Thursday, June 10, 2021, Michel Helms <michel@togetherdb.com> wrote:
>
> CREATE TABLE "wei rd" (id SERIAL);
> SELECT pg_table_size('wei rd');
>
> So just creating a table containing spaces, the pg_table_size, also
> pg_total_relation_size and maybe other administrative functions fail with
> error message "invalid name syntax".
>
You still have to double-quote the name even if its being passed around in
a string literal.
David J.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: pg_table_size errors "invalid name syntax" for table names containing spaces
2021-06-10 08:57 pg_table_size errors "invalid name syntax" for table names containing spaces Michel Helms <michel@togetherdb.com>
2021-06-10 12:25 ` Re: pg_table_size errors "invalid name syntax" for table names containing spaces David G. Johnston <david.g.johnston@gmail.com>
@ 2021-06-10 13:43 ` Tom Lane <tgl@sss.pgh.pa.us>
2021-06-11 06:15 ` Re: pg_table_size errors "invalid name syntax" for table names containing spaces Michel Helms <michel@togetherdb.com>
0 siblings, 1 reply; 4+ messages in thread
From: Tom Lane @ 2021-06-10 13:43 UTC (permalink / raw)
To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: Michel Helms <michel@togetherdb.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
"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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: pg_table_size errors "invalid name syntax" for table names containing spaces
2021-06-10 08:57 pg_table_size errors "invalid name syntax" for table names containing spaces Michel Helms <michel@togetherdb.com>
2021-06-10 12:25 ` Re: pg_table_size errors "invalid name syntax" for table names containing spaces David G. Johnston <david.g.johnston@gmail.com>
2021-06-10 13:43 ` Re: pg_table_size errors "invalid name syntax" for table names containing spaces Tom Lane <tgl@sss.pgh.pa.us>
@ 2021-06-11 06:15 ` Michel Helms <michel@togetherdb.com>
0 siblings, 0 replies; 4+ messages in thread
From: Michel Helms @ 2021-06-11 06:15 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: David G. Johnston <david.g.johnston@gmail.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Ahh okay, thank you both for the clarification!
On Thu, Jun 10, 2021 at 8:43 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> "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
>
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2021-06-11 06:15 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-06-10 08:57 pg_table_size errors "invalid name syntax" for table names containing spaces Michel Helms <michel@togetherdb.com>
2021-06-10 12:25 ` David G. Johnston <david.g.johnston@gmail.com>
2021-06-10 13:43 ` Tom Lane <tgl@sss.pgh.pa.us>
2021-06-11 06:15 ` Michel Helms <michel@togetherdb.com>
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