Re: Operator based on data type

From: Craig Ringer <ringerc(at)ringerc(dot)id(dot)au>
To: d(dot)j(dot)mcgreal(at)gmail(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Operator based on data type
Date: 2012-01-13 06:27:12
Message-ID: 4F0FCEC0.2000404@ringerc.id.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Craig Ringer 2012-01-13 06:44:24 Re: Compiling C function with VC++ for Windows version
Previous Message Craig Ringer 2012-01-13 06:16:55 Re: Corrupted index, what do i do?ruc