pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #6236: Query execution bug
2+ messages / 2 participants
[nested] [flat]

* BUG #6236: Query execution bug
@ 2011-09-30 11:41 Boris Matkov <borism@devart.com>
  2011-09-30 15:33 ` Re: BUG #6236: Query execution bug Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 2+ messages in thread

From: Boris Matkov @ 2011-09-30 11:41 UTC (permalink / raw)
  To: pgsql-bugs


The following bug has been logged online:

Bug reference:      6236
Logged by:          Boris Matkov
Email address:      borism@devart.com
PostgreSQL version: 9.0.0.1
Operating system:   Windows
Description:        Query execution bug
Details: 

INSERT INTO btest0 (id, name) VALUES ((SELECT DISTINCT id FROM btest0 WHERE
name = $1 LIMIT 1), $1) - was executed successfully

INSERT INTO btest0 (name,id) VALUES ($1, (SELECT DISTINCT id FROM btest0
WHERE name = $1 LIMIT 1)) - I got error:
---------------------------
inconsistent types deduced for parameter $1
---------------------------

Script for the btest0 table creating:

CREATE TABLE btest0
(
  id integer NOT NULL,
  name character varying(50) NOT NULL,
  value double precision,
  CONSTRAINT pk_btest0 PRIMARY KEY (id)
)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #6236: Query execution bug
  2011-09-30 11:41 BUG #6236: Query execution bug Boris Matkov <borism@devart.com>
@ 2011-09-30 15:33 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2011-09-30 15:33 UTC (permalink / raw)
  To: Boris Matkov <borism@devart.com>; +Cc: pgsql-bugs

"Boris Matkov" <borism@devart.com> writes:
> INSERT INTO btest0 (id, name) VALUES ((SELECT DISTINCT id FROM btest0 WHERE
> name = $1 LIMIT 1), $1) - was executed successfully

> INSERT INTO btest0 (name,id) VALUES ($1, (SELECT DISTINCT id FROM btest0
> WHERE name = $1 LIMIT 1)) - I got error:
> ---------------------------
> inconsistent types deduced for parameter $1
> ---------------------------

> Script for the btest0 table creating:

> CREATE TABLE btest0
> (
>   id integer NOT NULL,
>   name character varying(50) NOT NULL,
>   value double precision,
>   CONSTRAINT pk_btest0 PRIMARY KEY (id)
> )

It may be annoying, but it's not a bug.  The equality test uses the
"text = text" operator, so if that's seen first then the parameter gets
resolved as text.  You'd be better off to declare the type of the
parameter instead of assuming that it will always be resolved the way
you want ... but if you can't be bothered to do that, using text instead
of varchar as the column type would avoid most of the cases where you'll
see something like this.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2011-09-30 15:33 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-09-30 11:41 BUG #6236: Query execution bug Boris Matkov <borism@devart.com>
2011-09-30 15:33 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox