Re: Confusion over Python drivers - Mailing list pgsql-hackers

From Jeff Davis
Subject Re: Confusion over Python drivers
Date
Msg-id 1265673715.29919.2491.camel@jdavis
Whole thread Raw
In response to Re: Confusion over Python drivers  (Andrew McNamara <andrewm@object-craft.com.au>)
Responses Re: Confusion over Python drivers
List pgsql-hackers
On Tue, 2010-02-09 at 10:46 +1100, Andrew McNamara wrote:
> The problem is deeper than that - when query parameters use the binary
> option, the server has no way to decode the binary parameter without an
> appropriate type OID.

Postgres does not attempt to decode anything (text or binary format)
until it figures out what type it is.

> As you say, postgres will cast types depending on context, however this
> is stricter when binary parameters are used (because they only have one
> valid interpretation, whereas a text parameter may have several).

Type casts are a different matter; they are only done after the unknown
literals' types have been determined:
 create table n(i int);
 -- insert numeric literal, which is cast to int (assignment cast) insert into n values(5.0); -- succeeds
 -- insert unknown literal, which is inferred to be of type int insert into n values('5.0'); -- fails on integer type
inputfunction ERROR:  invalid input syntax for integer: "5.0" LINE 1: insert into n values('5.0');
 


Can you provide a concrete example in which the text versus binary
format changes the type inference behavior?

Regards,Jeff Davis



pgsql-hackers by date:

Previous
From: Jeff Davis
Date:
Subject: Re: Confusion over Python drivers
Next
From: Tom Lane
Date:
Subject: Re: Order of operations in lazy_vacuum_rel