Open loicmalassis opened 4 months ago
Hello @loicmalassis Thanks for the code.
We have support for the overloaded functions in the roadmap. I don't know if we need to return DDL concatenation of all the overloaded functions. Because oracle's dbms_metadata.get_ddl is returning DDL of a single overloaded function when we try to get DDL of overloaded function(randomly it is picking one of overloaded functions I guess). As this extension is counterpart for oracle dbms_metadata, we need to provide similar results. We will try to add this support soon.
First of all, thank you guys for having developed this extension.
There is one little bug, when several functions are defined with the same name but different sets of parameters, for example: 1) function my_schema.my_function(char, char) 2) function my_schema.my_function(char, char, int)
The function get_routine_ddl is expecting one single oid for a given schema+function Hence it creates an exception
Here is the proposed updated code, which provides the concatenated DDL (for each different "instance" of the function)
I hope it helps
Take care
CREATE OR REPLACE FUNCTION dbms_metadata.get_routine_ddl(schema_name text, routine_name text, routine_type text DEFAULT 'procedure'::text) RETURNS text LANGUAGE plpgsql AS $function$ DECLARE l_oid oid; routine_code text; routine_type_flag text; l_sqlterminator_guc boolean; BEGIN -- Initialize transform params if they have not been set before PERFORM dbms_metadata.init_transform_params();
EXCEPTION WHEN NO_DATA_FOUND THEN IF schema_name IS NULL THEN RAISE EXCEPTION '% with name % not found. Please provide schema name.', routine_type, routine_name; ELSE RAISE EXCEPTION '% with name % not found in schema %', routine_type, routine_name, schema_name; END IF; END; $function$ ;