diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml index 9b83210282..35b9161871 100644 --- a/doc/src/sgml/datatype.sgml +++ b/doc/src/sgml/datatype.sgml @@ -2154,7 +2154,7 @@ TIMESTAMP WITH TIME ZONE '2004-10-19 10:23:54+02' - + Special Values @@ -2242,12 +2242,26 @@ TIMESTAMP WITH TIME ZONE '2004-10-19 10:23:54+02' type: CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP, LOCALTIME, - LOCALTIMESTAMP. The latter four accept an - optional subsecond precision specification. (See LOCALTIMESTAMP. (See .) Note that these are SQL functions and are not recognized in data input strings. + + + While the input strings now, + today, tomorrow, + and yesterday are fine to use in interactive SQL + commands, they can have surprising behavior when the command is + saved to be executed later, for example in prepared statements, + views, and function definitions. The string can be converted to a + specific time value that continues to be used long after it becomes + stale. Use one of the SQL functions instead in such contexts. + For example, CURRENT_DATE + 1 is safer than + 'tomorrow'::date. + + + diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 09afb91a54..9d1e66a5e3 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -9997,20 +9997,22 @@ now() SELECT CURRENT_TIMESTAMP; SELECT now(); -SELECT TIMESTAMP 'now'; -- incorrect for use with DEFAULT +SELECT TIMESTAMP 'now'; -- but see tip below - You do not want to use the third form when specifying a DEFAULT - clause while creating a table. The system will convert now + Do not use the third form when specifying a value to be evaluated later, + for example in a DEFAULT clause for a table column. + The system will convert now to a timestamp as soon as the constant is parsed, so that when the default value is needed, the time of the table creation would be used! The first two forms will not be evaluated until the default value is used, because they are function calls. Thus they will give the desired behavior of defaulting to the time of row insertion. + (See also .)