Values of temporal types must satisfy several constraints so that they are well defined. These constraints are given next.
The constraints on the base type and the timestamptz
type must be satisfied.
A sequence value must be composed of at least one instant value.
An instantaneous sequence value must have inclusive lower and upper bounds.
In a sequence value, the timestamps of the composing instants must be different and ordered.
In a sequence value with stepwise interpolation, the last two values must be equal if upper bound is exclusive.
A set value must be composed of at least one unit value.
In an instant set value, the composing instants must be different and ordered. This implies that the temporal extent of an instant set value is an ordered set of timestamptz
values without duplicates.
In a sequence set value, the composing sequence values must be non overlapping and ordered. This implies that the temporal extent of a sequence set value is an ordered set of disjoint periods.
An error is raised whenever one of these constraints are not satisfied. Examples of incorrect temporal values are as follows.
-- Incorrect value for base type SELECT tbool '1.5@2001-01-01 08:00:00'; -- Base type value is not a point SELECT tgeompoint 'Linestring(0 0,1 1)@2001-01-01 08:05:00'; -- Incorrect timestamp SELECT tint '2@2001-02-31 08:00:00'; -- Empty sequence SELECT tint ''; -- Incorrect bounds for instantaneous sequence SELECT tint '[1@2001-01-01 09:00:00)'; -- Duplicate timestamps SELECT tint '[1@2001-01-01 08:00:00, 2@2001-01-01 08:00:00]'; -- Unordered timestamps SELECT tint '[1@2001-01-01 08:10:00, 2@2001-01-01 08:00:00]'; -- Incorrect end value SELECT tint '[1@2001-01-01 08:00:00, 2@2001-01-01 08:10:00)'; -- Empty sequence set SELECT tints(ARRAY[]); -- Duplicate timestamps SELECT tinti(ARRAY[tint '1@2001-01-01 08:00:00', '2@2001-01-01 08:00:00']); -- Overlapping periods SELECT tints(ARRAY[tint '[1@2001-01-01 08:00:00, 1@2001-01-01 10:00:00)', '[2@2001-01-01 09:00:00, 2@2001-01-01 11:00:00)']);