From: Tom Lane <tgl@sss.pgh.pa.us>
To: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: Information schema sql_identifier
Date: Tue, 22 Dec 2020 19:39:22 -0500
Message-ID: <669319.1608683962@sss.pgh.pa.us> (raw)
In-Reply-To: <653c81a9-bc2b-e7a6-1ece-eab59f007400@aklaver.com>
References: <653c81a9-bc2b-e7a6-1ece-eab59f007400@aklaver.com>
Adrian Klaver <adrian.klaver@aklaver.com> writes:
> So how does one go about using a table name from
> information_schema.tables in pg_table_size()?
You want something like
select pg_table_size(quote_ident(table_schema)||'.'||quote_ident(table_name))
from information_schema.tables;
I imagine that the failures you got are a consequence of having
some table names that aren't valid unless quoted (ie contain
spaces, funny characters, etc). In a general-purpose query,
you can't ignore the schema name either.
I might be more excited about v12's failure to provide an implicit
cast to regclass if there were any prospect of queries like this
working in a bulletproof way without accounting for schema names
and funny characters. But there isn't, so the query shown in SO
is a house of cards to start with. When you do it right, with
quote_ident() or format(), no special casting is needed.
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, adrian.klaver@aklaver.com
Subject: Re: Information schema sql_identifier
In-Reply-To: <669319.1608683962@sss.pgh.pa.us>
References: <653c81a9-bc2b-e7a6-1ece-eab59f007400@aklaver.com> <669319.1608683962@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