MobilityDB 1.1
Functions | Variables
temporal.c File Reference
#include "pg_general/temporal.h"
#include <assert.h>
#include <access/tuptoaster.h>
#include <libpq/pqformat.h>
#include <funcapi.h>
#include <meos.h>
#include <meos_internal.h>
#include "general/pg_types.h"
#include "general/temporaltypes.h"
#include "general/temporal_boxops.h"
#include "general/type_out.h"
#include "general/type_util.h"
#include "pg_general/doxygen_mobilitydb_api.h"
#include "pg_general/meos_catalog.h"
#include "pg_general/tinstant.h"
#include "pg_general/tsequence.h"
#include "pg_general/type_util.h"
#include "pg_point/tpoint_spatialfuncs.h"
Include dependency graph for temporal.c:

Functions

void _PG_init (void)
 Initialize the MobilityDB extension. More...
 
void ensure_non_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...
 
Datum interval_cmp (PG_FUNCTION_ARGS)
 
PGDLLEXPORT Datum Mobilitydb_full_version (PG_FUNCTION_ARGS)
 Versions of the MobilityDB extension and its dependencies. More...
 
PGDLLEXPORT Datum Mobilitydb_version (PG_FUNCTION_ARGS)
 Version of the MobilityDB extension. More...
 
void store_fcinfo (FunctionCallInfo fcinfo)
 Store in the cache the fcinfo of the external function. More...
 
PGDLLEXPORT Datum Tdiscseq_constructor (PG_FUNCTION_ARGS)
 Construct a temporal sequence with discrete interpolation from the array of temporal instants. More...
 
PGDLLEXPORT Datum Tdiscseq_from_base_time (PG_FUNCTION_ARGS)
 Construct a temporal discrete sequence from a base value and a timestamp set. More...
 
PGDLLEXPORT Datum Temporal_always_eq (PG_FUNCTION_ARGS)
 Return true if a temporal value is always equal to the base value. More...
 
PGDLLEXPORT Datum Temporal_always_ge (PG_FUNCTION_ARGS)
 Return true if a temporal value is always greater than or equal to a base value. More...
 
PGDLLEXPORT Datum Temporal_always_gt (PG_FUNCTION_ARGS)
 Return true if a temporal value is always greater than a base value. More...
 
PGDLLEXPORT Datum Temporal_always_le (PG_FUNCTION_ARGS)
 Return true if a temporal value is always less than or equal to a base value. More...
 
PGDLLEXPORT Datum Temporal_always_lt (PG_FUNCTION_ARGS)
 Return true if a temporal value is always less than a base value. More...
 
PGDLLEXPORT Datum Temporal_always_ne (PG_FUNCTION_ARGS)
 Return true if a temporal value is always different from a base value. More...
 
PGDLLEXPORT Datum Temporal_append_tinstant (PG_FUNCTION_ARGS)
 Append an instant at the end of a temporal value. More...
 
PGDLLEXPORT Datum Temporal_append_tsequence (PG_FUNCTION_ARGS)
 Append a sequence at the end of a temporal value. More...
 
PGDLLEXPORT Datum Temporal_at_max (PG_FUNCTION_ARGS)
 Restrict a temporal value to its maximum base value. More...
 
PGDLLEXPORT Datum Temporal_at_min (PG_FUNCTION_ARGS)
 Restrict a temporal value to its minimum base value. More...
 
PGDLLEXPORT Datum Temporal_at_period (PG_FUNCTION_ARGS)
 Restrict a temporal value to a period. More...
 
PGDLLEXPORT Datum Temporal_at_periodset (PG_FUNCTION_ARGS)
 Restrict a temporal value to a period set. More...
 
PGDLLEXPORT Datum Temporal_at_timestamp (PG_FUNCTION_ARGS)
 Restrict a temporal value to a timestamp. More...
 
PGDLLEXPORT Datum Temporal_at_timestampset (PG_FUNCTION_ARGS)
 Restrict a temporal value to a timestamp set. More...
 
