You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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
The text was updated successfully, but these errors were encountered: