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달 전156회 조회
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?

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