MobilityDB  1.0
Functions
period.c File Reference

Basic routines for time periods composed of two TimestampTz values and two Boolean values stating whether the bounds are inclusive or not. More...

#include "general/period.h"
#include <assert.h>
#include <access/hash.h>
#include <libpq/pqformat.h>
#include <utils/builtins.h>
#include "general/periodset.h"
#include "general/timeops.h"
#include "general/temporal.h"
#include "general/temporal_util.h"
#include "general/temporal_parser.h"
#include "general/rangetypes_ext.h"
Include dependency graph for period.c:

Functions

static char * period_deparse (bool lower_inc, bool upper_inc, const char *lbound_str, const char *ubound_str)
 Convert the deserialized period to text form. More...
 
void period_deserialize (const Period *p, PeriodBound *lower, PeriodBound *upper)
 Deconstruct the period. More...
 
int period_cmp_bounds (const PeriodBound *b1, const PeriodBound *b2)
 Compare two period boundary points, returning <0, 0, or >0 according to whether b1 is less than, equal to, or greater than b2. More...
 
int period_bound_qsort_cmp (const void *a1, const void *a2)
 Comparison function for sorting period bounds. More...
 
Periodperiod_make (TimestampTz lower, TimestampTz upper, bool lower_inc, bool upper_inc)
 Construct a period from the bounds. More...
 
void period_set (Period *p, TimestampTz lower, TimestampTz upper, bool lower_inc, bool upper_inc)
 Set the period from the argument values. More...
 
Periodperiod_copy (const Period *p)
 Returns a copy of the period. More...
 
float8 period_to_secs (TimestampTz v1, TimestampTz v2)
 Returns the number of seconds of the period as a float8 value. More...
 
Period ** periodarr_normalize (Period **periods, int count, int *newcount)
 Normalize an array of periods. More...
 
Periodperiod_super_union (const Period *p1, const Period *p2)
 Returns the smallest period that contains p1 and p2. More...
 
void period_expand (Period *p1, const Period *p2)
 Expand the first period with the second one. More...
 
PGDLLEXPORT Datum period_in (PG_FUNCTION_ARGS)
 Input function for periods. More...
 
static void unquote (char *str)
 Removs the quotes from the string representation of a period. More...
 
char * period_to_string (const Period *p)
 Returns the string representation of the period. More...
 
PGDLLEXPORT Datum period_out (PG_FUNCTION_ARGS)
 Output function for periods. More...
 
void period_write (const Period *p, StringInfo buf)
 Send function for periods (internal function) More...
 
PGDLLEXPORT Datum period_send (PG_FUNCTION_ARGS)
 Send function for periods. More...
 
Periodperiod_read (StringInfo buf)
 Receive function for periods (internal function) More...
 
PGDLLEXPORT Datum period_recv (PG_FUNCTION_ARGS)
 Receive function for periods. More...
 
PGDLLEXPORT Datum period_constructor2 (PG_FUNCTION_ARGS)
 Construct a period from the two arguments. More...
 
PGDLLEXPORT Datum period_constructor4 (PG_FUNCTION_ARGS)
 Construct a period from the four arguments. More...
 
PGDLLEXPORT Datum timestamp_to_period (PG_FUNCTION_ARGS)
 Cast the timestamp value as a period. More...
 
PGDLLEXPORT Datum period_to_tstzrange (PG_FUNCTION_ARGS)
 Convert the period as a tstzrange value. More...
 
PGDLLEXPORT Datum tstzrange_to_period (PG_FUNCTION_ARGS)
 Convert the tstzrange value as a period. More...
 
PGDLLEXPORT Datum period_lower (PG_FUNCTION_ARGS)
 Returns the lower bound value. More...
 
PGDLLEXPORT Datum period_upper (PG_FUNCTION_ARGS)
 Returns the upper bound value. More...
 
PGDLLEXPORT Datum period_lower_inc (PG_FUNCTION_ARGS)
 Returns true if the lower bound value is inclusive. More...
 
PGDLLEXPORT Datum period_upper_inc (PG_FUNCTION_ARGS)
 Returns true if the upper bound value is inclusive. More...
 
Periodperiod_shift_internal (const Period *p, const Interval *start)
 Shift the period by the interval (internal function) More...
 
PGDLLEXPORT Datum period_shift (PG_FUNCTION_ARGS)
 Shift the period by the interval. More...
 
void period_shift_tscale (Period *result, const Interval *start, const Interval *duration)
 Shift and/or scale the period by the two intervals (internal function) More...
 
Interval * period_duration_internal (const Period *p)
 Returns the duration of the period (internal function) More...
 
PGDLLEXPORT Datum period_duration (PG_FUNCTION_ARGS)
 Returns the duration of the period. More...
 
bool period_eq_internal (const Period *p1, const Period *p2)
 Returns true if the first period is equal to the second one (internal function) More...
 
PGDLLEXPORT Datum period_eq (PG_FUNCTION_ARGS)
 Returns true if the first period is equal to the second one. More...
 
bool period_ne_internal (const Period *p1, const Period *p2)
 Returns true if the first period is different from the second one (internal function) More...
 
PGDLLEXPORT Datum period_ne (PG_FUNCTION_ARGS)
 Returns true if the first period is different from the second one. More...
 
int period_cmp_internal (const Period *p1, const Period *p2)
 Returns -1, 0, or 1 depending on whether the first period is less than, equal, or greater than the second one (internal function) More...
 
PGDLLEXPORT Datum period_cmp (PG_FUNCTION_ARGS)
 Returns -1, 0, or 1 depending on whether the first period is less than, equal, or greater than the second one. More...
 
bool period_lt_internal (const Period *p1, const Period *p2)
 Returns true if the first period is less than the second one (internal function) More...
 
PGDLLEXPORT Datum period_lt (PG_FUNCTION_ARGS)
 Returns true if the first period is less than the second one. More...
 
bool period_le_internal (const Period *p1, const Period *p2)
 Returns true if the first period is less than or equal to the second one (internal function) More...
 
PGDLLEXPORT Datum period_le (PG_FUNCTION_ARGS)
 Returns true if the first period is less than or equal to the second one. More...
 
bool period_ge_internal (const Period *p1, const Period *p2)
 Returns true if the first period is greater than or equal to the second one (internal function) More...
 
PGDLLEXPORT Datum period_ge (PG_FUNCTION_ARGS)
 Returns true if the first period is greater than or equal to the second one. More...
 
bool period_gt_internal (const Period *p1, const Period *p2)
 Returns true if the first period is greater than the second one (internal function) More...
 
PGDLLEXPORT Datum period_gt (PG_FUNCTION_ARGS)
 Returns true if the first period is greater than the second one. More...
 
PGDLLEXPORT Datum period_hash (PG_FUNCTION_ARGS)
 

Detailed Description

Basic routines for time periods composed of two TimestampTz values and two Boolean values stating whether the bounds are inclusive or not.