Re: Prepared statements and unknown types

From: Thom Brown <thom(at)linux(dot)com>
To: PGSQL Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Prepared statements and unknown types
Date: 2010-09-29 18:51:11
Message-ID: AANLkTi=4oR34QtSycOUOD82_L8QHpQLd6rRvmBCVuMNC@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 29 September 2010 19:41, Peter Bex <Peter(dot)Bex(at)xs4all(dot)nl> wrote:
> 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?)

There is an unknown type...

test=# create table stuff (id serial);
NOTICE: CREATE TABLE will create implicit sequence "stuff_id_seq" for
serial column "stuff.id"
CREATE TABLE

test=# insert into stuff select c from generate_series(1,100) x(c);
INSERT 0 100

test=# PREPARE meow(unknown) AS
SELECT * from stuff where id < $1;
PREPARE
test=# execute meow(3);
id
----
1
2
(2 rows)

test=# PREPARE bark(unknown) AS
SELECT * from stuff where id < $1;
PREPARE
test=# execute bark('3'::unknown);
id
----
1
2
(2 rows)

The docs specifically make mention of it in the case of PREPARE.
--
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 sunpeng 2010-09-29 19:01:23 Are there any commands to see the created index info?
Previous Message Peter Bex 2010-09-29 18:41:42 Re: Prepared statements and unknown types