Skip site navigation (1) Skip section navigation (2)

BUG #6512: Bug with prepared statement and timestamp + interval

From: stefano(dot)baccianella(at)gmail(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #6512: Bug with prepared statement and timestamp + interval
Date: 2012-03-04 00:47:58
Message-ID: E1S3zcE-0004Rk-Fh@wrigleys.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-bugs
The following bug has been logged on the website:

Bug reference:      6512
Logged by:          Stefano Baccianella
Email address:      stefano(dot)baccianella(at)gmail(dot)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.


Responses

pgsql-bugs by date

Next:From: Magnus HaganderDate: 2012-03-04 11:44:54
Subject: Re: BUG #6502: Missing Link at Version Tracker
Previous:From: markoDate: 2012-03-03 19:19:48
Subject: BUG #6511: calling spi_exec_query from non-main package,results in: couldn't fetch $_TD

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group