MobilityDB 1.3
Loading...
Searching...
No Matches
Functions | Variables
temporal.c File Reference

Basic functions for temporal types of any subtype. More...

#include "pg_temporal/temporal.h"
#include <assert.h>
#include <postgres.h>
#include <funcapi.h>
#include <access/heaptoast.h>
#include <access/detoast.h>
#include <libpq/pqformat.h>
#include <utils/timestamp.h>
#include <meos.h>
#include <meos_rgeo.h>
#include <meos_internal.h>
#include "temporal/set.h"
#include "temporal/span.h"
#include "temporal/tbox.h"
#include "temporal/temporal.h"
#include "temporal/temporal_boxops.h"
#include "temporal/type_inout.h"
#include "temporal/type_util.h"
#include "geo/tgeo.h"
#include "pg_temporal/doxygen_mobilitydb.h"
#include "pg_temporal/meos_catalog.h"
#include "pg_temporal/type_util.h"
#include "pg_geo/tspatial.h"

Functions

void _PG_init (void)
 Initialize the MobilityDB extension. More...
 
bool ensure_not_empty_array (ArrayType *array)
 Ensure that the array is not empty. More...
 
FunctionCallInfo fetch_fcinfo ()
 Fetch from the cache the fcinfo of the external function. More...
 
interpType input_interp_string (FunctionCallInfo fcinfo, int argno)
 Return a temporal instant from a value and a timestamptz @sqlfn tint(), tfloat(), ... More...
 
Datum interval_cmp (PG_FUNCTION_ARGS)
 
Datum Mobilitydb_full_version (PG_FUNCTION_ARGS UNUSED)
 Return the versions of the MobilityDB extension and its dependencies @sqlfn mobilitydb_full_version() More...
 
Datum Mobilitydb_version (PG_FUNCTION_ARGS UNUSED)
 Return the version of the MobilityDB extension @sqlfn mobilitydb_version() More...
 
void store_fcinfo (FunctionCallInfo fcinfo)
 Store in the cache the fcinfo of the external function. More...
 
Datum Tbool_to_tint (PG_FUNCTION_ARGS)
 Convert a temporal Boolean into a temporal int @sqlfn tint() More...
 
Datum Temporal_append_tinstant (PG_FUNCTION_ARGS)
 Append an instant to a temporal value @sqlfn appendInstant() More...
 
Datum Temporal_append_tsequence (PG_FUNCTION_ARGS)
 Append a sequence to a temporal value @sqlfn appendSequence() More...
 
Datum Temporal_at_max (PG_FUNCTION_ARGS)
 Return a temporal value restricted to its maximum base value @sqlfn atMax() More...
 
Datum Temporal_at_min (PG_FUNCTION_ARGS)
 Return a temporal value restricted to its minimum base value @sqlfn atMin() More...
 
Datum Temporal_at_timestamptz (PG_FUNCTION_ARGS)
 Return a temporal value restricted to a timestamptz @sqlfn atTime() More...
 
Datum Temporal_at_tstzset (PG_FUNCTION_ARGS)
 Return a temporal value restricted to a timestamptz set @sqlfn atTime() More...
 
Datum Temporal_at_tstzspan (PG_FUNCTION_ARGS)
 Return a temporal value restricted to a timestamptz span @sqlfn atTime() More...
 
Datum Temporal_at_tstzspanset (PG_FUNCTION_ARGS)
 Return a temporal value restricted to a timestamptz span set @sqlfn atTime() More...
 
Datum Temporal_at_value (PG_FUNCTION_ARGS)
 Return a temporal value restricted to a base value @sqlfn atValue() More...
 
Datum Temporal_at_values (PG_FUNCTION_ARGS)
 Return a temporal value restricted to a set of base values @sqlfn atValues() More...
 
Datum Temporal_cmp (PG_FUNCTION_ARGS)
 Return -1, 0, or 1 depending on whether the first temporal value is less than, equal to, or greater than the second temporal value @sqlfn tint_cmp(), tfloat_cmp(), ... More...
 
Datum Temporal_delete_timestamptz (PG_FUNCTION_ARGS)
 Delete a timestamptz from a temporal value @sqlfn deleteTime() More...
 
Datum Temporal_delete_tstzset (PG_FUNCTION_ARGS)
 Delete a timestamptz set from a temporal value @sqlfn deleteTime() More...
 
Datum Temporal_delete_tstzspan (PG_FUNCTION_ARGS)
 Delete a timestamptz span from a temporal value @sqlfn deleteTime() More...
 
Datum Temporal_delete_tstzspanset (PG_FUNCTION_ARGS)
 Delete a timestamptz span set from a temporal value @sqlfn deleteTime() More...
 
Datum Temporal_duration (PG_FUNCTION_ARGS)
 Return the duration of a temporal value @sqlfn duration() More...
 
Datum Temporal_end_instant (PG_FUNCTION_ARGS)
 Return the end instant of a temporal value @sqlfn endInstant() More...
 
Datum Temporal_end_sequence (PG_FUNCTION_ARGS)
 Return the end sequence of a temporal sequence (set) @sqlfn endSequence() More...
 
Datum Temporal_end_timestamptz (PG_FUNCTION_ARGS)
 Return the end timestamptz of a temporal value @sqlfn endTimestamp() More...
 
Datum Temporal_end_value (PG_FUNCTION_ARGS)
 Return the end base value of a temporal value @sqlfn endValue() More...
 
Datum Temporal_enforce_typmod (PG_FUNCTION_ARGS)
 Enforce typmod information for temporal types. More...
 
Datum Temporal_eq (PG_FUNCTION_ARGS)
 Return true if two temporal values are equal @sqlfn tint_eq(), tfloat_eq(), ... More...
 
Datum Temporal_ge (PG_FUNCTION_ARGS)
 Return true if the first temporal value is greater than or equal to the second one @sqlfn tint_ge(), tfloat_ge(), ... More...
 
Datum Temporal_gt (PG_FUNCTION_ARGS)
 Return true if the first temporal value is greater than the second one @sqlfn tint_gt(), tfloat_gt(), ... More...
 
Datum Temporal_hash (PG_FUNCTION_ARGS)
 Return the hash value of a temporal value @sqlfn tint_hash(), tfloat_hash(), ... More...
 
Datum Temporal_in (PG_FUNCTION_ARGS)
 Return a temporal value from its Well-Known Text (WKT) representation @sqlfn tint_in(), tfloat_in(), ... More...
 
Datum Temporal_insert (PG_FUNCTION_ARGS)
 Insert the second temporal value into the first one @sqlfn insert() More...
 
Datum Temporal_instant_n (PG_FUNCTION_ARGS)
 Return the n-th instant of a temporal value @sqlfn instantN() More...
 
Datum Temporal_instants (PG_FUNCTION_ARGS)
 Return the array of distinct instants of a temporal value @sqlfn instants() More...
 
Datum Temporal_interp (PG_FUNCTION_ARGS)
 Return the interpolation of a temporal value as a string @sqlfn interp() More...
 
Datum Temporal_le (PG_FUNCTION_ARGS)
 Return true if the first temporal value is less than or equal to the second one @sqlfn tint_le(), tfloat_le(), ... More...
 
Datum Temporal_lower_inc (PG_FUNCTION_ARGS)
 Return true if the start instant of a temporal value is inclusive @sqlfn lowerInc() More...
 
Datum Temporal_lt (PG_FUNCTION_ARGS)
 Return true if the first temporal value is less than the second one @sqlfn tint_lt(), tfloat_lt(), ... More...
 
Datum Temporal_max_instant (PG_FUNCTION_ARGS)
 Return the instant with maximum base value of a temporal value @sqlfn maxInstant() More...
 
Datum Temporal_max_value (PG_FUNCTION_ARGS)
 Return the maximum base value of a temporal value @sqlfn maxValue() More...
 