PGDLLEXPORT Datum Temporal_at_value (PG_FUNCTION_ARGS)
 Restrict a temporal value to a base value. More...
 
PGDLLEXPORT Datum Temporal_at_values (PG_FUNCTION_ARGS)
 Restrict a temporal value to an array of base values. More...
 
void temporal_bbox_slice (Datum tempdatum, void *box)
 Peak into a temporal datum to find the bounding box. More...
 
PGDLLEXPORT Datum Temporal_cmp (PG_FUNCTION_ARGS)
 Return -1, 0, or 1 depending on whether the first temporal value is less than, equal, or greater than the second temporal value. More...
 
PGDLLEXPORT Datum Temporal_delete_period (PG_FUNCTION_ARGS)
 Delete a period from a temporal value. More...
 
PGDLLEXPORT Datum Temporal_delete_periodset (PG_FUNCTION_ARGS)
 Delete a period set from a temporal value. More...
 
PGDLLEXPORT Datum Temporal_delete_timestamp (PG_FUNCTION_ARGS)
 Delete a timestamp from a temporal value. More...
 
PGDLLEXPORT Datum Temporal_delete_timestampset (PG_FUNCTION_ARGS)
 Delete a timestamp set from a temporal value. More...
 
PGDLLEXPORT Datum Temporal_duration (PG_FUNCTION_ARGS)
 Return the duration of a temporal value. More...
 
PGDLLEXPORT Datum Temporal_end_instant (PG_FUNCTION_ARGS)
 Return the end instant of a temporal value. More...
 
PGDLLEXPORT Datum Temporal_end_sequence (PG_FUNCTION_ARGS)
 Return the end sequence of a temporal sequence (set) More...
 
PGDLLEXPORT Datum Temporal_end_timestamp (PG_FUNCTION_ARGS)
 Return the end timestamp of a temporal value. More...
 
PGDLLEXPORT Datum Temporal_end_value (PG_FUNCTION_ARGS)
 Return the end base value of a temporal value. More...
 
PGDLLEXPORT Datum Temporal_enforce_typmod (PG_FUNCTION_ARGS)
 Enforce typmod information for temporal types. More...
 
PGDLLEXPORT Datum Temporal_eq (PG_FUNCTION_ARGS)
 Return true if the temporal values are equal. More...
 
static Datum temporal_ev_al_comp_ext (FunctionCallInfo fcinfo, bool(*func)(const Temporal *, Datum))
 Generic function for the temporal ever/always comparison operators. More...
 
PGDLLEXPORT Datum Temporal_ever_eq (PG_FUNCTION_ARGS)
 Return true if a temporal value is ever equal to a base value. More...
 
PGDLLEXPORT Datum Temporal_ever_ge (PG_FUNCTION_ARGS)
 Return true if a temporal value is ever greater than or equal to a base value. More...
 
PGDLLEXPORT Datum Temporal_ever_gt (PG_FUNCTION_ARGS)
 Return true if a temporal value is ever greater than a base value. More...
 
PGDLLEXPORT Datum Temporal_ever_le (PG_FUNCTION_ARGS)
 Return true if a temporal value is ever less than or equal to a base value. More...
 
PGDLLEXPORT Datum Temporal_ever_lt (PG_FUNCTION_ARGS)
 Return true if a temporal value is ever less than a base value. More...
 
PGDLLEXPORT Datum Temporal_ever_ne (PG_FUNCTION_ARGS)
 Return true if a temporal value is ever different from a base value. More...
 
PGDLLEXPORT Datum Temporal_ge (PG_FUNCTION_ARGS)
 Return true if the first temporal value is greater than or equal to the second one. More...
 
PGDLLEXPORT Datum Temporal_gt (PG_FUNCTION_ARGS)
 Return true if the first temporal value is greater than the second one. More...
 
PGDLLEXPORT Datum Temporal_hash (PG_FUNCTION_ARGS)
 Return the hash value of a temporal value. More...
 
PGDLLEXPORT Datum Temporal_in (PG_FUNCTION_ARGS)
 Generic input function for temporal types. More...
 
PGDLLEXPORT Datum Temporal_insert (PG_FUNCTION_ARGS)
 Insert the second temporal value into the first one. More...
 
PGDLLEXPORT Datum Temporal_instant_n (PG_FUNCTION_ARGS)
 Return the n-th instant of a temporal value. More...
 
PGDLLEXPORT Datum Temporal_instants (PG_FUNCTION_ARGS)
 Return the distinct instants of a temporal value as an array. More...
 
PGDLLEXPORT Datum Temporal_interpolation (PG_FUNCTION_ARGS)
 Return the string representation of the interpolation of a temporal value. More...
 
PGDLLEXPORT Datum Temporal_le (PG_FUNCTION_ARGS)
 Return true if the first temporal value is less than or equal to the second one. More...
 
PGDLLEXPORT Datum Temporal_lt (PG_FUNCTION_ARGS)
 Return true if the first temporal value is less than the second one. More...
 
PGDLLEXPORT Datum Temporal_max_instant (PG_FUNCTION_ARGS)
 Return a pointer to the instant with maximum base value of the temporal value. More...
 
PGDLLEXPORT Datum Temporal_max_value (PG_FUNCTION_ARGS)
 Return the maximum base value of a temporal value. More...
 
PGDLLEXPORT Datum Temporal_mem_size (PG_FUNCTION_ARGS)
 Return the memory size in bytes of a temporal value. More...
 
PGDLLEXPORT Datum Temporal_merge (PG_FUNCTION_ARGS)
 Merge the two temporal values. More...
 
PGDLLEXPORT Datum Temporal_merge_array (PG_FUNCTION_ARGS)
 Merge the array of temporal values. More...
 
PGDLLEXPORT Datum Temporal_min_instant (PG_FUNCTION_ARGS)
 Return a pointer to the instant with the minimum base value of the temporal value. More...
 
PGDLLEXPORT Datum Temporal_min_value (PG_FUNCTION_ARGS)
 Return the minimum base value of a temporal value. More...
 
PGDLLEXPORT Datum Temporal_minus_max (PG_FUNCTION_ARGS)
 Restrict a temporal value to the complement of its maximum base value. More...
 
PGDLLEXPORT Datum Temporal_minus_min (PG_FUNCTION_ARGS)
 Restrict a temporal value to the complement of its minimum base value. More...
 
PGDLLEXPORT Datum Temporal_minus_period (PG_FUNCTION_ARGS)
 Restrict a temporal value to the complement of a period. More...
 
PGDLLEXPORT Datum Temporal_minus_periodset (PG_FUNCTION_ARGS)
 Restrict a temporal value to the complement of a period set. More...
 
PGDLLEXPORT Datum Temporal_minus_timestamp (PG_FUNCTION_ARGS)
 Restrict a temporal value to the complement of a timestamp. More...
 
PGDLLEXPORT Datum Temporal_minus_timestampset (PG_FUNCTION_ARGS)
 Restrict a temporal value to the complement of a timestamp set. More...
 
PGDLLEXPORT Datum Temporal_minus_value (PG_FUNCTION_ARGS)
 Restrict a temporal value to the complement of a base value. More...
 
PGDLLEXPORT Datum Temporal_minus_values (PG_FUNCTION_ARGS)
 Restrict a temporal value to the complement of an array of base values. More...
 
PGDLLEXPORT Datum Temporal_ne (PG_FUNCTION_ARGS)
 Return true if the temporal values are different. More...
 
PGDLLEXPORT Datum Temporal_num_instants (PG_FUNCTION_ARGS)
 Return the number of distinct instants of a temporal value. More...
 
PGDLLEXPORT Datum Temporal_num_sequences (PG_FUNCTION_ARGS)
 Return the number of sequences of a temporal sequence (set) More...
 
PGDLLEXPORT Datum Temporal_num_timestamps (PG_FUNCTION_ARGS)
 Return the number of distinct timestamps of a temporal value. More...
 
PGDLLEXPORT Datum Temporal_out (PG_FUNCTION_ARGS)
 Generic output function for temporal types. More...
 
