Oddly, this doesn't work:

create table test (x timestamp default localtimestamp at time zone 'UTC');
ERROR:  42601: syntax error at or near "at"

(Parentheses help.)

The attached patch fixes it.  Is there any reason for this omission?

(The patch also works in past releases, so it was not obviously a parser
problem.)
diff --git i/src/backend/parser/gram.y w/src/backend/parser/gram.y
index 8fc79b6..75a27ff 100644
--- i/src/backend/parser/gram.y
+++ w/src/backend/parser/gram.y
@@ -9452,6 +9452,19 @@ b_expr:		c_expr
 				{ $$ = $1; }
 			| b_expr TYPECAST Typename
 				{ $$ = makeTypeCast($1, $3, @2); }
+			| b_expr AT TIME ZONE b_expr
+				{
+					FuncCall *n = makeNode(FuncCall);
+					n->funcname = SystemFuncName("timezone");
+					n->args = list_make2($5, $1);
+					n->agg_order = NIL;
+					n->agg_star = FALSE;
+					n->agg_distinct = FALSE;
+					n->func_variadic = FALSE;
+					n->over = NULL;
+					n->location = @2;
+					$$ = (Node *) n;
+				}
 			| '+' b_expr					%prec UMINUS
 				{ $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "+", NULL, $2, @1); }
 			| '-' b_expr					%prec UMINUS
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to