1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

Measure the current transaction time to milliseconds.

Define a new function, GetCurrentTransactionStartTimeUsec() to get the time
 to this precision.
Allow now() and timestamp 'now' to use this higher precision result so
 we now have fractional seconds in this "constant".
Add timestamp without time zone type.
Move previous timestamp type to timestamp with time zone.
Accept another ISO variant for date/time values: yyyy-mm-ddThh:mm:ss
 (note the "T" separating the day from hours information).
Remove 'current' from date/time types; convert to 'now' in input.
Separate time and timetz regression tests.
Separate timestamp and timestamptz regression test.
This commit is contained in:
Thomas G. Lockhart
2001-09-28 08:09:14 +00:00
parent 1f075a32ee
commit 6f58115ddd
27 changed files with 2778 additions and 1873 deletions

View File

@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.253 2001/09/23 03:39:01 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.254 2001/09/28 08:09:09 thomas Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@@ -259,7 +259,7 @@ static void doNegateFloat(Value *v);
%type <str> opt_charset, opt_collate
%type <str> opt_float
%type <ival> opt_numeric, opt_decimal
%type <boolean> opt_varying, opt_timezone
%type <boolean> opt_varying, opt_timezone, opt_timezone_x
%type <ival> Iconst
%type <str> Sconst, comment_text
@@ -4229,10 +4229,16 @@ ConstDatetime: datetime
$$->name = xlateSqlType($1);
$$->typmod = -1;
}
| TIMESTAMP opt_timezone
| TIMESTAMP opt_timezone_x
{
$$ = makeNode(TypeName);
$$->name = xlateSqlType("timestamp");
if ($2)
$$->name = xlateSqlType("timestamptz");
else
$$->name = xlateSqlType("timestamp");
/* XXX the timezone field seems to be unused
* - thomas 2001-09-06
*/
$$->timezone = $2;
$$->typmod = -1;
}
@@ -4263,6 +4269,16 @@ datetime: YEAR_P { $$ = "year"; }
| SECOND_P { $$ = "second"; }
;
/* XXX Make the default be WITH TIME ZONE for 7.2 to help with database upgrades
* but revert this back to WITHOUT TIME ZONE for 7.3.
* Do this by simply reverting opt_timezone_x to opt_timezone - thomas 2001-09-06
*/
opt_timezone_x: WITH TIME ZONE { $$ = TRUE; }
| WITHOUT TIME ZONE { $$ = FALSE; }
| /*EMPTY*/ { $$ = TRUE; }
;
opt_timezone: WITH TIME ZONE { $$ = TRUE; }
| WITHOUT TIME ZONE { $$ = FALSE; }
| /*EMPTY*/ { $$ = FALSE; }

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.60 2001/06/24 02:41:21 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.61 2001/09/28 08:09:09 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@@ -240,7 +240,7 @@ can_coerce_type(int nargs, Oid *input_typeids, Oid *func_typeids)
oid_array[0] = inputTypeId;
ftup = SearchSysCache(PROCNAME,
PointerGetDatum(typeidTypeName(targetTypeId)),
PointerGetDatum(typeidTypeName(targetTypeId)),
Int32GetDatum(1),
PointerGetDatum(oid_array),
0);
@@ -498,6 +498,7 @@ TypeCategory(Oid inType)
case (TIMETZOID):
case (ABSTIMEOID):
case (TIMESTAMPOID):
case (TIMESTAMPTZOID):
result = DATETIME_TYPE;
break;
@@ -577,7 +578,10 @@ PreferredType(CATEGORY category, Oid type)
break;
case (DATETIME_TYPE):
result = TIMESTAMPOID;
if (type == DATEOID)
result = TIMESTAMPOID;
else
result = TIMESTAMPTZOID;
break;
case (TIMESPAN_TYPE):
@@ -634,10 +638,14 @@ PromoteTypeToNext(Oid inType)
break;
case (DATEOID):
case (ABSTIMEOID):
result = TIMESTAMPOID;
break;
case (ABSTIMEOID):
case (TIMESTAMPOID):
result = TIMESTAMPTZOID;
break;
case (TIMEOID):
case (RELTIMEOID):
result = INTERVALOID;
@@ -646,7 +654,7 @@ PromoteTypeToNext(Oid inType)
case (BOOLOID):
case (TEXTOID):
case (FLOAT8OID):
case (TIMESTAMPOID):
case (TIMESTAMPTZOID):
case (INTERVALOID):
default:
result = inType;

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.101 2001/09/20 23:31:08 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.102 2001/09/28 08:09:09 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@@ -40,11 +40,11 @@ bool Transform_null_equals = false;
static Node *parser_typecast_constant(Value *expr, TypeName *typename);
static Node *parser_typecast_expression(ParseState *pstate,
Node *expr, TypeName *typename);
Node *expr, TypeName *typename);
static Node *transformAttr(ParseState *pstate, Attr *att, int precedence);
static Node *transformIdent(ParseState *pstate, Ident *ident, int precedence);
static Node *transformIndirection(ParseState *pstate, Node *basenode,
List *indirection);
List *indirection);
/*

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.72 2001/09/17 01:06:36 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.73 2001/09/28 08:09:09 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@@ -462,10 +462,13 @@ FigureColname(Node *node)
{
if (node == NULL)
return "?column?";
switch (nodeTag(node))
{
case T_Ident:
return ((Ident *) node)->name;
case T_A_Const:
return (FigureColname((Node *)((A_Const *) node)->typename));
case T_Attr:
{
List *attrs = ((Attr *) node)->attrs;
@@ -481,7 +484,15 @@ FigureColname(Node *node)
case T_FuncCall:
return ((FuncCall *) node)->funcname;
case T_TypeCast:
return FigureColname(((TypeCast *) node)->arg);
{
char *name;
name = FigureColname(((TypeCast *) node)->arg);
if (strcmp(name, "?column?") == 0)
name = FigureColname((Node *)((TypeCast *) node)->typename);
return name;
}
break;
case T_CaseExpr:
{
char *name;
@@ -492,6 +503,8 @@ FigureColname(Node *node)
return name;
}
break;
case T_TypeName:
return ((TypeName *) node)->name;
default:
break;
}