PGDLLEXPORT Datum Temporal_recv (PG_FUNCTION_ARGS)
 Generic receive function for temporal types. More...
 
Temporaltemporal_recv (StringInfo buf)
 Return a temporal value from its binary representation read from a buffer. More...
 
static Datum temporal_restrict_period_ext (FunctionCallInfo fcinfo, bool atfunc)
 
static Datum temporal_restrict_timestamp_ext (FunctionCallInfo fcinfo, bool atfunc)
 Restrict a temporal value to (the complement of) a timestamp. More...
 
static Datum temporal_restrict_value_ext (FunctionCallInfo fcinfo, bool atfunc)
 Restrict a temporal value to (the complement of) an array of base values. More...
 
static Datum temporal_restrict_values_ext (FunctionCallInfo fcinfo, bool atfunc)
 Restrict a temporal value to (the complement of) an array of base values. More...
 
PGDLLEXPORT Datum Temporal_segments (PG_FUNCTION_ARGS)
 Return the segments of a temporal sequence (set) as an array. More...
 
PGDLLEXPORT Datum Temporal_send (PG_FUNCTION_ARGS)
 
PGDLLEXPORT Datum Temporal_sequence_n (PG_FUNCTION_ARGS)
 Return the n-th sequence of a temporal sequence (set) More...
 
PGDLLEXPORT Datum Temporal_sequences (PG_FUNCTION_ARGS)
 Return the sequences of a temporal sequence (set) as an array. More...
 
PGDLLEXPORT Datum Temporal_shift (PG_FUNCTION_ARGS)
 Return a temporal value a shifted by an interval. More...
 
PGDLLEXPORT Datum Temporal_shift_tscale (PG_FUNCTION_ARGS)
 Return a temporal value shifted and scaled by the intervals. More...
 
PGDLLEXPORT Datum Temporal_start_instant (PG_FUNCTION_ARGS)
 Return the start instant of a temporal value. More...
 
PGDLLEXPORT Datum Temporal_start_sequence (PG_FUNCTION_ARGS)
 Return the start sequence of a temporal sequence (set) More...
 
PGDLLEXPORT Datum Temporal_start_timestamp (PG_FUNCTION_ARGS)
 Return the start timestamp of a temporal value. More...
 
PGDLLEXPORT Datum Temporal_start_value (PG_FUNCTION_ARGS)
 Return the start base value of a temporal value. More...
 
PGDLLEXPORT Datum Temporal_subtype (PG_FUNCTION_ARGS)
 Return the string representation of the subtype of a temporal value. More...
 
PGDLLEXPORT Datum Temporal_time (PG_FUNCTION_ARGS)
 Return the time on which a temporal value is defined as a period set. More...
 
PGDLLEXPORT Datum Temporal_timestamp_n (PG_FUNCTION_ARGS)
 Return the n-th distinct timestamp of a temporal value. More...
 
PGDLLEXPORT Datum Temporal_timestamps (PG_FUNCTION_ARGS)
 Return the distinct timestamps of a temporal value as an array. More...
 
PGDLLEXPORT Datum Temporal_to_period (PG_FUNCTION_ARGS)
 Return the bounding period on which a temporal value is defined. More...
 
PGDLLEXPORT Datum Temporal_to_tcontseq (PG_FUNCTION_ARGS)
 Transform a temporal value into a temporal sequence. More...
 
PGDLLEXPORT Datum Temporal_to_tdiscseq (PG_FUNCTION_ARGS)
 Transform a temporal value into a temporal sequence with discrete interpolation. More...
 
PGDLLEXPORT Datum Temporal_to_tinstant (PG_FUNCTION_ARGS)
 Transform a temporal value into a temporal instant. More...
 
PGDLLEXPORT Datum Temporal_to_tsequenceset (PG_FUNCTION_ARGS)
 Transform a temporal value into a temporal sequence set. More...
 
PGDLLEXPORT Datum Temporal_tprecision (PG_FUNCTION_ARGS)
 Set the precision of a temporal value according to period buckets. More...
 
