pg-clone-schema icon indicating copy to clipboard operation
pg-clone-schema copied to clipboard

Owner with special characters

Open gunnareilers opened this issue 1 year ago • 1 comments

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 avatar Jul 04 '24 09:07 gunnareilers

@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.

MichaelDBA avatar Oct 29 '24 21:10 MichaelDBA

Assuming its working correctlyl now. Closing this since no response in months.

MichaelDBA avatar Nov 09 '24 13:11 MichaelDBA

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);

gunnareilers avatar Nov 11 '24 10:11 gunnareilers