Re: BUG #16991: regclass is not case sensitive causing "relation does not exist" error

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #16991: regclass is not case sensitive causing "relation does not exist" error
Дата
Msg-id 3896142.1620136761@sss.pgh.pa.us
обсуждение исходный текст
Ответ на BUG #16991: regclass is not case sensitive causing "relation does not exist" error  (PG Bug reporting form <noreply@postgresql.org>)
Ответы RE: BUG #16991: regclass is not case sensitive causing "relation does not exist" error  (Federico <cfederico87@gmail.com>)
Список pgsql-bugs
PG Bug reporting form <noreply@postgresql.org> writes:
> Casting the name of an object to regclass using `name_col::regclass` is very
> useful when querying the pg_catalog view to find the relevant information.
> This casting does not work if the name of the object to cast is case
> sensitive when it comes from a column.

This is acting as designed and documented: regclass input conversion acts
the same as the regular SQL parser does, which includes case folding of
unquoted text.  If you have input that should be taken literally, you
can apply quote_ident() to it.

Note that your sample query has a second issue: it takes no account of
schemas, so it'll fail if a view row shows a table that is not in your
search_path.  Actually-robust solutions to this problem require something
like
  (quote_ident(schemaname) || '.' || quote_ident(indexrelname))::regclass
which illustrates why you don't really want regclass to take its input
literally: it needs to be able to interpret schema-qualified names.

            regards, tom lane



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

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: pg_restore - generated column - not populating
Следующее
От: Federico
Дата:
Сообщение: RE: BUG #16991: regclass is not case sensitive causing "relation does not exist" error