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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

apt.postgresql.org Repository Update
The following bug has been logged on the website:

Bug reference:      16252
Logged by:          Filip Vukovinski
Email address:      [hidden email]
PostgreSQL version: 12.0
Operating system:   Windows 10 18362
Description:        

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

Reply | Threaded
Open this post in threaded view
|

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

Pavel Stehule


so 8. 2. 2020 v 19:17 odesílatel PG Bug reporting form <[hidden email]> napsal:
The following bug has been logged on the website:

Bug reference:      16252
Logged by:          Filip Vukovinski
Email address:      [hidden email]
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