Each temporal type has a constructor function with the same name as the type and a suffix for the subtype, where the suffixes ‘_inst
’, ‘_instset
’, ‘_seq
’, and ‘_seqset
’ correspond, respectively, to the subtypes instant, instant set, sequence, and sequence set. Examples are tint_seq
or tgeompoint_seqset
. Using the constructor function is frequently more convenient than writing a literal constant.
A first set of functions have two arguments, a base type and a time type, where the latter is a timestamptz
, a timestampset
, a period
, or a periodset
value for constructing, respectively, an instant, instant set, sequence, or sequence set value. The functions for sequence or sequence set values with continuous base type have in addition an optional third argument which is a Boolean for stating whether the resulting temporal value has linear interpolation or not. By default this argument is true if it is not specified.
Another set of functions for instant set values have a single argument, which is an array of values of the corresponding instant values.
Another set of functions for sequence values have one argument for the array of values of the corresponding instant subtype and two optional Boolean arguments stating, respectively, whether the left and right bounds are inclusive or exclusive. It the these arguments are not specified they are assumed to be true by default. In addition, the functions for sequence values with continuous base type have an additional Boolean argument stating whether the interpolation is linear or not. It this argument is not specified it is assumed to be true by default.
Another set of functions for sequence set values have a single argument, which is an array of values of the corresponding sequence values. For sequence values with continuous base type, the interpolation of the resulting temporal value depends on the interpolation of the composing sequences. An error is raised if the sequences composing the array have different interpolation.
We give next the constructor functions for the various subtypes.
Constructor for temporal types of instant subtype
ttype_inst(base,timestamptz): ttype_inst
SELECT tbool_inst(true, '2001-01-01'); SELECT tint_inst(1, '2001-01-01');
Constructor for temporal types of instant set subtype
ttype_instset(base,timestampset): ttype_instset
ttype_instset(ttype_inst[]): ttype_instset
SELECT tfloat_instset(1.5, '{2001-01-01, 2001-01-02}'); SELECT ttext_instset('AAA', '{2001-01-01, 2001-01-02}'); SELECT tbool_instset(ARRAY[tbool 'true@2001-01-01 08:00:00','false@2001-01-01 08:05:00']); SELECT tint_instset(ARRAY[tint '1@2001-01-01 08:00:00', '2@2001-01-01 08:05:00']); SELECT tfloat_instset(ARRAY[tfloat '1.0@2001-01-01 08:00:00', '2.0@2001-01-01 08:05:00']); SELECT ttext_instset(ARRAY[ttext 'AAA@2001-01-01 08:00:00', 'BBB@2001-01-01 08:05:00']); SELECT tgeompoint_instset(ARRAY[tgeompoint 'Point(0 0)@2001-01-01 08:00:00', 'Point(0 1)@2001-01-01 08:05:00', 'Point(1 1)@2001-01-01 08:10:00']); SELECT tgeogpoint_instset(ARRAY[tgeogpoint 'Point(1 1)@2001-01-01 08:00:00', 'Point(2 2)@2001-01-01 08:05:00']);
Constructor for temporal types of sequence subtype
tdisc_seq(base,period): tdisc_seq
tcont_seq(base,period,linear=true): tcont_seq
tdisc_seq(ttype_inst[],left_inc=true,right_inc=true}): tdisc_seq
tcont_seq(ttype_inst[],left_inc=true,right_inc=true,linear=true}): tcont_seq
SELECT tfloat_seq(1.5, '[2001-01-01, 2001-01-02]'); SELECT tgeompoint_seq('Point(0 0)', '[2001-01-01, 2001-01-02]', false); SELECT tbool_seq(ARRAY[tbool 'true@2001-01-01 08:00:00', 'true@2001-01-03 08:05:00'], true, true); SELECT tint_seq(ARRAY[tint(2,'2001-01-01 08:00:00'), tint(2,'2001-01-01 08:10:00')], true, false); SELECT tfloat_seq(ARRAY[tfloat '2.0@2001-01-01 08:00:00', '3@2001-01-03 08:05:00', '1@2001-01-03 08:10:00'], true, false); SELECT tfloat_seq(ARRAY[tfloat '2.0@2001-01-01 08:00:00', '3@2001-01-03 08:05:00', '1@2001-01-03 08:10:00'], true, true, false); SELECT ttext_seq(ARRAY[ttext('AAA', '2001-01-01 08:00:00'), ttext('BBB', '2001-01-03 08:05:00'), ttext('BBB', '2001-01-03 08:10:00')]); SELECT tgeompoint_seq(ARRAY[tgeompoint 'Point(0 0)@2001-01-01 08:00:00', 'Point(0 1)@2001-01-03 08:05:00', 'Point(1 1)@2001-01-03 08:10:00']); SELECT tgeogpoint_seq(ARRAY[tgeogpoint 'Point(0 0)@2001-01-01 08:00:00', 'Point(0 0)@2001-01-03 08:05:00'], true, true, false);
Constructors for temporal types of sequence set subtype
tdisc_seqset(base,periodset): tdisc_seqset
tcont_seqset(base,periodset,linear=true): tcont_seqset
ttype_seqset(ttype_seq[]): ttype_seqset
SELECT ttext_seqset('AAA', '{[2001-01-01, 2001-01-02], [2001-01-03, 2001-01-04]}'); SELECT tgeogpoint_seqset('Point(0 0)', '{[2001-01-01, 2001-01-02], [2001-01-03, 2001-01-04]}', false); SELECT tbool_seqset(ARRAY[tbool '[false@2001-01-01 08:00:00, false@2001-01-01 08:05:00)', '[true@2001-01-01 08:05:00]','(false@2001-01-01 08:05:00, false@2001-01-01 08:10:00)']); SELECT tint_seqset(ARRAY[tint '[1@2001-01-01 08:00:00, 2@2001-01-01 08:05:00, 2@2001-01-01 08:10:00, 2@2001-01-01 08:15:00)']); SELECT tfloat_seqset(ARRAY[tfloat '[1.0@2001-01-01 08:00:00, 2.0@2001-01-01 08:05:00, 2.0@2001-01-01 08:10:00]', '[2.0@2001-01-01 08:15:00, 3.0@2001-01-01 08:20:00)']); SELECT tfloat_seqset(ARRAY[tfloat 'Interp=Stepwise;[1.0@2001-01-01 08:00:00, 2.0@2001-01-01 08:05:00, 2.0@2001-01-01 08:10:00]', 'Interp=Stepwise;[3.0@2001-01-01 08:15:00, 3.0@2001-01-01 08:20:00)']); SELECT ttext_seqset(ARRAY[ttext '[AAA@2001-01-01 08:00:00, AAA@2001-01-01 08:05:00)', '[BBB@2001-01-01 08:10:00, BBB@2001-01-01 08:15:00)']); SELECT tgeompoint_seqset(ARRAY[tgeompoint '[Point(0 0)@2001-01-01 08:00:00, Point(0 1)@2001-01-01 08:05:00, Point(0 1)@2001-01-01 08:10:00)', '[Point(0 1)@2001-01-01 08:15:00, Point(0 0)@2001-01-01 08:20:00)']); SELECT tgeogpoint_seqset(ARRAY[tgeogpoint 'Interp=Stepwise;[Point(0 0)@2001-01-01 08:00:00, Point(0 0)@2001-01-01 08:05:00)', 'Interp=Stepwise;[Point(1 1)@2001-01-01 08:10:00, Point(1 1)@2001-01-01 08:15:00)']); SELECT tfloat_seqset(ARRAY[tfloat 'Interp=Stepwise;[1.0@2001-01-01 08:00:00, 2.0@2001-01-01 08:05:00, 2.0@2001-01-01 08:10:00]', '[3.0@2001-01-01 08:15:00, 3.0@2001-01-01 08:20:00)']); -- ERROR: Input sequences must have the same interpolation