Re: Information schema sql_identifier

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Information schema sql_identifier
Дата
Msg-id 669319.1608683962@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Information schema sql_identifier  (Adrian Klaver <adrian.klaver@aklaver.com>)
Ответы Re: Information schema sql_identifier
Список pgsql-general
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



В списке pgsql-general по дате отправления:

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: Information schema sql_identifier
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: Information schema sql_identifier