From: heiko.helmbrecht@xclinical.com
To: pgsql-bugs@postgresql.org
Subject: BUG #6723: Exception for correct query
Date: Mon, 09 Jul 2012 12:25:18 +0000
Message-ID: <E1SoD1i-0005T1-Sb@wrigleys.postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 6723
Logged by: Heiko Helmbrecht
Email address: heiko.helmbrecht@xclinical.com
PostgreSQL version: 8.4.12
Operating system: Linux
Description:
The optimizer is using a where condition for a full table, not to the
results of a join/subselect result, that's why it is tried to use casts,
that cannot work on the whole table, here are the easy steps to reproduce
the problems:
create table myTable(id integer, is_current boolean, value varchar(100), ref
integer);
create table myJoinTable(id integer, name varchar(10));
insert into myTable(id, is_current, value, ref) values
(1,true,'2012-01-15',1),
(2,true,'no date',2),
(3,false,'2012-01-07',3),
(4,false,'2012-01-07',1),
(5,false,'2012-01-07',1),
(6,false,'2012-01-07',1),
(7,false,'2012-01-07',1),
(8,false,'2012-01-07',3),
(9,true,'2012-01-07',3);
insert into myJoinTable(id, name) values (1, 'A'), (2, 'B'), (3, 'A');
select myDate from
(select CAST(t2.value AS DATE) as myDate
from myJoinTable t1 join myTable t2
on t1.id = t2.ref where t2.is_current = TRUE and t1.name = 'A') myTmpTable
WHERE myDate > '2012-01-01';
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: heiko.helmbrecht@xclinical.com
Subject: Re: BUG #6723: Exception for correct query
In-Reply-To: <E1SoD1i-0005T1-Sb@wrigleys.postgresql.org>
References: <E1SoD1i-0005T1-Sb@wrigleys.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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