Search Postgresql Archives

Re: Operator based on data type

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/01/2012 9:20 PM, Daniel McGreal wrote:
I have ended up writing a function (more accurately, two functions) which always convert a value into an array, either by returning the array immediately or by nesting it inside one so that all queries can use the second form, above.

CREATE OR REPLACE FUNCTION make_array(anyarray)  RETURNS anyarray AS
'select $1'  LANGUAGE sql IMMUTABLE COST 1;
CREATE OR REPLACE FUNCTION make_array(anynonarray)  RETURNS anyarray AS
'select array[$1]'  LANGUAGE sql IMMUTABLE COST 1;

Oooh, that's clever. Nice!

People say function overloading is no good ....

--
Craig Ringer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux