Polymorphic functions' weird behavior - Mailing list pgsql-general

From Viatcheslav Kalinin
Subject Polymorphic functions' weird behavior
Date
Msg-id 46AF1EE1.10903@ipcb.net
Whole thread Raw
Responses Re: Polymorphic functions' weird behavior
List pgsql-general
Hello
We've come across  the following issue with Polymorphic functions:

CREATE OR REPLACE FUNCTION "array_to_set" (vaarray anyarray) RETURNS
SETOF anyelement AS
$body$
BEGIN
   FOR I IN COALESCE(ARRAY_LOWER(VAARRAY, 1), 1) ..
COALESCE(ARRAY_UPPER(VAARRAY, 1), 0) LOOP
       RETURN NEXT VAARRAY[I];
   END LOOP;
END
$body$
LANGUAGE 'plpgsql' SECURITY INVOKER;


 > select * from array_to_set(array[1,2,3]);
array_to_set
--------------
           1
           2
           3
(3 rows)


Now we change SECURITY INVOKER clause to SECURITY DEFINER and voila:

 > select * from array_to_set(array[1,2,3]);
ERROR:  could not determine actual argument type for polymorphic
function "array_to_set"

Though explainable this is absolutely strange since logically security
rules and polymorphism are irrelevant.

regards, Viatcheslav




pgsql-general by date:

Previous
From: "Victor Adolfsson"
Date:
Subject: Performance problem with large resultsets (byte array 2200)
Next
From: ptjm@interlog.com (Patrick TJ McPhee)
Date:
Subject: Re: Porting MySQL data types to PostgreSQL