PGDLLEXPORT Datum Temporal_tsample (PG_FUNCTION_ARGS)
 Sample a temporal value according to period buckets. More...
 
PGDLLEXPORT Datum Temporal_tscale (PG_FUNCTION_ARGS)
 Return a temporal value scaled by an interval. More...
 
PGDLLEXPORT Datum Temporal_typmod_in (PG_FUNCTION_ARGS)
 Input typmod information for temporal types. More...
 
PGDLLEXPORT Datum Temporal_typmod_out (PG_FUNCTION_ARGS)
 Output typmod information for temporal types. More...
 
PGDLLEXPORT Datum Temporal_unnest (PG_FUNCTION_ARGS)
 Generate a list of values and associated period sets. More...
 
TempUnnestStatetemporal_unnest_state_make (const Temporal *temp, Datum *values, int count)
 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...
 
PGDLLEXPORT Datum Temporal_update (PG_FUNCTION_ARGS)
 Update the first temporal value with the second one. More...
 
static Temporaltemporal_valid_typmod (Temporal *temp, int32_t typmod)
 Ensure that the temporal type of a temporal value corresponds to the typmod. More...
 
PGDLLEXPORT Datum Temporal_value_at_timestamp (PG_FUNCTION_ARGS)
 Return the base value of a temporal value at the timestamp. More...
 
PGDLLEXPORT Datum Temporal_values (PG_FUNCTION_ARGS)
 Return the base values of a temporal value as an array. More...
 
void temporal_write (const Temporal *temp, StringInfo buf)
 Write the binary representation of a temporal value into a buffer. More...
 
PGDLLEXPORT Datum Tempstep_to_templinear (PG_FUNCTION_ARGS)
 Transform a temporal value with continuous base type from step to linear interpolation. More...
 
bool tempsubtype_from_string (const char *str, int16 *subtype)
 Return the enum value corresponding to the string representation of the concrete subtype of a temporal type. More...
 
const char * tempsubtype_name (int16 subtype)
 Return the string representation of the subtype of the temporal type corresponding to the enum value. More...
 
PGDLLEXPORT Datum Tfloat_spanset (PG_FUNCTION_ARGS)
 Return the base values of a temporal float as an array of spans. More...
 
PGDLLEXPORT Datum Tfloat_to_tint (PG_FUNCTION_ARGS)
 Cast a temporal float as a temporal integer. More...
 
uint32_t time_max_header_size (void)
 Return the size in bytes to read from toast to get the basic information from a variable-length time type: Time struct (i.e., Set or SpanSet) and bounding box size. More...
 
Datum timestamp_mi (PG_FUNCTION_ARGS)
 Basic functions for temporal types of any subtype. More...
 
PGDLLEXPORT Datum Tinstant_constructor (PG_FUNCTION_ARGS)
 Construct a temporal instant from the arguments. More...
 
PGDLLEXPORT Datum Tinstant_get_value (PG_FUNCTION_ARGS)
 Return the base value of a temporal instant. More...
 
TInstanttinstant_recv (StringInfo buf, meosType temptype)
 Return a temporal instant from its binary representation read from a buffer. More...
 
PGDLLEXPORT Datum Tinstant_timestamp (PG_FUNCTION_ARGS)
 Return the timestamp of a temporal instant. More...
 
void tinstant_write (const TInstant *inst, StringInfo buf)
 Write the binary representation of a temporal instant into a buffer. More...
 
PGDLLEXPORT Datum Tint_to_tfloat (PG_FUNCTION_ARGS)
 Cast a temporal integer as a temporal float. More...
 
PGDLLEXPORT Datum Tlinearseq_constructor (PG_FUNCTION_ARGS)
 Construct a temporal sequence with linear interpolation from the array of temporal instants. More...
 
PGDLLEXPORT Datum Tlinearseqset_constructor_gaps (PG_FUNCTION_ARGS)
 Construct a temporal sequence set with linear or step interpolation from the array of temporal instants. More...
 
