From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | cfederico87(at)gmail(dot)com |
Cc: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: BUG #16991: regclass is not case sensitive causing "relation does not exist" error |
Date: | 2021-05-04 13:59:21 |
Message-ID: | 3896142.1620136761@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs pgsql-docs |
PG Bug reporting form <noreply(at)postgresql(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Federico | 2021-05-04 14:29:32 | RE: BUG #16991: regclass is not case sensitive causing "relation does not exist" error |
Previous Message | Peter Eisentraut | 2021-05-04 12:25:58 | Re: pg_restore - generated column - not populating |
From | Date | Subject | |
---|---|---|---|
Next Message | Federico | 2021-05-04 14:29:32 | RE: BUG #16991: regclass is not case sensitive causing "relation does not exist" error |
Previous Message | PG Bug reporting form | 2021-05-04 10:53:56 | BUG #16991: regclass is not case sensitive causing "relation does not exist" error |