Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Wi8nZ-0002bI-KM for pgsql-bugs@arkaria.postgresql.org; Wed, 07 May 2014 20:50:41 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Wi8nY-0000Ud-EC for pgsql-bugs@arkaria.postgresql.org; Wed, 07 May 2014 20:50:40 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Wi3iV-0006cl-RY for pgsql-bugs@postgresql.org; Wed, 07 May 2014 15:25:07 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Wi3iR-0006Y3-H8 for pgsql-bugs@postgresql.org; Wed, 07 May 2014 15:25:06 +0000 MIME-Version: 1.0 Subject: BUG #10254: Joined Constraints not invoked on date ranges To: pgsql-bugs@postgresql.org From: christopher.hamel@zimmer.com Date: Wed, 07 May 2014 15:24:36 +0000 Message-ID: <20140507152436.1397.689@wrigleys.postgresql.org> X-Pg-Spam-Score: -1.2 (-) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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