Re: problem with bytea and undecorated literals

Daniele Varrazzo <[email protected]> Thu, 29 Apr 2010 14:06:04 +0100
Newsgroups gmane.comp.python.db.psycopg.devel
Message-ID <[email protected]>
On Thu, Apr 29, 2010 at 1:59 PM, Daniele Varrazzo
<[email protected]> wrote:

> With arrays instead it seems Postgres is not so aggressive in casting
> the argument to one for which a signature is available:
>
> test=> create function haveadatea(x timestamp[]) returns text language sql
>  as $$ select 'got a ts[]'::text $$;
> CREATE FUNCTION
> test=> select haveadatea (array['2010-01-01']);
> ERROR:  function haveadatea(text[]) does not exist
> LINE 1: select haveadatea (array['2010-01-01']);
>               ^
> HINT:  No function matches the given name and argument types. You
> might need to add explicit type casts.

Well, actually in case of text against an array parameter Postgres
does look for a proper type too: it seems it is ARRAY that it refuses
to cast:

test=> select haveadatea ('{''2010-01-01''}');
 haveadatea
------------
 got a ts[]
(1 row)

From the psycopg point of view it is probably easier to use the
ARRAY[] syntax with explicit cast on the array elements anyway.

-- Daniele