this repo has no description
1CREATE OR REPLACE FUNCTION public.drop_function_if_exists(function_name text, function_args text[])
2RETURNS void AS $$
3DECLARE
4full_function_name text;
5func_oid oid;
6BEGIN
7-- Find the function OID
8SELECT p.oid INTO func_oid
9FROM pg_proc p
10JOIN pg_namespace n ON p.pronamespace = n.oid
11WHERE n.nspname = 'public'
12AND p.proname = function_name
13AND array_length(p.proargtypes, 1) = array_length(function_args, 1)
14AND array_to_string(p.proargtypes::regtype[], ',') = array_to_string(function_args::regtype[], ',');
15-- If the function exists, drop it
16IF func_oid IS NOT NULL THEN
17full_function_name := 'public.' || function_name || '(' || array_to_string(function_args, ', ') || ')';
18EXECUTE 'DROP FUNCTION ' || full_function_name;
19END IF;
20END;
21$$ LANGUAGE plpgsql;