From: Peter Eisentraut Date: 2009年6月10日 07:03:34 +0000 (+0000) Subject: Correct/improve the datetime_precision field in the information schema. X-Git-Tag: REL8_4_RC1~26 X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=208d3a7555541383aadf682e47c14fed21468374;p=postgresql.git Correct/improve the datetime_precision field in the information schema. In particular, always show 0 for the date type instead of null, and show 6 (the default) for time, timestamp, and interval without a declared precision. This is now in fuller conformance with the SQL standard. Also clarify the documentation about this. discovered and analyzed by Konstantin Izmailov and Tom Lane --- diff --git a/doc/src/sgml/information_schema.sgml b/doc/src/sgml/information_schema.sgml index 06ccb6d2dea..b6e143c5da5 100644 --- a/doc/src/sgml/information_schema.sgml +++ b/doc/src/sgml/information_schema.sgml @@ -1,4 +1,4 @@ - + The Information Schema @@ -395,9 +395,12 @@ datetime_precision cardinal_number - If data_type identifies a date, time, or - interval type, the declared precision; null for all other data - types or if no precision was declared. + If data_type identifies a date, time, + timestamp, or interval type, this column contains the (declared + or implicit) fractional seconds precision of the type for this + attribute, that is, the number of decimal digits maintained + following the decimal point in the seconds value. For all + other data types, this column is null. @@ -995,9 +998,12 @@ datetime_precision cardinal_number - If data_type identifies a date, time, or - interval type, the declared precision; null for all other data - types or if no precision was declared. + If data_type identifies a date, time, + timestamp, or interval type, this column contains the (declared + or implicit) fractional seconds precision of the type for this + column, that is, the number of decimal digits maintained + following the decimal point in the seconds value. For all + other data types, this column is null. @@ -1729,7 +1735,7 @@ cardinal_number If the domain has a numeric type, this column contains the - (declared or implicit) precision of the type for this column. + (declared or implicit) precision of the type for this domain. The precision indicates the number of significant digits. It can be expressed in decimal (base 10) or binary (base 2) terms, as specified in the column @@ -1755,7 +1761,7 @@ cardinal_number If the domain has an exact numeric type, this column contains - the (declared or implicit) scale of the type for this column. + the (declared or implicit) scale of the type for this domain. The scale indicates the number of significant digits to the right of the decimal point. It can be expressed in decimal (base 10) or binary (base 2) terms, as specified in the column @@ -1768,9 +1774,12 @@ datetime_precision cardinal_number - If the domain has a date, time, or interval type, the declared - precision; null for all other data types or if no precision was - declared. + If data_type identifies a date, time, + timestamp, or interval type, this column contains the (declared + or implicit) fractional seconds precision of the type for this + domain, that is, the number of decimal digits maintained + following the decimal point in the seconds value. For all + other data types, this column is null. diff --git a/src/backend/catalog/information_schema.sql b/src/backend/catalog/information_schema.sql index 80132e27ea4..b295abbeab5 100644 --- a/src/backend/catalog/information_schema.sql +++ b/src/backend/catalog/information_schema.sql @@ -4,7 +4,7 @@ * * Copyright (c) 2003-2009, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/backend/catalog/information_schema.sql,v 1.53 2009年02月24日 10:06:32 petere Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/information_schema.sql,v 1.54 2009年06月10日 07:03:34 petere Exp $ */ /* @@ -160,12 +160,12 @@ CREATE FUNCTION _pg_datetime_precision(typid oid, typmod int4) RETURNS integer RETURNS NULL ON NULL INPUT AS $$SELECT - CASE WHEN 2ドル = -1 /* default typmod */ - THEN null + CASE WHEN 1ドル IN (1082) /* date */ + THEN 0 WHEN 1ドル IN (1083, 1114, 1184, 1266) /* time, timestamp, same + tz */ - THEN 2ドル + THEN CASE WHEN 2ドル < 0 THEN 6 ELSE 2ドル END WHEN 1ドル IN (1186) /* interval */ - THEN 2ドル & 65535 + THEN CASE WHEN 2ドル < 0 THEN 6 ELSE 2ドル & 65535 END ELSE null END$$;

AltStyle によって変換されたページ (->オリジナル) /