Datum Temporal_mem_size (PG_FUNCTION_ARGS)
 Return the memory size in bytes of a temporal value @sqlfn memSize() More...
 
Datum Temporal_merge (PG_FUNCTION_ARGS)
 Merge two temporal values @sqlfn merge() More...
 
Datum Temporal_merge_array (PG_FUNCTION_ARGS)
 Merge an array of temporal values @sqlfn merge() More...
 
Datum Temporal_min_instant (PG_FUNCTION_ARGS)
 Return the instant with the minimum base value of a temporal value @sqlfn minInstant() More...
 
Datum Temporal_min_value (PG_FUNCTION_ARGS)
 Return the minimum base value of a temporal value @sqlfn minValue() More...
 
Datum Temporal_minus_max (PG_FUNCTION_ARGS)
 Return a temporal value restricted to the complement of its maximum base value @sqlfn minusMax() More...
 
Datum Temporal_minus_min (PG_FUNCTION_ARGS)
 Return a temporal value restricted to the complement of its minimum base value @sqlfn minusMin() More...
 
Datum Temporal_minus_timestamptz (PG_FUNCTION_ARGS)
 Return a temporal value restricted to the complement of a timestamptz @sqlfn minusTime() More...
 
Datum Temporal_minus_tstzset (PG_FUNCTION_ARGS)
 Return a temporal value restricted to the complement of a timestamptz set @sqlfn minusTime() More...
 
Datum Temporal_minus_tstzspan (PG_FUNCTION_ARGS)
 Return a temporal value restricted to the complement of a timestamptz span @sqlfn minusTime() More...
 
Datum Temporal_minus_tstzspanset (PG_FUNCTION_ARGS)
 Return a temporal value restricted to the complement of a span set @sqlfn minusTime() More...
 
Datum Temporal_minus_value (PG_FUNCTION_ARGS)
 Return a temporal value restricted to the complement of a base value @sqlfn minusValue() More...
 
Datum Temporal_minus_values (PG_FUNCTION_ARGS)
 Return a temporal value restricted to the complement of a set of base values @sqlfn minusValues() More...
 
Datum Temporal_ne (PG_FUNCTION_ARGS)
 Return true if two temporal values are different @sqlfn tint_ne(), tfloat_ne(), ... More...
 
Datum Temporal_num_instants (PG_FUNCTION_ARGS)
 Return the number of distinct instants of a temporal value @sqlfn numInstants() More...
 
Datum Temporal_num_sequences (PG_FUNCTION_ARGS)
 Return the number of sequences of a temporal sequence (set) @sqlfn numSequences() More...
 
Datum Temporal_num_timestamps (PG_FUNCTION_ARGS)
 Return the number of distinct timestamps of a temporal value @sqlfn numTimestamps() More...
 
Datum Temporal_out (PG_FUNCTION_ARGS)
 Return the Well-Known Text (WKT) representation of a temporal value @sqlfn tint_out(), tfloat_out(), ... More...
 
Datum Temporal_recv (PG_FUNCTION_ARGS)
 Return a temporal value from its Well-Known Binary (WKB) representation @sqlfn tint_recv(), tfloat_recv(), ... More...
 
Temporaltemporal_recv (StringInfo buf)
 Return a temporal value from its binary representation read from a buffer. More...
 
Datum Temporal_restrict_minmax (FunctionCallInfo fcinfo, bool min, bool atfunc)
 Generic function for restricting a temporal value to its minimum/maximum base value @sqlfn atMin(), minusMin(), atMax(), minusMax(),. More...
 
static Datum Temporal_restrict_timestamptz (FunctionCallInfo fcinfo, bool atfunc)
 Return a temporal value restricted to (the complement of) a timestamptz. More...
 
Datum Temporal_restrict_tstzset (FunctionCallInfo fcinfo, bool atfunc)
 Return a temporal value restricted to a timestamptz set @sqlfn atTime() More...
 
static Datum Temporal_restrict_tstzspan (FunctionCallInfo fcinfo, bool atfunc)
 Return a temporal value restricted to (the complement of) a timestamptz span. More...
 
Datum Temporal_restrict_tstzspanset (FunctionCallInfo fcinfo, bool atfunc)
 Return a temporal value restricted to a timestamptz span set @sqlfn atTime() More...
 
static Datum Temporal_restrict_value (FunctionCallInfo fcinfo, bool atfunc)
 Return a temporal value restricted to (the complement of) a base value. More...
 
static Datum Temporal_restrict_values (FunctionCallInfo fcinfo, bool atfunc)
 Return a temporal value restricted to (the complement of) a set of base values. More...
 
Datum Temporal_round (PG_FUNCTION_ARGS)
 Return a temporal value with the component values set to a number of decimal places @sqlfn round() More...
 
Datum Temporal_scale_time (PG_FUNCTION_ARGS)
 Return a temporal value scaled by an interval @sqlfn scaleTime() More...
 
Datum Temporal_segments (PG_FUNCTION_ARGS)
 Return the array of segments of a temporal sequence (set) @sqlfn segments() More...
 
Datum Temporal_send (PG_FUNCTION_ARGS)
 Return the Well-Known Binary (WKB) representation of a temporal value @sqlfn tint_send(), tfloat_send(), ... More...
 
Datum Temporal_sequence_n (PG_FUNCTION_ARGS)
 Return the n-th sequence of a temporal sequence (set) @sqlfn sequenceN() More...
 
Datum Temporal_sequences (PG_FUNCTION_ARGS)
 Return the array of sequences of a temporal sequence (set) @sqlfn sequences() More...
 
Datum Temporal_set_interp (PG_FUNCTION_ARGS)
 Return a temporal value transformed to an interpolation @sqlfn setInterp() More...
 
Datum Temporal_shift_scale_time (PG_FUNCTION_ARGS)
 Return a temporal value shifted and scaled by two intervals @sqlfn shiftScaleTime() More...
 
Datum Temporal_shift_time (PG_FUNCTION_ARGS)
 Return a temporal value shifted by an interval @sqlfn shiftTime() More...
 
Temporaltemporal_slice (Datum tempdatum)
 Peek into a temporal datum to find the bounding box. More...
 
Datum Temporal_start_instant (PG_FUNCTION_ARGS)
 Return the start instant of a temporal value @sqlfn startInstant() More...
 
Datum Temporal_start_sequence (PG_FUNCTION_ARGS)
 Return the start sequence of a temporal sequence (set) @sqlfn startSequence() More...
 
Datum Temporal_start_timestamptz (PG_FUNCTION_ARGS)
 Return the start timestamptz of a temporal value @sqlfn startTimestamp() More...
 
Datum Temporal_start_value (PG_FUNCTION_ARGS)
 Return the start base value of a temporal value @sqlfn startValue() More...
 
Datum Temporal_stops (PG_FUNCTION_ARGS)
 Return the constant segments of a temporal value @sqlfn stops() More...
 
Datum Temporal_subtype (PG_FUNCTION_ARGS)
 Return the subtype of a temporal value as a string @sqlfn tempSubtype() More...
 
Datum Temporal_time (PG_FUNCTION_ARGS)
 Return the time on which a temporal value is defined as a span set @sqlfn getTime() More...
 
Datum Temporal_timestamps (PG_FUNCTION_ARGS)
 Return the array of distinct timestamps of a temporal value @sqlfn timestamps() More...
 
Datum Temporal_timestamptz_n (PG_FUNCTION_ARGS)
 Return the n-th distinct timestamptz of a temporal value @sqlfn timestampN() More...
 
Datum Temporal_to_tinstant (PG_FUNCTION_ARGS)
 Return a temporal value transformed to a temporal instant @sqlfn tintInst(), tfloatInst(), ... More...
 
Datum Temporal_to_tsequence (PG_FUNCTION_ARGS)
 Return a temporal value transformed to a temporal sequence. More...
 
Datum Temporal_to_tsequenceset (PG_FUNCTION_ARGS)
 Return a temporal value transformed to a temporal sequence set. More...
 
Datum Temporal_to_tstzspan (PG_FUNCTION_ARGS)
 Convert a temporal value into a timestamptz span @sqlfn timeSpan() More...
 
Datum Temporal_typmod_in (PG_FUNCTION_ARGS)
 Input typmod information for temporal types. More...
 
Datum Temporal_typmod_out (PG_FUNCTION_ARGS)
 Output typmod information for temporal types. More...
 
Datum Temporal_unnest (PG_FUNCTION_ARGS)
 Return the list of values and associated span sets of a temporal value @sqlfn unnest() More...
 
TempUnnestStatetemporal_unnest_state_make (const Temporal *temp)
 Create the initial state that persists across multiple calls of the function. More...
 
void temporal_unnest_state_next (TempUnnestState *state)
 Increment the current state to the next unnest value. More...
 
Datum Temporal_update (PG_FUNCTION_ARGS)
 Update the first temporal value with the second one @sqlfn update() More...
 
Datum Temporal_upper_inc (PG_FUNCTION_ARGS)
 Return true if the end instant of a temporal value is inclusive @sqlfn upperInc() More...
 
static Temporaltemporal_valid_typmod (Temporal *temp, int32_t typmod)
 Ensure that the temporal type of a temporal value corresponds to the typmod. More...
 
Datum Temporal_value_at_timestamptz (PG_FUNCTION_ARGS)
 Return the base value of a temporal value at a timestamptz @sqlfn valueAtTimestamp() More...
 
Datum Temporal_value_n (PG_FUNCTION_ARGS)
 Return the n-th value of a temporal value @sqlfn valueN() More...
 
Datum Temporal_valueset (PG_FUNCTION_ARGS)
 Return the base values of a temporal value as a set @sqlfn getValues() More...
 
void temporal_write (const Temporal *temp, StringInfo buf)
 Write the binary representation of a temporal value into a buffer. More...
 
Datum Temporalarr_round (PG_FUNCTION_ARGS)
 Return an array of temporal floats with the precision of the values set to a number of decimal places @sqlfn asText() More...
 
Datum Tfloat_to_tint (PG_FUNCTION_ARGS)
 Convert a temporal float into a temporal integer @sqlfn tint() More...
 
Datum timestamp_mi (PG_FUNCTION_ARGS)
 
Datum Tinstant_constructor (PG_FUNCTION_ARGS)
 Return a temporal instant from a value and a timestamptz @sqlfn tint(), tfloat(), ... More...
 
TInstanttinstant_recv (StringInfo buf, meosType temptype)
 Return a temporal instant from its binary representation read from a buffer. More...
 
Datum Tinstant_timestamptz (PG_FUNCTION_ARGS)
 Return the timestamptz of a temporal instant @sqlfn getTimestamp() More...
 
Datum Tinstant_value (PG_FUNCTION_ARGS)
 Return the base value of a temporal instant @sqlfn getValue() More...
 
void tinstant_write (const TInstant *inst, StringInfo buf)
 Write the binary representation of a temporal instant into a buffer. More...
 
Datum Tint_to_tfloat (PG_FUNCTION_ARGS)
 Convert a temporal integer into a temporal float @sqlfn tfloat() More...
 
Datum Tnumber_at_span (PG_FUNCTION_ARGS)
 Return a temporal value restricted to a span of base values @sqlfn atSpan() More...
 
Datum Tnumber_at_spanset (PG_FUNCTION_ARGS)
 Return a temporal value restricted to a span set of base values @sqlfn atSpanset() More...
 
Datum Tnumber_at_tbox (PG_FUNCTION_ARGS)
 Return a temporal value restricted to a temporal box @sqlfn atTbox() More...
 
