dbTalk Databases Forums  

[BUGS] AT TIME ZONE INTERVAL and prepared statements

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] AT TIME ZONE INTERVAL and prepared statements in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Kris Jurka
 
Posts: n/a

Default [BUGS] AT TIME ZONE INTERVAL and prepared statements - 10-22-2004 , 05:11 PM







AT TIME ZONE INTERVAL $1 doesn't seem to be supported in prepared
statements.

This works:

SELECT now() AT TIME ZONE INTERVAL '-08:00';

This doesn't:

PREPARE mys(text) AS SELECT now() AT TIME ZONE INTERVAL $1;
ERROR: syntax error at or near "$1" at character 57

These work:

PREPARE mys(interval) AS SELECT now() AT TIME ZONE $1;
PREPARE mys(text) AS SELECT now() AT TIME ZONE ($1::interval)


Any reason why the second case doesn't work?

Kris Jurka

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] AT TIME ZONE INTERVAL and prepared statements - 10-22-2004 , 05:25 PM






Kris Jurka <books (AT) ejurka (DOT) com> writes:
Quote:
AT TIME ZONE INTERVAL $1 doesn't seem to be supported in prepared
statements.
Try
AT TIME ZONE $1
or possibly
AT TIME ZONE $1::interval
You are confusing the syntax for a typed literal with part of the AT
TIME ZONE construct.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match


Reply With Quote
  #3  
Old   
Kris Jurka
 
Posts: n/a

Default Re: [BUGS] AT TIME ZONE INTERVAL and prepared statements - 10-22-2004 , 05:57 PM





On Fri, 22 Oct 2004, Tom Lane wrote:

Quote:
You are confusing the syntax for a typed literal with part of the AT
TIME ZONE construct.
Could you explain what the difference is between a typed literal
"int '11'" and a cast(ed) literal "'11'::int" to me they seem like the
same thing.

Kris Jurka


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings


Reply With Quote
  #4  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] AT TIME ZONE INTERVAL and prepared statements - 10-22-2004 , 06:04 PM



Kris Jurka <books (AT) ejurka (DOT) com> writes:
Quote:
On Fri, 22 Oct 2004, Tom Lane wrote:
You are confusing the syntax for a typed literal with part of the AT
TIME ZONE construct.

Could you explain what the difference is between a typed literal
"int '11'" and a cast(ed) literal "'11'::int" to me they seem like the
same thing.
Yes, they are semantically the same. The first one is a kluge that Tom
Lockhart put in to approximate the SQL spec's demands for representation
of timestamp and interval constants. It does not work syntactically to
try to extend it to a general cast construct (we can only barely manage
to support it as-is --- there are various special cases that don't work
such as arrays and qualified type names, and a depressingly large part
of gram.y is devoted to getting the cases that do work to work). Even
if we could get the parser to cope with that without reduce/reduce
errors, we'd be greatly reducing the grammar's ability to detect actual
syntax errors, because practically anything next to practically anything
else would become a potentially legal cast construct.

So, no "INTERVAL $1". Bad enough we have to take "INTERVAL 'string'".
This wasn't one of the SQL committee's better ideas.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.