PGDLLEXPORT Datum Tnumber_at_span (PG_FUNCTION_ARGS)
 Restrict a temporal value to a span of base values. More...
 
PGDLLEXPORT Datum Tnumber_at_spanset (PG_FUNCTION_ARGS)
 Restrict a temporal value to an array of spans of base values. More...
 
PGDLLEXPORT Datum Tnumber_at_tbox (PG_FUNCTION_ARGS)
 Restrict a temporal value to a temporal box. More...
 
PGDLLEXPORT Datum Tnumber_integral (PG_FUNCTION_ARGS)
 Return the integral (area under the curve) of a temporal number. More...
 
PGDLLEXPORT Datum Tnumber_minus_span (PG_FUNCTION_ARGS)
 Restrict a temporal value to the complement of a span of base values. More...
 
PGDLLEXPORT Datum Tnumber_minus_spanset (PG_FUNCTION_ARGS)
 Restrict a temporal value to the complement of a span set. More...
 
PGDLLEXPORT Datum Tnumber_minus_tbox (PG_FUNCTION_ARGS)
 Restrict a temporal value to the complement of a temporal box. More...
 
static Datum tnumber_restrict_span_ext (FunctionCallInfo fcinfo, bool atfunc)
 
static Datum tnumber_restrict_spanset_ext (FunctionCallInfo fcinfo, bool atfunc)
 Restrict a temporal value to (the complement of) a span set of base values. More...
 
static Datum tnumber_restrict_tbox_ext (FunctionCallInfo fcinfo, bool atfunc)
 Restrict a temporal value to (the complement of) a temporal box. More...
 
PGDLLEXPORT Datum Tnumber_to_span (PG_FUNCTION_ARGS)
 Return the value span of a temporal integer. More...
 
PGDLLEXPORT Datum Tnumber_to_tbox (PG_FUNCTION_ARGS)
 Return the bounding box of a temporal number. More...
 
PGDLLEXPORT Datum Tnumber_twavg (PG_FUNCTION_ARGS)
 Return the time-weighted average of a temporal number. More...
 
PGDLLEXPORT Datum Tscalarseqset_constructor_gaps (PG_FUNCTION_ARGS)
 Construct a temporal sequence set with step interpolation from the array of temporal instants with scalar base type, that is, a base type that does not have distance. More...
 
static Datum tsequence_constructor_ext (FunctionCallInfo fcinfo, bool get_bounds, bool get_linear)
 Construct a temporal sequence from the array of temporal instants. More...
 
PGDLLEXPORT Datum Tsequence_from_base_time (PG_FUNCTION_ARGS)
 Construct a temporal sequence from a base value and a period. 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...
 
PGDLLEXPORT Datum Tsequenceset_constructor (PG_FUNCTION_ARGS)
 Construct a temporal sequence set from the array of temporal sequences. More...
 
Datum tsequenceset_constructor_gaps_ext (FunctionCallInfo fcinfo, bool get_linear, bool get_dist)
 Construct a temporal sequence set from the array of temporal instants that are split in various sequences if two consecutive instants have a distance and/or temporal gap greater than the arguments. More...
 
PGDLLEXPORT Datum Tsequenceset_from_base_time (PG_FUNCTION_ARGS)
 Construct a temporal sequence set from from a base value and a timestamp set. More...
 
PGDLLEXPORT Datum Tstepseq_constructor (PG_FUNCTION_ARGS)
 Construct a temporal sequence with step interpolation from the array of temporal instants. More...
 
PGDLLEXPORT Datum Tstepseqset_constructor_gaps (PG_FUNCTION_ARGS)
 Construct a temporal sequence set with step interpolation from the array of temporal instants. More...
 

Variables

FunctionCallInfo _FCINFO
 Global variable that saves the PostgreSQL fcinfo. More...
 
 PG_MODULE_MAGIC
 
struct tempsubtype_struct tempsubtype_struct_array []
 Array storing the mapping between the string representation of the subtypes of temporal types and the corresponding enum value. More...
 
static char * tempsubtypeName []
 Array storing the string representation of the concrete subtypes of temporal types. More...