mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-24 18:55:04 +08:00
Add LOCALTIME and LOCALTIMESTAMP functions per SQL99 standard.
Remove ODBC-compatible empty parentheses from calls to SQL99 functions for which these parentheses do not match the standard. Update the ODBC driver to ensure compatibility with the ODBC standard for these functions (e.g. CURRENT_TIMESTAMP, CURRENT_USER, etc). Include a new appendix in the User's Guide which lists the labeled features for SQL99 (the labeled features replaced the "basic", "intermediate", and "advanced" categories from SQL92). features.sgml does not yet split this list into "supported" and "unsupported" lists.
This commit is contained in:
parent
bad5fe9797
commit
133df7ce70
1811
doc/src/sgml/features.sgml
Normal file
1811
doc/src/sgml/features.sgml
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/filelist.sgml,v 1.18 2002/06/13 05:54:00 momjian Exp $ -->
|
||||
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/filelist.sgml,v 1.19 2002/06/15 02:59:55 thomas Exp $ -->
|
||||
|
||||
<!entity history SYSTEM "history.sgml">
|
||||
<!entity info SYSTEM "info.sgml">
|
||||
@ -23,16 +23,17 @@
|
||||
<!entity array SYSTEM "array.sgml">
|
||||
<!entity datatype SYSTEM "datatype.sgml">
|
||||
<!entity datetime SYSTEM "datetime.sgml">
|
||||
<!entity features SYSTEM "features.sgml">
|
||||
<!entity func SYSTEM "func.sgml">
|
||||
<!entity indices SYSTEM "indices.sgml">
|
||||
<!entity inherit SYSTEM "inherit.sgml">
|
||||
<!entity keywords SYSTEM "keywords.sgml">
|
||||
<!entity manage SYSTEM "manage.sgml">
|
||||
<!entity mvcc SYSTEM "mvcc.sgml">
|
||||
<!entity perform SYSTEM "perform.sgml">
|
||||
<!entity queries SYSTEM "queries.sgml">
|
||||
<!entity syntax SYSTEM "syntax.sgml">
|
||||
<!entity typeconv SYSTEM "typeconv.sgml">
|
||||
<!entity keywords SYSTEM "keywords.sgml">
|
||||
|
||||
<!-- reference pages -->
|
||||
<!entity % allfiles SYSTEM "ref/allfiles.sgml">
|
||||
|
@ -1,5 +1,5 @@
|
||||
<!--
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.101 2002/06/11 16:00:17 thomas Exp $
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.102 2002/06/15 02:59:55 thomas Exp $
|
||||
PostgreSQL documentation
|
||||
-->
|
||||
|
||||
@ -2703,17 +2703,17 @@ PostgreSQL documentation
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><function>current_time</function></entry>
|
||||
<entry><type>time</type></entry>
|
||||
<entry>Time of day; see <link linkend="functions-datetime-current">below</link>
|
||||
</entry>
|
||||
<entry></entry>
|
||||
<entry></entry>
|
||||
<entry><function>current_time</function></entry>
|
||||
<entry><type>time with time zone</type></entry>
|
||||
<entry>Time of day; see <link linkend="functions-datetime-current">below</link>
|
||||
</entry>
|
||||
<entry></entry>
|
||||
<entry></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><function>current_timestamp</function></entry>
|
||||
<entry><type>timestamp</type></entry>
|
||||
<entry><type>timestamp with time zone</type></entry>
|
||||
<entry>Date and time; see <link linkend="functions-datetime-current">below</link>
|
||||
</entry>
|
||||
<entry></entry>
|
||||
@ -2790,6 +2790,24 @@ PostgreSQL documentation
|
||||
<entry><literal>true</literal></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><function>localtime</function></entry>
|
||||
<entry><type>time</type></entry>
|
||||
<entry>Time of day; see <link linkend="functions-datetime-current">below</link>
|
||||
</entry>
|
||||
<entry></entry>
|
||||
<entry></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><function>localtimestamp</function></entry>
|
||||
<entry><type>timestamp</type></entry>
|
||||
<entry>Date and time; see <link linkend="functions-datetime-current">below</link>
|
||||
</entry>
|
||||
<entry></entry>
|
||||
<entry></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><function>now</function>()</entry>
|
||||
<entry><type>timestamp</type></entry>
|
||||
@ -3264,40 +3282,37 @@ SELECT date_trunc('year', TIMESTAMP '2001-02-16 20:38:40');
|
||||
<para>
|
||||
The following functions are available to obtain the current date and/or
|
||||
time:
|
||||
<synopsis>
|
||||
<synopsis>
|
||||
CURRENT_DATE
|
||||
CURRENT_TIME
|
||||
CURRENT_TIMESTAMP
|
||||
CURRENT_TIME ( <replaceable>precision</replaceable> )
|
||||
CURRENT_TIMESTAMP ( <replaceable>precision</replaceable> )
|
||||
</synopsis>
|
||||
<function>CURRENT_TIME</function> and
|
||||
<function>CURRENT_TIMESTAMP</function> can optionally be given
|
||||
a precision parameter, which causes the result to be rounded
|
||||
to that many fractional digits. Without a precision parameter,
|
||||
the result is given to full available precision.
|
||||
</para>
|
||||
|
||||
<note>
|
||||
<para>
|
||||
Prior to <productname>PostgreSQL</productname> 7.2, the precision parameters
|
||||
were unimplemented, and the result was always given in integer
|
||||
seconds.
|
||||
LOCALTIME
|
||||
LOCALTIMESTAMP
|
||||
LOCALTIME ( <replaceable>precision</replaceable> )
|
||||
LOCALTIMESTAMP ( <replaceable>precision</replaceable> )
|
||||
</synopsis>
|
||||
<function>CURRENT_TIME</function>,
|
||||
<function>CURRENT_TIMESTAMP</function>,
|
||||
<function>LOCALTIME</function>, and
|
||||
<function>LOCALTIMESTAMP</function>
|
||||
can optionally be given
|
||||
a precision parameter, which causes the result to be rounded
|
||||
to that many fractional digits. Without a precision parameter,
|
||||
the result is given to the full available precision.
|
||||
</para>
|
||||
</note>
|
||||
|
||||
<note>
|
||||
<para>
|
||||
The <acronym>SQL99</acronym> standard requires these functions to
|
||||
be written without any parentheses, unless a precision parameter
|
||||
is given. As of <productname>PostgreSQL</productname> 7.2, an empty pair of
|
||||
parentheses can be written, but this is deprecated and may be
|
||||
removed in a future release.
|
||||
</para>
|
||||
</note>
|
||||
<note>
|
||||
<para>
|
||||
Prior to <productname>PostgreSQL</productname> 7.2, the precision
|
||||
parameters were unimplemented, and the result was always given
|
||||
in integer seconds.
|
||||
</para>
|
||||
</note>
|
||||
|
||||
<informalexample>
|
||||
<screen>
|
||||
<informalexample>
|
||||
<screen>
|
||||
SELECT CURRENT_TIME;
|
||||
<computeroutput>14:39:53.662522-05</computeroutput>
|
||||
|
||||
@ -3309,6 +3324,9 @@ SELECT CURRENT_TIMESTAMP;
|
||||
|
||||
SELECT CURRENT_TIMESTAMP(2);
|
||||
<computeroutput>2001-12-23 14:39:53.66-05</computeroutput>
|
||||
|
||||
SELECT LOCALTIMESTAMP;
|
||||
<computeroutput>2001-12-23 14:39:53.662522</computeroutput>
|
||||
</screen>
|
||||
</informalexample>
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
<!--
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/user.sgml,v 1.29 2001/05/12 22:51:36 petere Exp $
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/user.sgml,v 1.30 2002/06/15 02:59:55 thomas Exp $
|
||||
-->
|
||||
|
||||
<book id="user">
|
||||
@ -31,6 +31,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/Attic/user.sgml,v 1.29 2001/05/12 22:51:36
|
||||
|
||||
&datetime;
|
||||
&keywords;
|
||||
&features;
|
||||
|
||||
&biblio;
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.322 2002/06/13 14:16:43 thomas Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.323 2002/06/15 03:00:03 thomas Exp $
|
||||
*
|
||||
* HISTORY
|
||||
* AUTHOR DATE MAJOR EVENT
|
||||
@ -259,7 +259,6 @@ static void doNegateFloat(Value *v);
|
||||
%type <list> row_descriptor, row_list, in_expr_nodes
|
||||
%type <node> row_expr
|
||||
%type <node> case_expr, case_arg, when_clause, case_default
|
||||
%type <boolean> opt_empty_parentheses
|
||||
%type <list> when_clause_list
|
||||
%type <ival> sub_type
|
||||
%type <list> OptCreateAs, CreateAsList
|
||||
@ -347,7 +346,7 @@ static void doNegateFloat(Value *v);
|
||||
KEY,
|
||||
|
||||
LANCOMPILER, LANGUAGE, LEADING, LEFT, LEVEL, LIKE, LIMIT, LISTEN,
|
||||
LOAD, LOCAL, LOCATION, LOCK_P,
|
||||
LOAD, LOCAL, LOCALTIME, LOCALTIMESTAMP, LOCATION, LOCK_P,
|
||||
|
||||
MATCH, MAXVALUE, MINUTE_P, MINVALUE, MODE, MONTH_P, MOVE,
|
||||
|
||||
@ -5461,7 +5460,7 @@ c_expr: columnref
|
||||
n->agg_distinct = FALSE;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
| CURRENT_DATE opt_empty_parentheses
|
||||
| CURRENT_DATE
|
||||
{
|
||||
/*
|
||||
* Translate as "'now'::text::date".
|
||||
@ -5487,7 +5486,7 @@ c_expr: columnref
|
||||
|
||||
$$ = (Node *)makeTypeCast((Node *)s, d);
|
||||
}
|
||||
| CURRENT_TIME opt_empty_parentheses
|
||||
| CURRENT_TIME
|
||||
{
|
||||
/*
|
||||
* Translate as "'now'::text::timetz".
|
||||
@ -5530,7 +5529,7 @@ c_expr: columnref
|
||||
|
||||
$$ = (Node *)makeTypeCast((Node *)s, d);
|
||||
}
|
||||
| CURRENT_TIMESTAMP opt_empty_parentheses
|
||||
| CURRENT_TIMESTAMP
|
||||
{
|
||||
/*
|
||||
* Translate as "'now'::text::timestamptz".
|
||||
@ -5574,7 +5573,94 @@ c_expr: columnref
|
||||
|
||||
$$ = (Node *)makeTypeCast((Node *)s, d);
|
||||
}
|
||||
| CURRENT_USER opt_empty_parentheses
|
||||
| LOCALTIME
|
||||
{
|
||||
/*
|
||||
* Translate as "'now'::text::time".
|
||||
* See comments for CURRENT_DATE.
|
||||
*/
|
||||
A_Const *s = makeNode(A_Const);
|
||||
TypeName *d;
|
||||
|
||||
s->val.type = T_String;
|
||||
s->val.val.str = "now";
|
||||
s->typename = SystemTypeName("text");
|
||||
|
||||
d = SystemTypeName("time");
|
||||
/* SQL99 mandates a default precision of zero for TIME
|
||||
* fields in schemas. However, for LOCALTIME
|
||||
* let's preserve the microsecond precision we
|
||||
* might see from the system clock. - thomas 2001-12-07
|
||||
*/
|
||||
d->typmod = 6;
|
||||
|
||||
$$ = (Node *)makeTypeCast((Node *)s, d);
|
||||
}
|
||||
| LOCALTIME '(' Iconst ')'
|
||||
{
|
||||
/*
|
||||
* Translate as "'now'::text::time(n)".
|
||||
* See comments for CURRENT_DATE.
|
||||
*/
|
||||
A_Const *s = makeNode(A_Const);
|
||||
TypeName *d;
|
||||
|
||||
s->val.type = T_String;
|
||||
s->val.val.str = "now";
|
||||
s->typename = SystemTypeName("text");
|
||||
d = SystemTypeName("time");
|
||||
if (($3 < 0) || ($3 > MAX_TIME_PRECISION))
|
||||
elog(ERROR, "LOCALTIME(%d) precision must be between %d and %d",
|
||||
$3, 0, MAX_TIME_PRECISION);
|
||||
d->typmod = $3;
|
||||
|
||||
$$ = (Node *)makeTypeCast((Node *)s, d);
|
||||
}
|
||||
| LOCALTIMESTAMP
|
||||
{
|
||||
/*
|
||||
* Translate as "'now'::text::timestamp".
|
||||
* See comments for CURRENT_DATE.
|
||||
*/
|
||||
A_Const *s = makeNode(A_Const);
|
||||
TypeName *d;
|
||||
|
||||
s->val.type = T_String;
|
||||
s->val.val.str = "now";
|
||||
s->typename = SystemTypeName("text");
|
||||
|
||||
d = SystemTypeName("timestamp");
|
||||
/* SQL99 mandates a default precision of 6 for timestamp.
|
||||
* Also, that is about as precise as we will get since
|
||||
* we are using a microsecond time interface.
|
||||
* - thomas 2001-12-07
|
||||
*/
|
||||
d->typmod = 6;
|
||||
|
||||
$$ = (Node *)makeTypeCast((Node *)s, d);
|
||||
}
|
||||
| LOCALTIMESTAMP '(' Iconst ')'
|
||||
{
|
||||
/*
|
||||
* Translate as "'now'::text::timestamp(n)".
|
||||
* See comments for CURRENT_DATE.
|
||||
*/
|
||||
A_Const *s = makeNode(A_Const);
|
||||
TypeName *d;
|
||||
|
||||
s->val.type = T_String;
|
||||
s->val.val.str = "now";
|
||||
s->typename = SystemTypeName("text");
|
||||
|
||||
d = SystemTypeName("timestamp");
|
||||
if (($3 < 0) || ($3 > MAX_TIMESTAMP_PRECISION))
|
||||
elog(ERROR, "LOCALTIMESTAMP(%d) precision must be between %d and %d",
|
||||
$3, 0, MAX_TIMESTAMP_PRECISION);
|
||||
d->typmod = $3;
|
||||
|
||||
$$ = (Node *)makeTypeCast((Node *)s, d);
|
||||
}
|
||||
| CURRENT_USER
|
||||
{
|
||||
FuncCall *n = makeNode(FuncCall);
|
||||
n->funcname = SystemFuncName("current_user");
|
||||
@ -5583,7 +5669,7 @@ c_expr: columnref
|
||||
n->agg_distinct = FALSE;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
| SESSION_USER opt_empty_parentheses
|
||||
| SESSION_USER
|
||||
{
|
||||
FuncCall *n = makeNode(FuncCall);
|
||||
n->funcname = SystemFuncName("session_user");
|
||||
@ -5592,7 +5678,7 @@ c_expr: columnref
|
||||
n->agg_distinct = FALSE;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
| USER opt_empty_parentheses
|
||||
| USER
|
||||
{
|
||||
FuncCall *n = makeNode(FuncCall);
|
||||
n->funcname = SystemFuncName("current_user");
|
||||
@ -5966,9 +6052,6 @@ attrs: '.' attr_name
|
||||
{ $$ = lcons(makeString($2), $3); }
|
||||
;
|
||||
|
||||
opt_empty_parentheses: '(' ')' { $$ = TRUE; }
|
||||
| /*EMPTY*/ { $$ = TRUE; }
|
||||
;
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
@ -6572,6 +6655,8 @@ reserved_keyword:
|
||||
| INTO
|
||||
| LEADING
|
||||
| LIMIT
|
||||
| LOCALTIME
|
||||
| LOCALTIMESTAMP
|
||||
| NEW
|
||||
| NOT
|
||||
| NULL_P
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.113 2002/06/11 15:41:37 thomas Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.114 2002/06/15 03:00:03 thomas Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -172,6 +172,8 @@ static const ScanKeyword ScanKeywords[] = {
|
||||
{"listen", LISTEN},
|
||||
{"load", LOAD},
|
||||
{"local", LOCAL},
|
||||
{"localtime", LOCALTIME},
|
||||
{"localtimestamp", LOCALTIMESTAMP},
|
||||
{"location", LOCATION},
|
||||
{"lock", LOCK_P},
|
||||
{"match", MATCH},
|
||||
|
@ -103,6 +103,8 @@ char *mapFuncs[][2] = {
|
||||
{"CURRENT_DATE", "current_date" },
|
||||
{"CURRENT_TIME", "current_time" },
|
||||
{"CURRENT_TIMESTAMP", "current_timestamp" },
|
||||
{"LOCALTIME", "localtime" },
|
||||
{"LOCALTIMESTAMP", "localtimestamp" },
|
||||
{"CURRENT_USER", "cast(current_user as text)" },
|
||||
{"SESSION_USER", "cast(session_user as text)" },
|
||||
{"CURDATE", "current_date" },
|
||||
|
Loading…
Reference in New Issue
Block a user