From f1438cf5c6f54d0a887c7fbef91163efda5daa0f Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Fri, 8 Jun 2012 10:28:32 +0300 Subject: [PATCH] Documentation style improvements --- doc/src/sgml/rangetypes.sgml | 60 +++++++++++++++++------------------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/doc/src/sgml/rangetypes.sgml b/doc/src/sgml/rangetypes.sgml index dcaa4ecf6c..c5994bc79e 100644 --- a/doc/src/sgml/rangetypes.sgml +++ b/doc/src/sgml/rangetypes.sgml @@ -35,32 +35,32 @@ - INT4RANGE — Range of INTEGER + int4range — Range of integer - INT8RANGE — Range of BIGINT + int8range — Range of bigint - NUMRANGE — Range of NUMERIC + numrange — Range of numeric - TSRANGE — Range of TIMESTAMP WITHOUT TIME ZONE + tsrange — Range of timestamp without time zone - TSTZRANGE — Range of TIMESTAMP WITH TIME ZONE + tstzrange — Range of timestamp with time zone - DATERANGE — Range of DATE + daterange — Range of date @@ -74,9 +74,9 @@ -CREATE TABLE reservation ( room int, during TSRANGE ); +CREATE TABLE reservation (room int, during tsrange); INSERT INTO reservation VALUES - ( 1108, '[2010-01-01 14:30, 2010-01-01 15:30)' ); + (1108, '[2010-01-01 14:30, 2010-01-01 15:30)'); -- Containment SELECT int4range(10, 20) @> 3; @@ -223,16 +223,16 @@ empty Examples: -- includes 3, does not include 7, and does include all points in between -select '[3,7)'::int4range; +SELECT '[3,7)'::int4range; -- does not include either 3 or 7, but includes all points in between -select '(3,7)'::int4range; +SELECT '(3,7)'::int4range; -- includes only the single point 4 -select '[4,4]'::int4range; +SELECT '[4,4]'::int4range; -- includes no points (and will be normalized to 'empty') -select '[4,4)'::int4range; +SELECT '[4,4)'::int4range; @@ -279,13 +279,13 @@ SELECT numrange(NULL, 2.2); A discrete range is one whose element type has a well-defined - step, such as INTEGER or DATE. + step, such as integer or date. In these types two elements can be said to be adjacent, when there are no valid values between them. This contrasts with continuous ranges, where it's always (or almost always) possible to identify other element values between two given values. For example, a range over the - NUMERIC type is continuous, as is a range over TIMESTAMP. - (Even though TIMESTAMP has limited precision, and so could + numeric type is continuous, as is a range over timestamp. + (Even though timestamp has limited precision, and so could theoretically be treated as discrete, it's better to consider it continuous since the step size is normally not of interest.) @@ -313,8 +313,8 @@ SELECT numrange(NULL, 2.2); - The built-in range types INT4RANGE, INT8RANGE, - and DATERANGE all use a canonical form that includes + The built-in range types int4range, int8range, + and daterange all use a canonical form that includes the lower bound and excludes the upper bound; that is, [). User-defined range types can use other conventions, however. @@ -332,8 +332,8 @@ SELECT numrange(NULL, 2.2); CREATE TYPE floatrange AS RANGE ( - subtype = float8, - subtype_diff = float8mi + subtype = float8, + subtype_diff = float8mi ); SELECT '[1.234, 5.678]'::floatrange; @@ -451,8 +451,7 @@ CREATE INDEX reservation_idx ON reservation USING gist (during); range type. For example: -ALTER TABLE reservation - ADD EXCLUDE USING gist (during WITH &&); +ALTER TABLE reservation ADD EXCLUDE USING gist (during WITH &&); That constraint will prevent any overlapping values from existing @@ -460,11 +459,11 @@ ALTER TABLE reservation INSERT INTO reservation VALUES - ( 1108, '[2010-01-01 11:30, 2010-01-01 13:00)' ); + (1108, '[2010-01-01 11:30, 2010-01-01 13:00)'); INSERT 0 1 INSERT INTO reservation VALUES - ( 1108, '[2010-01-01 14:45, 2010-01-01 15:45)' ); + (1108, '[2010-01-01 14:45, 2010-01-01 15:45)'); ERROR: conflicting key value violates exclusion constraint "reservation_during_excl" DETAIL: Key (during)=([ 2010-01-01 14:45:00, 2010-01-01 15:45:00 )) conflicts with existing key (during)=([ 2010-01-01 14:30:00, 2010-01-01 15:30:00 )). @@ -480,25 +479,24 @@ with existing key (during)=([ 2010-01-01 14:30:00, 2010-01-01 15:30:00 )). are equal: -CREATE TABLE room_reservation -( - room TEXT, - during TSRANGE, - EXCLUDE USING gist (room WITH =, during WITH &&) +CREATE TABLE room_reservation ( + room text, + during tsrange, + EXCLUDE USING gist (room WITH =, during WITH &&) ); INSERT INTO room_reservation VALUES - ( '123A', '[2010-01-01 14:00, 2010-01-01 15:00)' ); + ('123A', '[2010-01-01 14:00, 2010-01-01 15:00)'); INSERT 0 1 INSERT INTO room_reservation VALUES - ( '123A', '[2010-01-01 14:30, 2010-01-01 15:30)' ); + ('123A', '[2010-01-01 14:30, 2010-01-01 15:30)'); ERROR: conflicting key value violates exclusion constraint "room_reservation_room_during_excl" DETAIL: Key (room, during)=(123A, [ 2010-01-01 14:30:00, 2010-01-01 15:30:00 )) conflicts with existing key (room, during)=(123A, [ 2010-01-01 14:00:00, 2010-01-01 15:00:00 )). INSERT INTO room_reservation VALUES - ( '123B', '[2010-01-01 14:30, 2010-01-01 15:30)' ); + ('123B', '[2010-01-01 14:30, 2010-01-01 15:30)'); INSERT 0 1 -- 2.40.0