Datum Tnumber_integral (PG_FUNCTION_ARGS)
 Return the integral (area under the curve) of a temporal number @sqlfn integral() More...
 
Datum Tnumber_minus_span (PG_FUNCTION_ARGS)
 Return a temporal value restricted to the complement of a span of base values @sqlfn minusSpan() More...
 
Datum Tnumber_minus_spanset (PG_FUNCTION_ARGS)
 Return a temporal value restricted to the complement of a span set of base values @sqlfn minusSpanset() More...
 
Datum Tnumber_minus_tbox (PG_FUNCTION_ARGS)
 Return a temporal value restricted to the complement of a temporal box @sqlfn minusTbox() More...
 
static Datum Tnumber_restrict_span (FunctionCallInfo fcinfo, bool atfunc)
 
static Datum Tnumber_restrict_spanset (FunctionCallInfo fcinfo, bool atfunc)
 Return a temporal value restricted to (the complement of) a span set of base values. More...
 
static Datum Tnumber_restrict_tbox (FunctionCallInfo fcinfo, bool atfunc)
 Return a temporal value restricted to (the complement of) a temporal box. More...
 
Datum Tnumber_scale_value (PG_FUNCTION_ARGS)
 Return a temporal value scaled by an interval @sqlfn scaleValue() More...
 
Datum Tnumber_shift_scale_value (PG_FUNCTION_ARGS)
 Return a temporal value shifted and scaled by two intervals @sqlfn shiftScaleValue() More...
 
Datum Tnumber_shift_value (PG_FUNCTION_ARGS)
 Return a temporal value shifted by an interval @sqlfn shiftValue() More...
 
Datum Tnumber_to_span (PG_FUNCTION_ARGS)
 Convert a temporal number into a value span @sqlfn valueSpan() More...
 
Datum Tnumber_to_tbox (PG_FUNCTION_ARGS)
 Convert a temporal number into a temporal box @sqlfn tbox() More...
 
Datum Tnumber_twavg (PG_FUNCTION_ARGS)
 Return the time-weighted average of a temporal number @sqlfn twAvg() More...
 
Datum Tnumber_valuespans (PG_FUNCTION_ARGS)
 Return the value span set of a temporal number @sqlfn getValues() More...
 
Datum Tsequence_constructor (PG_FUNCTION_ARGS)
 Return a temporal sequence from an array of temporal instants @sqlfn tintSeq(), tfloatSeq(), ... More...
 
Datum Tsequence_from_base_tstzset (PG_FUNCTION_ARGS)
 Return a temporal discrete sequence from a base value and a timestamptz set @sqlfn tint(), tfloat(), ... More...
 
Datum Tsequence_from_base_tstzspan (PG_FUNCTION_ARGS)
 Return a temporal sequence from a base value and a timestamptz span @sqlfn tint(), tfloat(), ... More...
 
TSequencetsequence_recv (StringInfo buf, meosType temptype)
 Return a temporal sequence from its binary representation read from a buffer. More...
 
void tsequence_write (const TSequence *seq, StringInfo buf)
 Write the binary representation of a temporal sequence into a buffer. More...
 
Datum Tsequenceset_constructor (PG_FUNCTION_ARGS)
 Return a temporal sequence set from an array of temporal sequences @sqlfn tintSeqSet(), tfloatSeqSet(), ... More...
 
Datum Tsequenceset_constructor_gaps (PG_FUNCTION_ARGS)
 Return a temporal sequence set from an array of temporal instants accounting for potential gaps. More...
 
Datum Tsequenceset_from_base_tstzspanset (PG_FUNCTION_ARGS)
 Return a temporal sequence set from a base value and a timestamptz set @sqlfn tint(), tfloat(), ... More...
 

Variables

static FunctionCallInfo MOBDB_PG_FCINFO
 Global variable that saves the PostgreSQL fcinfo structure. More...
 
 PG_MODULE_MAGIC
 

Detailed Description

Basic functions for temporal types of any subtype.