Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id AF7C48E352D for ; Sat, 3 Mar 2012 20:48:14 -0400 (AST) Received: from mahout.postgresql.org ([98.129.198.123]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1S3zcR-0004l9-QQ for pgsql-bugs@postgresql.org; Sun, 04 Mar 2012 00:48:14 +0000 Received: from [204.145.124.246] (helo=wrigleys.postgresql.org) by mahout.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1S3zcF-0005Q3-8c for pgsql-bugs@postgresql.org; Sun, 04 Mar 2012 00:47:59 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.72) (envelope-from ) id 1S3zcE-0004Rk-Fh for pgsql-bugs@postgresql.org; Sun, 04 Mar 2012 00:47:58 +0000 Date: Sun, 04 Mar 2012 00:47:58 +0000 Message-Id: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #6512: Bug with prepared statement and timestamp + interval To: pgsql-bugs@postgresql.org From: stefano.baccianella@gmail.com X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201203/23 X-Sequence-Number: 32584 The following bug has been logged on the website: Bug reference: 6512 Logged by: Stefano Baccianella Email address: stefano.baccianella@gmail.com PostgreSQL version: 9.1.1 Operating system: Windows 7 64bit Description: = When trying to execute a query like: SELECT * FROM table WHERE timestamp_column > $1 AND timestamp_column < $1 + interval '1 hour' There is no problems, but when executing SELECT * FROM table WHERE timestamp_column > $1 - interval '1 hour' AND timestamp_column < $1 + interval '1 hour' The database return a error saying the the operator timestamp > interval does not exist. Either the query SELECT * FROM table WHERE timestamp_column < $1 + interval '1 hour' AND timestamp_column > $1 Does not work The $1 value is a timestamp (like now() for instance). But the query SELECT * FROM table WHERE timestamp_column =3D $1 OR ( timestamp_column > $1 - interval '1 hour' AND timestamp_column < $1 + interval '1 hour') works as expected. It seems that the analyzer cannot guess the value of a prepared statement combined with an interval. For my test i'm using PHP without PDO.