pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: christopher.hamel@zimmer.com
To: pgsql-bugs@postgresql.org
Subject: BUG #10254: Joined Constraints not invoked on date ranges
Date: Wed, 07 May 2014 15:24:36 +0000
Message-ID: <20140507152436.1397.689@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

The following bug has been logged on the website:

Bug reference:      10254
Logged by:          Christopher Hamel
Email address:      christopher.hamel@zimmer.com
PostgreSQL version: 9.3.0
Operating system:   RedHat 6.4
Description:        

If you have this theoretical structure:

create table stage.header (
  id int not null,
  transaction_date date not null
);

create table stage.line (
  header_id int not null,
  transaction_date date not null,
  line_id int not null
);

create table stage.header_2013 (
  constraint header_2013_ck1 check (transaction_date >= '2013-01-01' and
transaction_date < '2014-01-01')
) inherits (stage.header);

create table stage.header_2014 (
  constraint header_2014_ck1 check (transaction_date >= '2014-01-01' and
transaction_date < '2015-01-01')
) inherits (stage.header);

create table stage.line_2013 (
  constraint line_2013_ck1 check (transaction_date >= '2013-01-01' and
transaction_date < '2014-01-01')
) inherits (stage.line);

create table stage.line_2014 (
  constraint line_2014_ck1 check (transaction_date >= '2014-01-01' and
transaction_date < '2015-01-01')
) inherits (stage.line);

If I run an explain plan on the following query:

select *
from
  stage.header h
  join stage.line l on
    h.id = l.header_id and
    h.transaction_date = l.transaction_date
where
  h.transaction_date = '2014-03-01'

It correctly invokes the check constraint on both h and l and only reads the
"2014" tables.

However, if I change the "= 2014-03-01" to "> 2014-03-01" the check
constraint is ignored.

If I specifically invoke the range on both the h and l tables, it will work
fine, but since the join specifies those fields have to be the same, can
that condition be propagated automatically?


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (2+ messages)  latest in thread

Message-ID: <20140507152436.1397.689@wrigleys.postgresql.org>
Permalink:  ../20140507152436.1397.689@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/20140507152436.1397.689@wrigleys.postgresql.org

 · 

reply

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: christopher.hamel@zimmer.com
  Subject: Re: BUG #10254: Joined Constraints not invoked on date ranges
  In-Reply-To: <20140507152436.1397.689@wrigleys.postgresql.org>
  References: <20140507152436.1397.689@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