pgdiff icon indicating copy to clipboard operation
pgdiff copied to clipboard

ERROR: syntax error at or near "CASCADE" for "DROP FUNCTION"

Open David-Angel opened this issue 7 years ago • 1 comments

We are getting this error on the generated drop function statements:

ERROR: syntax error at or near "CASCADE"

FOR REAL EXAMPLE: STATEMENT: DROP FUNCTION default_data.complex_schema_changes_version CASCADE;

It should be written "drop function default_data.complex_schema_changes_version() cascade; (missing empty parenthesis)

Here is a working example of dropping functions using the "pg_get_function_identity_arguments". You should be able to easily fix it using this.

with functions (simple_name, full_name, arguments) as ( select (case when ((ns.nspname is null) or (ns.nspname = '')) then '' else ns.nspname || '.' end) || p.proname, (case when ((ns.nspname is null) or (ns.nspname = '')) then '' else '"' || ns.nspname || '".' end) || '"' || p.proname || '"', pg_get_function_identity_arguments(p.oid) from pg_proc p left join pg_namespace ns on ns.oid = p.pronamespace where -- Exclude system schemas lower(ns.nspname) not in ('pg_catalog' , 'information_schema') order by ns.nspname, p.proname ) select simple_name, format('DROP FUNCTION %s(%s);', f.full_name, f.arguments) from functions f

David-Angel avatar Apr 26 '18 01:04 David-Angel

Thank you, David. I'll try to make time to work on it this weekend.

joncrlsn avatar Apr 27 '18 15:04 joncrlsn