Обсуждение: BUG #16252: PL/pgSQL dynamic programming not well suited for working with different schemas

Поиск
Список
Период
Сортировка

BUG #16252: PL/pgSQL dynamic programming not well suited for working with different schemas

От
PG Bug reporting form
Дата:
The following bug has been logged on the website:

Bug reference:      16252
Logged by:          Filip Vukovinski
Email address:      filip.vukovinski@net.hr
PostgreSQL version: 12.0
Operating system:   Windows 10 18362
Description:

The %I format specifier for identifiers, does not handle table schema
prefixes.


Re: BUG #16252: PL/pgSQL dynamic programming not well suited forworking with different schemas

От
Pavel Stehule
Дата:


so 8. 2. 2020 v 19:17 odesílatel PG Bug reporting form <noreply@postgresql.org> napsal:
The following bug has been logged on the website:

Bug reference:      16252
Logged by:          Filip Vukovinski
Email address:      filip.vukovinski@net.hr
PostgreSQL version: 12.0
Operating system:   Windows 10 18362
Description:       

The %I format specifier for identifiers, does not handle table schema
prefixes.


sure. It is expected. Nobody can detect if "." inside name means part of name or special symbol.

If you want to handle schema, you should to write some 

format("SELECT * FROM %I.%I", schema_name, table_name);

For identifier separation, you can use "parse_ident" function

postgres=# SELECT parse_ident('a.b.cax."ass.ss"');
┌──────────────────┐
│   parse_ident    │
╞══════════════════╡
│ {a,b,cax,ass.ss} │
└──────────────────┘
(1 row)



Regards

Pavel