PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <sys/socket.h>
#include "access/brin.h"
#include "access/brin_internal.h"
#include "access/brin_tuple.h"
#include "access/genam.h"
#include "access/htup_details.h"
#include "access/reloptions.h"
#include "access/stratnum.h"
#include "catalog/pg_am.h"
#include "catalog/pg_amop.h"
#include "catalog/pg_type.h"
#include "utils/array.h"
#include "utils/builtins.h"
#include "utils/date.h"
#include "utils/datum.h"
#include "utils/float.h"
#include "utils/inet.h"
#include "utils/lsyscache.h"
#include "utils/memutils.h"
#include "utils/pg_lsn.h"
#include "utils/rel.h"
#include "utils/syscache.h"
#include "utils/timestamp.h"
#include "utils/uuid.h"
Go to the source code of this file.
Data Structures | |
struct | MinmaxMultiOpaque |
struct | MinMaxMultiOptions |
struct | Ranges |
struct | SerializedRanges |
struct | ExpandedRange |
struct | DistanceValue |
struct | compare_context |
Macros | |
#define | MINMAX_MAX_PROCNUMS 1 /* maximum support procs we need */ |
#define | PROCNUM_DISTANCE 11 /* required, distance between values */ |
#define | PROCNUM_BASE 11 |
#define | MINMAX_BUFFER_FACTOR 10 |
#define | MINMAX_BUFFER_MIN 256 |
#define | MINMAX_BUFFER_MAX 8192 |
#define | MINMAX_BUFFER_LOAD_FACTOR 0.5 |
#define | MINMAX_MULTI_DEFAULT_VALUES_PER_PAGE 32 |
#define | MinMaxMultiGetValuesPerRange(opts) |
#define | SAMESIGN(a, b) (((a) < 0) == ((b) < 0)) |
Typedefs | |
typedef struct MinmaxMultiOpaque | MinmaxMultiOpaque |
typedef struct MinMaxMultiOptions | MinMaxMultiOptions |
typedef struct Ranges | Ranges |
typedef struct SerializedRanges | SerializedRanges |
typedef struct ExpandedRange | ExpandedRange |
typedef struct DistanceValue | DistanceValue |
typedef struct compare_context | compare_context |
#define MINMAX_BUFFER_FACTOR 10 |
Definition at line 106 of file brin_minmax_multi.c.
#define MINMAX_BUFFER_LOAD_FACTOR 0.5 |
Definition at line 109 of file brin_minmax_multi.c.
#define MINMAX_BUFFER_MAX 8192 |
Definition at line 108 of file brin_minmax_multi.c.
#define MINMAX_BUFFER_MIN 256 |
Definition at line 107 of file brin_minmax_multi.c.
#define MINMAX_MAX_PROCNUMS 1 /* maximum support procs we need */ |
Definition at line 92 of file brin_minmax_multi.c.
#define MINMAX_MULTI_DEFAULT_VALUES_PER_PAGE 32 |
Definition at line 128 of file brin_minmax_multi.c.
#define MinMaxMultiGetValuesPerRange | ( | opts | ) |
Definition at line 130 of file brin_minmax_multi.c.
#define PROCNUM_BASE 11 |
Definition at line 99 of file brin_minmax_multi.c.
#define PROCNUM_DISTANCE 11 /* required, distance between values */ |
Definition at line 93 of file brin_minmax_multi.c.
Definition at line 135 of file brin_minmax_multi.c.
typedef struct compare_context compare_context |
typedef struct DistanceValue DistanceValue |
typedef struct ExpandedRange ExpandedRange |
typedef struct MinmaxMultiOpaque MinmaxMultiOpaque |
typedef struct MinMaxMultiOptions MinMaxMultiOptions |
typedef struct SerializedRanges SerializedRanges |
|
static |
Definition at line 427 of file brin_minmax_multi.c.
References Assert, BTEqualStrategyNumber, BTLessStrategyNumber, DatumGetBool(), FunctionCall2Coll(), i, ExpandedRange::maxval, minmax_multi_get_strategy_procinfo(), and ExpandedRange::minval.
Referenced by brin_minmax_multi_union(), and ensure_free_space_in_buffer().
Definition at line 297 of file brin_minmax_multi.c.
References Assert, bsearch_arg(), Ranges::cmp, compare_context::cmpFn, Ranges::colloid, compare_context::colloid, compare_values(), DatumGetBool(), FunctionCall2Coll(), i, InvalidOid, Ranges::maxvalues, Ranges::nranges, Ranges::nsorted, Ranges::nvalues, start, Ranges::typid, value, and Ranges::values.
Referenced by compactify_ranges(), ensure_free_space_in_buffer(), range_add_value(), and range_deduplicate_values().
Datum brin_minmax_multi_add_value | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2413 of file brin_minmax_multi.c.
References Assert, Ranges::attno, BrinDesc::bd_index, BrinDesc::bd_tupdesc, brin_minmax_multi_get_values(), brin_minmax_multi_serialize(), brin_range_deserialize(), BrinGetPagesPerRange, BTLessStrategyNumber, BrinValues::bv_allnulls, BrinValues::bv_attno, BrinValues::bv_context, BrinValues::bv_mem_value, BrinValues::bv_serialize, BrinValues::bv_values, Ranges::cmp, Ranges::colloid, DatumGetPointer(), Max, MaxHeapTuplesPerPage, SerializedRanges::maxvalues, MemoryContextSwitchTo(), Min, MINMAX_BUFFER_FACTOR, MINMAX_BUFFER_MAX, MINMAX_BUFFER_MIN, minmax_multi_get_strategy_procinfo(), minmax_multi_init(), newval, opts, PG_DETOAST_DATUM, PG_GET_COLLATION, PG_GET_OPCLASS_OPTIONS, PG_GETARG_DATUM, PG_GETARG_POINTER, PG_RETURN_BOOL, PG_USED_FOR_ASSERTS_ONLY, PointerGetDatum(), range_add_value(), Ranges::target_maxvalues, TupleDescAttr, and Ranges::typid.
Datum brin_minmax_multi_consistent | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2550 of file brin_minmax_multi.c.
References Assert, brin_range_deserialize(), BTEqualStrategyNumber, BTGreaterEqualStrategyNumber, BTGreaterStrategyNumber, BTLessEqualStrategyNumber, BTLessStrategyNumber, BrinValues::bv_attno, BrinValues::bv_values, DatumGetBool(), elog, ERROR, FunctionCall2Coll(), i, sort-test::key, SerializedRanges::maxvalues, minmax_multi_get_strategy_procinfo(), Ranges::nranges, Ranges::nvalues, PG_DETOAST_DATUM, PG_GET_COLLATION, PG_GETARG_INT32, PG_GETARG_POINTER, PG_RETURN_BOOL, SK_ISNULL, val, value, and Ranges::values.
Datum brin_minmax_multi_distance_date | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2081 of file brin_minmax_multi.c.
References Assert, PG_GETARG_DATEADT, and PG_RETURN_FLOAT8.
Datum brin_minmax_multi_distance_float4 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1884 of file brin_minmax_multi.c.
References a1, a2, Assert, get_float8_infinity(), PG_GETARG_FLOAT4, and PG_RETURN_FLOAT8.
Datum brin_minmax_multi_distance_float8 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1910 of file brin_minmax_multi.c.
References a1, a2, Assert, get_float8_infinity(), PG_GETARG_FLOAT8, and PG_RETURN_FLOAT8.
Datum brin_minmax_multi_distance_inet | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2298 of file brin_minmax_multi.c.
References a, Assert, b, i, ip_addr, ip_addrsize, ip_bits, ip_family, len, Max, palloc(), pfree(), PG_GETARG_INET_PP, and PG_RETURN_FLOAT8.
Datum brin_minmax_multi_distance_int2 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1936 of file brin_minmax_multi.c.
References a1, a2, Assert, PG_GETARG_INT16, and PG_RETURN_FLOAT8.
Datum brin_minmax_multi_distance_int4 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1954 of file brin_minmax_multi.c.
References a1, a2, Assert, PG_GETARG_INT32, and PG_RETURN_FLOAT8.
Datum brin_minmax_multi_distance_int8 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1972 of file brin_minmax_multi.c.
References a1, a2, Assert, PG_GETARG_INT64, and PG_RETURN_FLOAT8.
Datum brin_minmax_multi_distance_interval | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2156 of file brin_minmax_multi.c.
References Assert, Interval::day, days, Interval::month, PG_GETARG_INTERVAL_P, PG_RETURN_FLOAT8, Interval::time, and USECS_PER_DAY.
Datum brin_minmax_multi_distance_macaddr | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2213 of file brin_minmax_multi.c.
References a, Assert, b, PG_GETARG_MACADDR_P, and PG_RETURN_FLOAT8.
Datum brin_minmax_multi_distance_macaddr8 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2250 of file brin_minmax_multi.c.
References a, Assert, b, PG_GETARG_MACADDR8_P, and PG_RETURN_FLOAT8.
Datum brin_minmax_multi_distance_numeric | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2022 of file brin_minmax_multi.c.
References a1, a2, Assert, DatumGetBool(), DirectFunctionCall1, DirectFunctionCall2, numeric_float8(), numeric_le(), numeric_sub(), PG_GETARG_DATUM, and PG_RETURN_FLOAT8.
Datum brin_minmax_multi_distance_pg_lsn | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2192 of file brin_minmax_multi.c.
References Assert, PG_GETARG_LSN, and PG_RETURN_FLOAT8.
Datum brin_minmax_multi_distance_tid | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1991 of file brin_minmax_multi.c.
References Assert, ItemPointerCompare(), ItemPointerGetBlockNumberNoCheck(), ItemPointerGetOffsetNumberNoCheck(), MaxHeapTuplesPerPage, PG_GETARG_DATUM, and PG_RETURN_FLOAT8.
Datum brin_minmax_multi_distance_time | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2100 of file brin_minmax_multi.c.
References Assert, PG_GETARG_TIMEADT, and PG_RETURN_FLOAT8.
Datum brin_minmax_multi_distance_timestamp | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2138 of file brin_minmax_multi.c.
References Assert, PG_GETARG_TIMESTAMP, and PG_RETURN_FLOAT8.
Datum brin_minmax_multi_distance_timetz | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2120 of file brin_minmax_multi.c.
References Assert, PG_GETARG_TIMETZADT_P, PG_RETURN_FLOAT8, TimeTzADT::time, USECS_PER_SEC, and TimeTzADT::zone.
Datum brin_minmax_multi_distance_uuid | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2048 of file brin_minmax_multi.c.
References a1, a2, Assert, pg_uuid_t::data, DatumGetBool(), DatumGetUUIDP(), DirectFunctionCall2, i, PG_GETARG_DATUM, PG_RETURN_FLOAT8, uuid_le(), and UUID_LEN.
|
static |
Definition at line 2400 of file brin_minmax_multi.c.
References MinMaxMultiGetValuesPerRange, and opts.
Referenced by brin_minmax_multi_add_value().
Datum brin_minmax_multi_opcinfo | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1860 of file brin_minmax_multi.c.
References lookup_type_cache(), MAXALIGN, BrinOpcInfo::oi_nstored, BrinOpcInfo::oi_opaque, BrinOpcInfo::oi_regular_nulls, BrinOpcInfo::oi_typcache, palloc0(), PG_RETURN_POINTER, and SizeofBrinOpcInfo.
Datum brin_minmax_multi_options | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2963 of file brin_minmax_multi.c.
References add_local_int_reloption(), init_local_reloptions(), MINMAX_MULTI_DEFAULT_VALUES_PER_PAGE, PG_GETARG_POINTER, and PG_RETURN_VOID.
Definition at line 2381 of file brin_minmax_multi.c.
References Assert, brin_range_serialize(), compactify_ranges(), DatumGetPointer(), Ranges::nsorted, Ranges::nvalues, PointerGetDatum(), and Ranges::target_maxvalues.
Referenced by brin_minmax_multi_add_value().
Datum brin_minmax_multi_summary_in | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2985 of file brin_minmax_multi.c.
References ereport, errcode(), errmsg(), ERROR, and PG_RETURN_VOID.
Datum brin_minmax_multi_summary_out | ( | PG_FUNCTION_ARGS | ) |
Definition at line 3007 of file brin_minmax_multi.c.
References a, accumArrayResult(), appendStringInfo(), appendStringInfoChar(), b, brin_range_deserialize(), buf, cstring_to_text(), cstring_to_text_with_len(), CurrentMemoryContext, DatumGetCString(), fmgr_info(), FunctionCall1, getTypeOutputInfo(), i, idx(), initStringInfo(), makeArrayResult(), Ranges::maxvalues, SerializedRanges::maxvalues, Ranges::nranges, Ranges::nvalues, OidOutputFunctionCall(), OutputFunctionCall(), PG_DETOAST_DATUM, PG_GETARG_DATUM, PG_RETURN_CSTRING, PointerGetDatum(), str, SerializedRanges::typid, val, and Ranges::values.
Datum brin_minmax_multi_summary_recv | ( | PG_FUNCTION_ARGS | ) |
Definition at line 3126 of file brin_minmax_multi.c.
References ereport, errcode(), errmsg(), ERROR, and PG_RETURN_VOID.
Datum brin_minmax_multi_summary_send | ( | PG_FUNCTION_ARGS | ) |
Datum brin_minmax_multi_union | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2736 of file brin_minmax_multi.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert, AssertCheckExpandedRanges(), BrinDesc::bd_tupdesc, brin_range_deserialize(), brin_range_serialize(), BTLessStrategyNumber, build_distances(), BrinValues::bv_allnulls, BrinValues::bv_attno, BrinValues::bv_values, CurrentMemoryContext, fill_expanded_ranges(), Ranges::maxvalues, SerializedRanges::maxvalues, MemoryContextDelete(), MemoryContextSwitchTo(), merge_overlapping_ranges(), minmax_multi_get_procinfo(), minmax_multi_get_strategy_procinfo(), Ranges::nranges, Ranges::nvalues, palloc0(), pfree(), PG_DETOAST_DATUM, PG_GET_COLLATION, PG_GETARG_POINTER, PG_RETURN_VOID, PointerGetDatum(), PROCNUM_DISTANCE, reduce_expanded_ranges(), sort_expanded_ranges(), store_expanded_ranges(), and TupleDescAttr.
|
static |
Definition at line 722 of file brin_minmax_multi.c.
References Assert, SerializedRanges::data, fetch_att(), get_typbyval(), get_typlen(), i, MAXALIGN, SerializedRanges::maxvalues, minmax_multi_init(), SerializedRanges::nranges, cvec::nranges, SerializedRanges::nvalues, palloc(), PointerGetDatum(), range(), SerializedRanges::typid, and VARSIZE_ANY.
Referenced by brin_minmax_multi_add_value(), brin_minmax_multi_consistent(), brin_minmax_multi_summary_out(), and brin_minmax_multi_union().
|
static |
Definition at line 577 of file brin_minmax_multi.c.
References Assert, SerializedRanges::data, data, DatumGetCString(), DatumGetPointer(), get_typbyval(), get_typlen(), i, len, SerializedRanges::maxvalues, SerializedRanges::nranges, cvec::nranges, SerializedRanges::nvalues, palloc0(), range(), range_deduplicate_values(), SET_VARSIZE, store_att_byval(), SerializedRanges::typid, and VARSIZE_ANY.
Referenced by brin_minmax_multi_serialize(), and brin_minmax_multi_union().
|
static |
Definition at line 1330 of file brin_minmax_multi.c.
References a1, a2, Assert, compare_distances(), DatumGetFloat8(), FunctionCall2Coll(), i, DistanceValue::index, ExpandedRange::maxval, ExpandedRange::minval, palloc0(), qsort, and DistanceValue::value.
Referenced by brin_minmax_multi_union(), compactify_ranges(), and ensure_free_space_in_buffer().
|
static |
Definition at line 1387 of file brin_minmax_multi.c.
References cmp(), fill_expanded_ranges(), Ranges::nranges, Ranges::nvalues, palloc0(), and sort_expanded_ranges().
Referenced by compactify_ranges(), and ensure_free_space_in_buffer().
Definition at line 1789 of file brin_minmax_multi.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert, AssertCheckRanges(), Ranges::attno, BTLessStrategyNumber, build_distances(), build_expanded_ranges(), Ranges::colloid, CurrentMemoryContext, MemoryContextDelete(), MemoryContextSwitchTo(), minmax_multi_get_procinfo(), minmax_multi_get_strategy_procinfo(), Ranges::nranges, Ranges::nsorted, Ranges::nvalues, PROCNUM_DISTANCE, reduce_expanded_ranges(), store_expanded_ranges(), and Ranges::typid.
Referenced by brin_minmax_multi_serialize().
|
static |
Definition at line 1306 of file brin_minmax_multi.c.
References a, b, and DistanceValue::value.
Referenced by build_distances().
|
static |
Definition at line 859 of file brin_minmax_multi.c.
References a, arg, b, compare_context::cmpFn, compare_context::colloid, DatumGetBool(), FunctionCall2Coll(), ExpandedRange::maxval, and ExpandedRange::minval.
Referenced by sort_expanded_ranges().
|
static |
Definition at line 897 of file brin_minmax_multi.c.
References a, arg, b, compare_context::cmpFn, compare_context::colloid, DatumGetBool(), and FunctionCall2Coll().
Referenced by AssertCheckRanges(), range_contains_value(), range_deduplicate_values(), and reduce_expanded_ranges().
|
static |
Definition at line 1602 of file brin_minmax_multi.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert, AssertCheckExpandedRanges(), AssertCheckRanges(), BTLessStrategyNumber, build_distances(), build_expanded_ranges(), CurrentMemoryContext, MemoryContextDelete(), MemoryContextSwitchTo(), MINMAX_BUFFER_LOAD_FACTOR, minmax_multi_get_procinfo(), minmax_multi_get_strategy_procinfo(), cvec::nranges, PROCNUM_DISTANCE, range(), range_deduplicate_values(), reduce_expanded_ranges(), and store_expanded_ranges().
Referenced by range_add_value().
|
static |
Definition at line 1135 of file brin_minmax_multi.c.
References Assert, ExpandedRange::collapsed, i, idx(), ExpandedRange::maxval, ExpandedRange::minval, Ranges::nranges, Ranges::nvalues, and Ranges::values.
Referenced by brin_minmax_multi_union(), and build_expanded_ranges().
|
static |
Definition at line 922 of file brin_minmax_multi.c.
References BTGreaterStrategyNumber, BTLessStrategyNumber, DatumGetBool(), FunctionCall2Coll(), minmax_multi_get_strategy_procinfo(), newval, Ranges::nranges, start, and Ranges::values.
Referenced by range_contains_value().
|
static |
Definition at line 1232 of file brin_minmax_multi.c.
References cmp(), ExpandedRange::collapsed, DatumGetBool(), FunctionCall2Coll(), idx(), and ExpandedRange::maxval.
Referenced by brin_minmax_multi_union().
|
static |
Definition at line 2864 of file brin_minmax_multi.c.
References BrinDesc::bd_context, BrinDesc::bd_index, BrinDesc::bd_info, MinmaxMultiOpaque::extra_proc_missing, MinmaxMultiOpaque::extra_procinfos, fmgr_info_copy(), FmgrInfo::fn_oid, if(), index_getprocid(), index_getprocinfo(), InvalidOid, BrinOpcInfo::oi_opaque, PROCNUM_BASE, and RegProcedureIsValid.
Referenced by brin_minmax_multi_union(), compactify_ranges(), and ensure_free_space_in_buffer().
|
static |
Definition at line 2908 of file brin_minmax_multi.c.
References Assert, BrinDesc::bd_context, BrinDesc::bd_index, BrinDesc::bd_info, BrinDesc::bd_tupdesc, BTMaxStrategyNumber, MinmaxMultiOpaque::cached_subtype, DatumGetObjectId(), elog, ERROR, fmgr_info_cxt(), FmgrInfo::fn_oid, get_opcode(), HeapTupleIsValid, i, if(), Int16GetDatum(), InvalidOid, ObjectIdGetDatum(), BrinOpcInfo::oi_opaque, oprid(), RelationData::rd_opfamily, RegProcedureIsValid, ReleaseSysCache(), SearchSysCache4(), MinmaxMultiOpaque::strategy_procinfos, SysCacheGetAttrNotNull(), and TupleDescAttr.
Referenced by AssertCheckExpandedRanges(), brin_minmax_multi_add_value(), brin_minmax_multi_consistent(), brin_minmax_multi_union(), compactify_ranges(), ensure_free_space_in_buffer(), has_matching_range(), range_add_value(), and range_contains_value().
|
static |
Definition at line 487 of file brin_minmax_multi.c.
References Assert, len, Ranges::maxvalues, palloc0(), and values.
Referenced by brin_minmax_multi_add_value(), and brin_range_deserialize().
|
static |
Definition at line 1703 of file brin_minmax_multi.c.
References Assert, AssertCheckRanges(), BTLessStrategyNumber, datumCopy(), ensure_free_space_in_buffer(), minmax_multi_get_strategy_procinfo(), newval, Ranges::nranges, Ranges::nsorted, Ranges::nvalues, range_contains_value(), and Ranges::values.
Referenced by brin_minmax_multi_add_value().
|
static |
Definition at line 1046 of file brin_minmax_multi.c.
References bsearch_arg(), BTEqualStrategyNumber, Ranges::cmp, compare_context::cmpFn, Ranges::colloid, compare_context::colloid, compare_values(), DatumGetBool(), FunctionCall2Coll(), has_matching_range(), i, minmax_multi_get_strategy_procinfo(), newval, Ranges::nranges, Ranges::nsorted, Ranges::nvalues, and Ranges::values.
Referenced by range_add_value().
|
static |
Definition at line 517 of file brin_minmax_multi.c.
References AssertCheckRanges(), compare_context::cmpFn, compare_context::colloid, compare_values(), i, cvec::nranges, qsort_arg(), range(), and start.
Referenced by brin_range_serialize(), and ensure_free_space_in_buffer().
|
static |
Definition at line 1477 of file brin_minmax_multi.c.
References Assert, cmp(), compare_context::cmpFn, ExpandedRange::collapsed, compare_context::colloid, compare_values(), i, DistanceValue::index, ExpandedRange::maxval, ExpandedRange::minval, palloc(), qsort_arg(), and values.
Referenced by brin_minmax_multi_union(), compactify_ranges(), and ensure_free_space_in_buffer().
|
static |
Definition at line 1180 of file brin_minmax_multi.c.
References Assert, cmp(), compare_context::cmpFn, compare_context::colloid, compare_expanded_ranges(), i, and qsort_arg().
Referenced by brin_minmax_multi_union(), and build_expanded_ranges().
|
static |
Definition at line 1559 of file brin_minmax_multi.c.
References Assert, i, idx(), ExpandedRange::maxval, Ranges::maxvalues, ExpandedRange::minval, Ranges::nranges, Ranges::nsorted, Ranges::nvalues, and Ranges::values.
Referenced by brin_minmax_multi_union(), compactify_ranges(), and ensure_free_space_in_buffer().