Re: Prepared statements and unknown types

From: Thom Brown <thom(at)linux(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Bex <Peter(dot)Bex(at)xs4all(dot)nl>, PGSQL Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Prepared statements and unknown types
Date: 2010-09-29 19:22:03
Message-ID: AANLkTin2pXrtyp8bOj1bh1kA+JbQHaZDFFuYkFNLwByr@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 29 September 2010 20:02, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Peter Bex <Peter(dot)Bex(at)xs4all(dot)nl> writes:
>> On Wed, Sep 29, 2010 at 07:33:53PM +0100, Thom Brown wrote:
>>> Okay, I understand what's happening.  But does the planner need to
>>> understand the type of literals in the select list if it's not used
>>> anywhere else?
>
>> Fields sent back to the client also carry their type with them.
>> There's no "unknown" type (and it wouldn't be very useful in any
>> case, because how would you go about displaying an unknown type?)
>
> Well, actually there *is* an "unknown" type (OID 705), which is what
> will be reported if there's a literal of unresolved type in the SELECT
> list.  That's how come you can do
>
> regression=# select 'foo' as meow;
>  meow
> ------
>  foo
> (1 row)
>
> However, the issue here is not the output but the input: PREPARE is
> complaining that the *input* parameter $1 has no determinate type.
> If PREPARE doesn't know it, then the client isn't going to know it
> either, and so it would be hard for the client to know what to send
> to execute the statement.

We'll have to think of ways to work round this then as it's for a
database class in a common library we're building.

Thanks Tom

--
Thom Brown
Twitter: @darkixion
IRC (freenode): dark_ixion
Registered Linux user: #516935

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Kerr 2010-09-29 21:21:29 Centralized User Management Tool?
Previous Message Tom Lane 2010-09-29 19:02:38 Re: Prepared statements and unknown types