BUG #16991: regclass is not case sensitive causing "relation does not exist" error
От | PG Bug reporting form |
---|---|
Тема | BUG #16991: regclass is not case sensitive causing "relation does not exist" error |
Дата | |
Msg-id | 16991-bcaeaafa17e0a723@postgresql.org обсуждение исходный текст |
Ответы |
Re: BUG #16991: regclass is not case sensitive causing "relation does not exist" error
|
Список | pgsql-bugs |
The following bug has been logged on the website: Bug reference: 16991 Logged by: Federico Caselli Email address: cfederico87@gmail.com PostgreSQL version: 13.2 Operating system: any Description: Hi, 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. Example using indexes to illustrate: ```sql begin; create table example(id serial, value text); create index "CaseSensitiveIndex" on example (value, id); create index not_case_sensitive on example (id, value); select pg_relation_size(indexrelname::regclass) from pg_stat_all_indexes where indexrelname = 'not_case_sensitive'; select pg_relation_size(indexrelname::regclass) from pg_stat_all_indexes where indexrelname = 'CaseSensitiveIndex'; rollback; ``` In this example the case the first select using the insensitive "not_case_sensitive" is correctly casted to regclass, while the second use using "CaseSensitiveIndex" fails with the error "SQL Error [42P01]: ERROR: relation "casesensitiveindex" does not exist" suggesting that the case is not respected by the regclass casting. While the example makes little sense, since the column "indexrelid" could be used directly, in many queries the oid of an object is not immediately available. Using the "select oid from pg_class where ..." as suggested in the documentation here https://www.postgresql.org/docs/current/datatype-oid.html works, but as mentioned in the documentation is not 100% correct. It think it would be nice if when casting from a column regclass would use the case sensitive form, like it's possible when using the literal name directly, like `select '"CaseSensitiveIndex"'::regclass` Best, Federico
В списке pgsql-bugs по дате отправления: