pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: stefano.baccianella@gmail.com
To: pgsql-bugs@postgresql.org
Subject: BUG #6512: Bug with prepared statement and timestamp + interval
Date: Sun, 04 Mar 2012 00:47:58 +0000
Message-ID: <E1S3zcE-0004Rk-Fh@wrigleys.postgresql.org> (raw)

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 = $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.




view thread (3+ messages)  latest in thread

Message-ID: <E1S3zcE-0004Rk-Fh@wrigleys.postgresql.org>
Permalink:  ../E1S3zcE-0004Rk-Fh@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/E1S3zcE-0004Rk-Fh@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: stefano.baccianella@gmail.com
  Subject: Re: BUG #6512: Bug with prepared statement and timestamp + interval
  In-Reply-To: <E1S3zcE-0004Rk-Fh@wrigleys.postgresql.org>
  References: <E1S3zcE-0004Rk-Fh@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