Parameter name Information missing in system view PG_PROC_INFO.proargnames for not named parameters

0

In PostgreSQL, when creating a procedure using the following syntax:

CREATE OR REPLACE PROCEDURE schema3.position_test( OUT arg1 INTEGER, INOUT BOOLEAN, OUT arg3 BIGINT ) LANGUAGE 'plpgsql' SECURITY INVOKER AS $$ BEGIN -- Procedure logic here END; $$;

The system catalog pg_proc correctly displays the proargnames column as {arg1,"",arg3}. However, when executing the same query in Amazon Redshift and checking the system catalog pg_proc_info, the proargnames column displays as {arg1,arg3}.

My question is: How can I accurately determine the exact position of parameter names in Redshift?

Any insights or clarification on this difference would be greatly appreciated. Thank you!

已提问 2 个月前157 查看次数
1 回答
1

In Amazon Redshift, the pg_proc_info system view does not provide the parameter names for unnamed parameters, as you have observed. This is a known behavior in Redshift, and it is different from how PostgreSQL handles it.

A workaround you can try is combining the information from proargnames, proargmodes, and proallargtypes. This should allow you to accurately determine the position, name (if named), mode, and data type of each parameter in the function or procedure definition.

This approach should help you work around the limitation of Redshift not displaying unnamed parameter names directly in the proargnames column.

Key Source:

profile picture
专家
已回答 2 个月前
  • CREATE OR REPLACE PROCEDURE schema7.position_test ( INTEGER, INOUT BOOLEAN, OUT arg BIGINT) LANGUAGE 'plpgsql' SECURITY INVOKER AS $$ BEGIN END; $$;

    This is how I am creating a procedure

    & as per your workaround I am fetching 3 columns

    SELECT p.proname AS Procedure_Name, p.proargnames AS Parameter_Name, p.proargmodes AS Parameter_Mode, p.proallargtypes AS Parameter_Type FROM pg_catalog.pg_proc_info p JOIN pg_catalog.pg_namespace n ON p.pronamespace = n.oid JOIN pg_catalog.pg_language l ON p.prolang = l.oid WHERE n.nspname = 'schema7'

    procedure_name parameter_name parameter_mode parameter_type

    position_test {arg} {i,b,o} {23,16,20}

    now how can i say whether arg is the first or second or third parameter?

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则