default localtimestamp at time zone
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.)
Attachments:
default-localtimestamp-at-time-zone.patchtext/x-patch; charset=UTF-8; name=default-localtimestamp-at-time-zone.patchDownload
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
Peter Eisentraut <peter_e@gmx.net> writes:
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?
I'm not really thrilled about adding low-usage options to b_expr. That
could back us into a corner later, by preventing b_expr from being used
in someplace where it'd be desirable.
regards, tom lane