Re: Old question - failed to find conversion function from

From: Richard Huxton <dev(at)archonet(dot)com>
To: ilejn(at)yandex(dot)ru
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Old question - failed to find conversion function from
Date: 2005-07-19 11:03:35
Message-ID: 42DCDE07.4020906@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-general

Ilja Golshtein wrote:
>
> When I invoke
>
> select 1 where 5 in (null)
>
> everything is Ok,
> though when I try
>
> select 1 where 5 in (select null)
>
> I get
>
> ERROR: failed to find conversion function from "unknown" to integer.
>
> Is it desired behavior or subject to change
> in future versions of PG?

Well, it would obviously be better if PG could figure out it was safe,
but I'm not sure there's a general case where it is. You can see it's OK
because you know there's only one row in your SELECT result-set.
However, what if you had:
... (select null UNION ALL select '2005-01-01')
Now is this a set of "unknown" or "text" or "date"? Should PG change
it's decision based on what the rest of the query wants?

So - although this may change in future versions of PG, I wouldn't count
on it never being a problem.

> I realize my simplified example looks radiculous while it came from reality.
> Sometimes my engine generates SQL queries does not know correct type
> and unable to cast, while PostgreSQL should have all information required.

How are you generating the SQL if you don't know the types involved? Are
you just blindly quoting all values? What do you do with arrays/points
etc, or don't you handle those?

--
Richard Huxton
Archonet Ltd

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Ilja Golshtein 2005-07-19 12:19:58 Re: Old question - failed to find conversion function from "unknown"
Previous Message Ilja Golshtein 2005-07-19 09:50:06 Old question - failed to find conversion function from "unknown"

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2005-07-19 12:16:32 Re: Slow first query
Previous Message Dennis Bjorklund 2005-07-19 10:42:20 Re: index row size exceeds btree maximum, 2713 - Solutions?