Polymorphic functions' weird behavior

From: Viatcheslav Kalinin <vka(at)ipcb(dot)net>
To: pgsql general <pgsql-general(at)postgresql(dot)org>
Subject: Polymorphic functions' weird behavior
Date: 2007-07-31 11:37:05
Message-ID: 46AF1EE1.10903@ipcb.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alban Hertroys 2007-07-31 12:22:26 psql 8.2 client vs pg 8.1 server problem
Previous Message Victor Adolfsson 2007-07-31 09:56:14 Performance problem with large resultsets (byte array 2200)