pg-clone-schema
pg-clone-schema copied to clipboard
Owner with special characters
Issue: Cloning a schema from an owner with special characters causes the clone_schema to fail.
Description: Some statements are executed without quotation marks around the owner.
I quoted the owner at different positions. See diff files for changes that worked for me. diff_clone_schema.sql.txt
Steps to reproduce
-
Have a database that belongs to an owner with special characters e.g. "tu-user". Schema, tables, ... belong to that same owner.
-
Execute the original code snippet.
-
Observe the error due to unescaped special characters.
Diagnostics: line=PL/pgSQL function clone_schema(text,text,cloneparms[]) line 312 at EXECUTE. 42601. syntax error at or near "-"
Proposed change: Add double quotes around the owner in all statements.
Benefits: This change will prevent errors caused by special characters in the owner name.
Thanks a lot!
@gunnareilers , Sorry it took so long to get to this. I made your suggested changes. Thanks for making it easy for me. Get the latest and let me know.
Assuming its working correctlyl now. Closing this since no response in months.
Hi @MichaelDBA! Thanks for solving this issue. Sorry, I wasn't able to test it sooner. Unfortunateley there is still one error that I could fix by editing line 1298: lastsql = 'CREATE SCHEMA ' || quote_ident(dest_schema) || ' AUTHORIZATION ' || quote_ident(buffer);