Refactor header inclusion

Correcting conditions in #ifdefs, adding missing includes, removing
and rearranging existing includes, replacing PG12 with PG12_GE for
forward compatibility. Fixed number of places with relation_close to
table_close, which were missed earlier.
This commit is contained in:
Ruslan Fomkin 2020-02-10 11:39:11 +01:00 committed by Erik Nordström
parent e57ee45fcf
commit 1ddc62eb5f
68 changed files with 251 additions and 395 deletions

View File

@ -184,7 +184,7 @@ minmax_indexscan(Relation rel, Relation idxrel, AttrNumber attnum, Datum minmax[
{
IndexScanDesc scan = index_beginscan(rel, idxrel, GetTransactionSnapshot(), 0, 0);
HeapTuple tuple;
#if PG12 /* TODO we should not materialize a HeapTuple unless needed */
#if PG12_GE /* TODO we should not materialize a HeapTuple unless needed */
TupleTableSlot *slot = MakeSingleTupleTableSlot(RelationGetDescr(rel), &TTSOpsBufferHeapTuple);
bool should_free = false;
#endif
@ -209,7 +209,7 @@ minmax_indexscan(Relation rel, Relation idxrel, AttrNumber attnum, Datum minmax[
nulls[n++] = false;
}
#if PG12
#if PG12_GE
if (should_free)
{
heap_freetuple(tuple);
@ -234,14 +234,14 @@ minmax_indexscan(Relation rel, Relation idxrel, AttrNumber attnum, Datum minmax[
nulls[n++] = false;
}
#if PG12
#if PG12_GE
if (should_free)
heap_freetuple(tuple);
#endif
index_endscan(scan);
#if PG12
#if PG12_GE
ExecDropSingleTupleTableSlot(slot);
#endif

View File

@ -5,7 +5,6 @@
*/
#include <postgres.h>
#include <nodes/nodeFuncs.h>
#include <optimizer/clauses.h>
#include <optimizer/pathnode.h>
#include <optimizer/paths.h>
#include <optimizer/tlist.h>
@ -14,12 +13,12 @@
#include "compat.h"
#if PG12_LT
#include <optimizer/var.h> /* f09346a */
#elif PG12_GE
#include <optimizer/clauses.h>
#include <optimizer/var.h>
#else
#include <optimizer/optimizer.h>
#endif
#include "hypertable.h"
#include "chunk_append/chunk_append.h"
#include "chunk_append/planner.h"
#include "func_cache.h"
@ -232,7 +231,7 @@ ts_chunk_append_path_create(PlannerInfo *root, RelOptInfo *rel, Hypertable *ht,
#endif
nested_children = lappend(nested_children, append);
}
#if PG12
#if PG12_GE
else if (list_length(merge_childs) == 0)
{
/* nop */

View File

@ -7,11 +7,10 @@
#define TIMESCALEDB_CHUNK_APPEND_H
#include <postgres.h>
#include <nodes/primnodes.h>
#include "compat.h"
#include <nodes/primnodes.h>
#if PG12_LT /* nodes/relation.h renamed in fa2cf16 */
#if PG12_LT
#include <nodes/relation.h>
#else
#include <nodes/pathnodes.h>

View File

@ -12,7 +12,6 @@
#include <nodes/bitmapset.h>
#include <nodes/makefuncs.h>
#include <nodes/nodeFuncs.h>
#include <optimizer/clauses.h>
#include <optimizer/cost.h>
#include <optimizer/plancat.h>
#include <optimizer/prep.h>
@ -25,8 +24,8 @@
#include <math.h>
#include "compat.h"
#if PG12_LT /* nodes/relation.h renamed in fa2cf16 */
#if PG12_LT
#include <optimizer/clauses.h>
#include <optimizer/predtest.h>
#include <nodes/relation.h>
#else
@ -34,8 +33,8 @@
#include <optimizer/optimizer.h>
#endif
#include "chunk_append/chunk_append.h"
#include "chunk_append/exec.h"
#include "chunk_append/chunk_append.h"
#include "chunk_append/explain.h"
#include "chunk_append/planner.h"
#include "loader/lwlocks.h"
@ -227,7 +226,7 @@ chunk_append_begin(CustomScanState *node, EState *estate, int eflags)
state->num_subplans = list_length(state->filtered_subplans);
#if PG12
#if PG12_GE
ExecInitResultTupleSlotTL(&node->ss.ps, TTSOpsVirtualP);
/* node returns slots from each of its subnodes, therefore not fixed */
@ -400,7 +399,7 @@ chunk_append_exec(CustomScanState *node)
if (!TupIsNull(subslot))
{
#if PG12
#if PG12_GE
/* convert to Virtual tuple, so the tts_ops don't conflict */
if (state->slot->tts_tupleDescriptor != subslot->tts_tupleDescriptor)
ExecSetSlotDescriptor(state->slot, subslot->tts_tupleDescriptor);
@ -433,7 +432,7 @@ chunk_append_exec(CustomScanState *node)
#endif
}
#if PG12
#if PG12_GE
ExecClearTuple(state->slot);
#endif
@ -588,7 +587,7 @@ chunk_append_end(CustomScanState *node)
ExecEndNode(state->subplanstates[i]);
}
#if PG12
#if PG12_GE
ExecDropSingleTupleTableSlot(state->slot);
#endif
}

View File

@ -10,14 +10,6 @@
#include <nodes/bitmapset.h>
#include <nodes/extensible.h>
#include "compat.h"
#if PG12_LT /* nodes/relation.h renamed in fa2cf16 */
#include <nodes/relation.h>
#else
#include <nodes/pathnodes.h>
#endif
typedef struct ParallelChunkAppendState
{
int next_plan;
@ -72,7 +64,7 @@ typedef struct ChunkAppendState
ParallelChunkAppendState *pstate;
void (*choose_next_subplan)(struct ChunkAppendState *);
#if PG12
#if PG12_GE
TupleTableSlot *slot;
#endif
} ChunkAppendState;

View File

@ -9,7 +9,6 @@
#include <nodes/extensible.h>
#include <nodes/makefuncs.h>
#include <nodes/nodeFuncs.h>
#include <optimizer/clauses.h>
#include <optimizer/pathnode.h>
#include <optimizer/paths.h>
#include <optimizer/placeholder.h>
@ -21,8 +20,9 @@
#include "compat.h"
#if PG12_LT
#include <optimizer/var.h> /* f09346a */
#elif PG12_GE
#include <optimizer/clauses.h>
#include <optimizer/var.h>
#else
#include <optimizer/appendinfo.h>
#include <optimizer/optimizer.h>
#endif

View File

@ -9,14 +9,6 @@
#include <postgres.h>
#include <nodes/extensible.h>
#include "compat.h"
#if PG12_LT /* nodes/relation.h renamed in fa2cf16 */
#include <nodes/relation.h>
#else
#include <nodes/pathnodes.h>
#endif
Plan *ts_chunk_append_plan_create(PlannerInfo *root, RelOptInfo *rel, CustomPath *path, List *tlist,
List *clauses, List *custom_plans);
Scan *ts_chunk_append_get_scan_plan(Plan *plan);

View File

@ -8,9 +8,15 @@
#include <catalog/pg_type.h>
#include <nodes/makefuncs.h>
#include <nodes/nodeFuncs.h>
#include <optimizer/clauses.h>
#include <utils/lsyscache.h>
#include "compat.h"
#ifdef PG12_LT
#include <optimizer/clauses.h>
#else
#include <optimizer/optimizer.h>
#endif
#include "chunk_append/transform.h"
#include "utils.h"

View File

@ -9,14 +9,6 @@
#include <postgres.h>
#include <nodes/extensible.h>
#include "compat.h"
#if PG12_LT /* nodes/relation.h renamed in fa2cf16 */
#include <nodes/relation.h>
#else
#include <nodes/pathnodes.h>
#endif
extern Expr *ts_transform_cross_datatype_comparison(Expr *clause);
#endif /* TIMESCALEDB_CHUNK_APPEND_TRANSFORM_H */

View File

@ -34,7 +34,7 @@ chunk_dispatch_begin(CustomScanState *node, EState *estate, int eflags)
state->hypertable_cache = hypertable_cache;
state->dispatch = ts_chunk_dispatch_create(ht, estate);
node->custom_ps = list_make1(ps);
#if PG12
#if PG12_GE
// TODO get from parent using table_slot_callbacks?
// TODO should this use ExecInitExtraTupleSlot?
state->slot = MakeSingleTupleTableSlot(NULL, TTSOpsBufferHeapTupleP);
@ -62,7 +62,7 @@ chunk_dispatch_exec(CustomScanState *node)
EState *estate = node->ss.ps.state;
MemoryContext old;
bool cis_changed;
#if PG12
#if PG12_GE
bool should_free_tuple = false;
/*
@ -110,10 +110,10 @@ chunk_dispatch_exec(CustomScanState *node)
cis = ts_chunk_dispatch_get_chunk_insert_state(dispatch,
point,
&cis_changed,
#if PG12
state->slot->tts_ops
#else
#if PG12_LT
NULL
#else
state->slot->tts_ops
#endif
);
if (cis_changed)
@ -184,7 +184,7 @@ chunk_dispatch_exec(CustomScanState *node)
}
#endif
#if PG12 /* from ExecPrepareTupleRouting */
#if PG12_GE /* from ExecPrepareTupleRouting */
if (state->parent->mt_transition_capture != NULL)
{
/* TODO BEFORE triggers? */
@ -276,7 +276,7 @@ chunk_dispatch_end(CustomScanState *node)
ExecEndNode(substate);
ts_chunk_dispatch_destroy(state->dispatch);
ts_cache_release(state->hypertable_cache);
#if PG12
#if PG12_GE
ExecDropSingleTupleTableSlot(state->slot);
#endif
}

View File

@ -33,7 +33,7 @@ typedef struct ChunkDispatchState
* for each chunk.
*/
ChunkDispatch *dispatch;
#if PG12
#if PG12_GE
TupleTableSlot *slot;
#endif
} ChunkDispatchState;

View File

@ -25,19 +25,17 @@
#include "compat.h"
#if PG12_LT
#include <optimizer/var.h> /* f09346a */
#elif PG12_GE
#include <optimizer/var.h>
#else
#include <optimizer/optimizer.h>
#endif
#include "export.h"
#include "chunk_index.h"
#include "hypertable.h"
#include "hypertable_cache.h"
#include "catalog.h"
#include "scanner.h"
#include "chunk.h"
#include "compat.h"
static bool chunk_index_insert(int32 chunk_id, const char *chunk_index, int32 hypertable_id,
const char *hypertable_index);

View File

@ -12,8 +12,8 @@
#include <fmgr.h>
#include <utils/relcache.h>
#include <compat.h>
#include <export.h>
#include "compat.h"
#include "export.h"
typedef struct Chunk Chunk;
typedef struct Hypertable Hypertable;

View File

@ -12,9 +12,6 @@
#include <utils/guc.h>
#include <nodes/plannodes.h>
#include <access/xact.h>
#include <optimizer/plancat.h>
#include <optimizer/clauses.h>
#include <optimizer/planner.h>
#include <miscadmin.h>
#include <parser/parsetree.h>
#include <rewrite/rewriteManip.h>
@ -22,15 +19,18 @@
#include <catalog/pg_type.h>
#include "compat.h"
#if PG12
#if PG12_LT
#include <optimizer/clauses.h>
#include <optimizer/plancat.h>
#include <optimizer/planner.h>
#else
#include <optimizer/optimizer.h>
#endif
#include "errors.h"
#include "chunk_insert_state.h"
#include "errors.h"
#include "chunk_dispatch.h"
#include "chunk_dispatch_state.h"
#include "compat.h"
#include "chunk_index.h"
/*
@ -89,7 +89,7 @@ create_chunk_range_table_entry(ChunkDispatch *dispatch, Relation rel)
estate->es_range_table = lappend(estate->es_range_table, rte);
#if PG12
#if PG12_GE
Assert(list_length(estate->es_range_table) > estate->es_range_table_size);
if (estate->es_range_table_array != NULL)
{
@ -238,17 +238,17 @@ create_chunk_result_relation_info(ChunkDispatch *dispatch, Relation rel, Index r
rri->ri_onConflict = makeNode(OnConflictSetState);
rri->ri_onConflict->oc_ProjInfo = rri_orig->ri_onConflict->oc_ProjInfo;
rri->ri_onConflict->oc_WhereClause = rri_orig->ri_onConflict->oc_WhereClause;
#if PG12
#if PG12_GE
rri->ri_onConflict->oc_Existing = rri_orig->ri_onConflict->oc_Existing;
rri->ri_onConflict->oc_ProjSlot = rri_orig->ri_onConflict->oc_ProjSlot;
Assert(!TTS_FIXED(rri->ri_onConflict->oc_ProjSlot));
#else
#else /* #if PG11 */
rri->ri_onConflict->oc_ProjTupdesc = rri_orig->ri_onConflict->oc_ProjTupdesc;
#endif
#endif /* PG12_GE */
}
else
rri->ri_onConflict = NULL;
#endif
#endif /* PG11_LT */
create_chunk_rri_constraint_expr(rri, rel);

View File

@ -11,11 +11,7 @@
#include <funcapi.h>
#include <access/tupconvert.h>
#include "hypertable.h"
#include "chunk.h"
#include "cache.h"
#include "chunk_dispatch_state.h"
#include "compat.h"
typedef struct ChunkInsertState
{

View File

@ -75,7 +75,7 @@
* will only be activated in versions >=11 when we implement partition-wise
* joins.
*/
#if PG96 || PG10
#if PG11_LT
#define adjust_appendrel_attrs_compat adjust_appendrel_attrs
#else
#define adjust_appendrel_attrs_compat(root, node, appinfo) \
@ -89,7 +89,7 @@
* PG11 introduced flags to BackgroundWorker connection functions. PG96 & 10
* interface kept for backwards compatibility.
*/
#if PG96 || PG10
#if PG11_LT
#define BackgroundWorkerInitializeConnectionByOidCompat(dboid, useroid) \
BackgroundWorkerInitializeConnectionByOid(dboid, useroid)
#define BackgroundWorkerInitializeConnectionCompat(dbname, username) \
@ -137,7 +137,7 @@
* https://github.com/postgres/postgres/commit/17b7c302b5fc92bd0241c452599019e18df074dc
* we use the PG11 version as it is more descriptive.
*/
#if PG96 || PG10
#if PG11_LT
#define ConstraintRelidTypidNameIndexId ConstraintRelidIndexId
#endif
@ -150,7 +150,7 @@
* with it separately, we instead maintain backwards compatibility for the old
* interface and continue to manage as before.
*/
#if PG96 || PG10
#if PG11_LT
#define CreateTriggerCompat CreateTrigger
#else
#define CreateTriggerCompat(stmt, \
@ -260,7 +260,6 @@
ExecBuildProjectionInfo(tl, exprContext, slot, parent, inputdesc)
#endif
/* https://github.com/postgres/postgres/commit/5db6df0c0117ff2a4e0cd87594d2db408cd5022f */
#if PG12_LT
#define TM_Result HTSU_Result
@ -284,7 +283,7 @@
* https://github.com/postgres/postgres/commit/ad7dbee368a7cd9e595d2a957be784326b08c943).
* We adopt the PG11 conventions so that we can take advantage of JITing more easily in the future.
*/
#if PG96 || PG10
#if PG11_LT
#define TupleTableSlotOps void
#define TTSOpsVirtualP NULL
@ -309,9 +308,7 @@ ExecInitExtraTupleSlotCompat(EState *estate, TupleDesc tupdesc, void *tts_ops)
* ExecSetTupleBound is only available starting with PG11 so we map to a backported version
* for PG9.6 and PG10
*/
#if PG96 || PG10
#define ExecSetTupleBound(tuples_needed, child_node) ts_ExecSetTupleBound(tuples_needed, child_node)
#endif
static inline TupleTableSlot *
MakeTupleTableSlotCompat(TupleDesc tupdesc, void *tts_ops)
@ -323,7 +320,7 @@ MakeTupleTableSlotCompat(TupleDesc tupdesc, void *tts_ops)
return myslot;
}
#elif PG12_LT
#elif PG11
#define TupleTableSlotOps void
#define TTSOpsVirtualP NULL
@ -335,7 +332,7 @@ MakeTupleTableSlotCompat(TupleDesc tupdesc, void *tts_ops)
#define MakeTupleTableSlotCompat(tupdesc, tts_ops) MakeTupleTableSlot(tupdesc)
#define MakeSingleTupleTableSlotCompat(tupledesc, tts_ops) MakeSingleTupleTableSlot(tupledesc)
#else
#else /* PG12_GE */
#define TTSOpsVirtualP (&TTSOpsVirtual)
#define TTSOpsHeapTupleP (&TTSOpsHeapTuple)
@ -432,7 +429,7 @@ MakeTupleTableSlotCompat(TupleDesc tupdesc, void *tts_ops)
* compatibility here and have a small static inline function to replicate the
* behavior on older versions.
*/
#if PG96 || PG10
#if PG11_LT
static inline char *
get_attname_compat(Oid relid, AttrNumber attnum, bool missing_ok)
{
@ -465,7 +462,7 @@ get_attname_compat(Oid relid, AttrNumber attnum, bool missing_ok)
* can be null for pg_catalog tables, but must be provided otherwise), and
* simply omit in earlier versions.
*/
#if PG96 || PG10
#if PG11_LT
#define heap_attisnull_compat(tup, attnum, tupledesc) heap_attisnull(tup, attnum)
#else
#define heap_attisnull_compat heap_attisnull
@ -484,7 +481,7 @@ get_attname_compat(Oid relid, AttrNumber attnum, bool missing_ok)
* by us, we might in the future want to use some of those flags depending on how
* we eventually decide to work with declarative partitioning.
*/
#if PG96 || PG10
#if PG11_LT
/* Index flags */
#define INDEX_CREATE_IS_PRIMARY (1 << 0)
#define INDEX_CREATE_ADD_CONSTRAINT (1 << 1)
@ -656,7 +653,7 @@ get_attname_compat(Oid relid, AttrNumber attnum, bool missing_ok)
*
* PG11 added a unit parameter to ExplainPropertyInteger
*/
#if PG96 || PG10
#if PG11_LT
#define ExplainPropertyIntegerCompat(label, unit, value, es) \
ExplainPropertyInteger(label, value, es)
#else
@ -679,7 +676,7 @@ get_attname_compat(Oid relid, AttrNumber attnum, bool missing_ok)
* PG11 fixes some functions that return pointers to follow convention and end
* with P.
*/
#if PG96 || PG10
#if PG11_LT
#define PG_RETURN_JSONB_P PG_RETURN_JSONB
#endif
@ -697,7 +694,7 @@ get_attname_compat(Oid relid, AttrNumber attnum, bool missing_ok)
* are nested.
*/
#if PG96 || PG10
#if PG11_LT
#define ResultRelInfo_OnConflictProjInfoCompat(rri) ((rri)->ri_onConflictSetProj)
#define ResultRelInfo_OnConflictWhereCompat(rri) ((rri)->ri_onConflictSetWhere)
#define ResultRelInfo_OnConflictNotNull(rri) true
@ -714,7 +711,7 @@ get_attname_compat(Oid relid, AttrNumber attnum, bool missing_ok)
* https://github.com/postgres/postgres/commit/d87510a524f36a630cfb34cc392e95e959a1b0dc) We do not
* define RVR_SKIP_LOCKED as cannot yet emulate it
*/
#if PG96 || PG10
#if PG11_LT
#define RVR_MISSING_OK (1 << 0)
#define RVR_NOWAIT (1 << 1)
#define RangeVarGetRelidExtendedCompat(relation, lockmode, flags, callback, callback_arg) \
@ -746,7 +743,7 @@ get_attname_compat(Oid relid, AttrNumber attnum, bool missing_ok)
* use one of the functions in this family, but making this general in case we
* use the others in the future).
*/
#if PG96 || PG10
#if PG11_LT
#define PreventInTransactionBlock PreventTransactionChain
#endif
@ -759,7 +756,7 @@ get_attname_compat(Oid relid, AttrNumber attnum, bool missing_ok)
* see
* https://github.com/postgres/postgres/commit/c2fe139c201c48f1133e9fbea2dd99b8efe2fadd#diff-79a1a60cd631a1067199e0296de47ec4
*/
#if PG96 || PG10 || PG11
#if PG12_LT
#define TableScanDesc HeapScanDesc
#define table_beginscan heap_beginscan
#define table_beginscan_catalog heap_beginscan_catalog
@ -786,7 +783,7 @@ extern int oid_cmp(const void *p1, const void *p2);
#endif
/* pq_sendint is deprecated in PG11, so create pq_sendint32 in 9.6 and 10 */
#if PG96 || PG10
#if PG11_LT
#define pq_sendint32(buf, i) pq_sendint(buf, i, 4)
#endif

View File

@ -15,9 +15,7 @@
#include <nodes/nodeFuncs.h>
#include <nodes/nodes.h>
#include <nodes/plannodes.h>
#include <optimizer/clauses.h>
#include <optimizer/plancat.h>
#include <optimizer/prep.h>
#include <parser/parsetree.h>
#include <rewrite/rewriteManip.h>
#include <utils/lsyscache.h>
@ -25,8 +23,10 @@
#include <utils/syscache.h>
#include "compat.h"
#if PG12_GE
#if PG12_LT
#include <optimizer/clauses.h>
#include <optimizer/prep.h>
#else
#include <optimizer/appendinfo.h>
#include <optimizer/optimizer.h>
#endif
@ -142,7 +142,7 @@ ca_append_begin(CustomScanState *node, EState *estate, int eflags)
.parse = &parse,
};
#if PG12
#if PG12_GE
state->slot = MakeSingleTupleTableSlot(NULL, TTSOpsVirtualP);
#endif
@ -292,7 +292,7 @@ ca_append_exec(CustomScanState *node)
if (TupIsNull(subslot))
return NULL;
#if PG12
#if PG12_GE
if (state->slot->tts_tupleDescriptor != subslot->tts_tupleDescriptor)
ExecSetSlotDescriptor(state->slot, subslot->tts_tupleDescriptor);
@ -326,7 +326,7 @@ ca_append_end(CustomScanState *node)
{
ExecEndNode(linitial(node->custom_ps));
}
#if PG12
#if PG12_GE
ExecDropSingleTupleTableSlot(((ConstraintAwareAppendState *) node)->slot);
#endif
}

View File

@ -9,14 +9,6 @@
#include <postgres.h>
#include <nodes/extensible.h>
#include "compat.h"
#if PG12_LT /* nodes/relation.h renamed in fa2cf16 */
#include <nodes/relation.h>
#else
#include <nodes/pathnodes.h>
#endif
typedef struct ConstraintAwareAppendPath
{
CustomPath cpath;
@ -27,7 +19,7 @@ typedef struct ConstraintAwareAppendState
CustomScanState csstate;
Plan *subplan;
Size num_append_subplans;
#if PG12
#if PG12_GE
TupleTableSlot *slot;
#endif
} ConstraintAwareAppendState;

View File

@ -64,7 +64,7 @@ typedef struct CopyChunkState
static CopyChunkState *
copy_chunk_state_create(Hypertable *ht, Relation rel, CopyFromFunc from_func, CopyState cstate,
HeapScanDesc scandesc)
TableScanDesc scandesc)
{
CopyChunkState *ccstate;
EState *estate = CreateExecutorState();
@ -269,7 +269,7 @@ timescaledb_CopyFrom(CopyChunkState *ccstate, List *range_table, Hypertable *ht)
ChunkDispatch *dispatch = ccstate->dispatch;
ChunkInsertState *cis;
bool cis_changed;
#if PG12
#if PG12_GE
bool should_free = false;
#endif
@ -303,10 +303,10 @@ timescaledb_CopyFrom(CopyChunkState *ccstate, List *range_table, Hypertable *ht)
cis = ts_chunk_dispatch_get_chunk_insert_state(dispatch,
point,
&cis_changed,
#if PG12
TTSOpsHeapTupleP
#else
#if PG12_LT
NULL
#else
TTSOpsHeapTupleP
#endif
);
@ -381,7 +381,7 @@ timescaledb_CopyFrom(CopyChunkState *ccstate, List *range_table, Hypertable *ht)
/* OK, store the tuple and create index entries for it */
heap_insert(resultRelInfo->ri_RelationDesc, tuple, mycid, hi_options, bistate);
#if PG12
#if PG12_GE
/* re-store the tuple so the slot's ItemPointer is updated */
ExecStoreHeapTuple(tuple, slot, should_free);
#endif

View File

@ -9,8 +9,6 @@
#include <postgres.h>
#include <nodes/pg_list.h>
#include "catalog.h"
#include "dimension.h"
#include "chunk_constraint.h"
#define DIMENSION_SLICE_MAXVALUE ((int64) PG_INT64_MAX)

View File

@ -6,20 +6,22 @@
#include <postgres.h>
#include <parser/parse_oper.h>
#include <catalog/pg_type.h>
#include <optimizer/cost.h>
#include <optimizer/clauses.h>
#include <optimizer/tlist.h>
#include <utils/selfuncs.h>
#include "compat.h"
#if PG12_LT
#include <optimizer/clauses.h>
#include <optimizer/cost.h>
#include <optimizer/tlist.h>
#else
#include <optimizer/optimizer.h>
#endif
#include "func_cache.h"
#include "estimate.h"
#include "planner_import.h"
#include "utils.h"
#include "compat.h"
#if PG12
#include <optimizer/optimizer.h>
#endif
/*
* This module contains functions for estimating, e.g., the number of groups
* formed in various grouping expressions that involve time bucketing.

View File

@ -25,7 +25,7 @@
#include <catalog/indexing.h>
#include "compat.h"
#if PG12
#if PG12_GE
#include <access/genam.h>
#endif

View File

@ -6,8 +6,6 @@
#include <postgres.h>
#include <miscadmin.h>
#include <parser/parse_oper.h>
#include <optimizer/cost.h>
#include <optimizer/clauses.h>
#include <catalog/namespace.h>
#include <catalog/pg_type.h>
#include <catalog/pg_proc.h>
@ -21,8 +19,12 @@
#include <utils/rel.h>
#include "compat.h"
#if PG12
#if PG12_LT
#include <nodes/relation.h>
#include <optimizer/cost.h>
#include <optimizer/clauses.h>
#else
#include <nodes/pathnodes.h>
#include <optimizer/optimizer.h>
#endif
@ -299,11 +301,11 @@ static HTAB *func_hash = NULL;
static Oid
proc_get_oid(HeapTuple tuple)
{
#if PG12
#if PG12_LT
return HeapTupleGetOid(tuple);
#else
Form_pg_proc form = (Form_pg_proc) GETSTRUCT(tuple);
return form->oid;
#else
return HeapTupleGetOid(tuple);
#endif
}

View File

@ -5,13 +5,14 @@
*/
#include <postgres.h>
#include <utils/typcache.h>
#include <optimizer/clauses.h>
#include <utils/lsyscache.h>
#include <parser/parsetree.h>
#include <utils/array.h>
#include "compat.h"
#if PG12_GE
#if PG12_LT
#include <optimizer/clauses.h>
#else
#include <optimizer/optimizer.h>
#endif

View File

@ -264,7 +264,7 @@ indexing_create_and_verify_hypertable_indexes(Hypertable *ht, bool create_defaul
if (create_default)
create_default_indexes(ht, time_dim, space_dim, has_time_idx, has_time_space_idx);
relation_close(tblrel, AccessShareLock);
table_close(tblrel, AccessShareLock);
}
/* create the index on the root table of a hypertable.

View File

@ -447,15 +447,15 @@ ts_get_partition_hash(PG_FUNCTION_ARGS)
if (pfc->tce->hash_proc == InvalidOid)
elog(ERROR, "could not find hash function for type %u", pfc->argtype);
#if PG12
#if PG12_LT
collation = InvalidOid;
#else
/* use the supplied collation, if it exists, otherwise use the default for
* the type
*/
collation = PG_GET_COLLATION();
if (!OidIsValid(collation))
collation = pfc->tce->typcollation;
#else
collation = InvalidOid;
#endif
hash = FunctionCall1Coll(&pfc->tce->hash_proc_finfo, collation, arg);

View File

@ -21,7 +21,6 @@
#include "utils.h"
#include "guc.h"
#include "estimate.h"
#include "compat.h"
/* Add a parallel HashAggregate plan.
* This code is similar to parts of create_grouping_paths */

View File

@ -6,15 +6,6 @@
#ifndef TIMESCALEDB_PLAN_ADD_HASHAGG_H
#define TIMESCALEDB_PLAN_ADD_HASHAGG_H
#include "compat.h"
#include <nodes/primnodes.h>
#if PG12_LT /* nodes/relation.h renamed in fa2cf16 */
#include <nodes/relation.h>
#else
#include <nodes/pathnodes.h>
#endif
/* This optimization adds a HashAggregate plan to many group by queries.
* In plain postgres, many time-series queries will not use a the hash aggregate
* because the planner will incorrectly assume that the number of rows is much larger than

View File

@ -32,40 +32,42 @@
*
*
*/
#include "postgres.h"
#include <postgres.h>
#include "access/htup_details.h"
#include "catalog/pg_aggregate.h"
#include "catalog/pg_type.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "optimizer/clauses.h"
#include "optimizer/cost.h"
#include "optimizer/pathnode.h"
#include "optimizer/paths.h"
#include "optimizer/planmain.h"
#include "optimizer/subselect.h"
#include "optimizer/tlist.h"
#include "parser/parsetree.h"
#include "parser/parse_clause.h"
#include "parser/parse_func.h"
#include "rewrite/rewriteManip.h"
#include "utils/lsyscache.h"
#include "utils/syscache.h"
#include "catalog/pg_proc.h"
#include <access/htup_details.h>
#include <access/stratnum.h>
#include <catalog/namespace.h>
#include "utils/typcache.h"
#include "access/stratnum.h"
#include "plan_agg_bookend.h"
#include "utils.h"
#include "extension.h"
#include <catalog/pg_aggregate.h>
#include <catalog/pg_proc.h>
#include <catalog/pg_type.h>
#include <nodes/makefuncs.h>
#include <nodes/nodeFuncs.h>
#include <optimizer/cost.h>
#include <optimizer/pathnode.h>
#include <optimizer/paths.h>
#include <optimizer/planmain.h>
#include <optimizer/subselect.h>
#include <optimizer/tlist.h>
#include <parser/parsetree.h>
#include <parser/parse_clause.h>
#include <parser/parse_func.h>
#include <rewrite/rewriteManip.h>
#include <utils/lsyscache.h>
#include <utils/syscache.h>
#include <utils/typcache.h>
#include "compat.h"
#if PG12
#include "optimizer/optimizer.h"
#if PG12_LT
#include <optimizer/clauses.h>
#else
#include <optimizer/optimizer.h>
#endif
#include "plan_agg_bookend.h"
#include "planner.h"
#include "utils.h"
#include "extension.h"
typedef struct FirstLastAggInfo
{
MinMaxAggInfo *m_agg_info; /* reusing MinMaxAggInfo to avoid code
@ -657,7 +659,7 @@ build_first_last_path(PlannerInfo *root, FirstLastAggInfo *fl_info, Oid eqop, Oi
subroot->tuple_fraction = 1.0;
subroot->limit_tuples = 1.0;
#if PG12
#if PG12_GE
{
ListCell *lc;
/* min/max optimizations ususally happen before
@ -713,7 +715,7 @@ build_first_last_path(PlannerInfo *root, FirstLastAggInfo *fl_info, Oid eqop, Oi
first_last_qp_callback,
NULL);
#if PG12
#if PG12_GE
{
ListCell *lc;
/* we need to disable inheritance so the chunks are re-expanded correctly in the subroot */

View File

@ -6,14 +6,5 @@
#ifndef TIMESCALEDB_PLAN_AGG_BOOKEND_H
#define TIMESCALEDB_PLAN_AGG_BOOKEND_H
#include "compat.h"
#include <nodes/primnodes.h>
#if PG12_LT /* nodes/relation.h renamed in fa2cf16 */
#include <nodes/relation.h>
#else
#include <nodes/pathnodes.h>
#endif
extern void ts_preprocess_first_last_aggregates(PlannerInfo *root, List *tlist);
#endif /* TIMESCALEDB_PLAN_AGG_BOOKEND_H */

View File

@ -11,7 +11,6 @@
#include <nodes/makefuncs.h>
#include <nodes/nodeFuncs.h>
#include <nodes/plannodes.h>
#include <optimizer/clauses.h>
#include <optimizer/pathnode.h>
#include <optimizer/prep.h>
#include <optimizer/restrictinfo.h>
@ -33,7 +32,8 @@
#endif
#if PG12_LT
#include <optimizer/var.h> /* f09346a */
#include <optimizer/clauses.h>
#include <optimizer/var.h>
#elif PG12_GE
#include <optimizer/optimizer.h>
#endif
@ -518,7 +518,7 @@ process_quals(Node *quals, CollectQualCtx *ctx, bool is_outer_join)
return (Node *) list_concat((List *) quals, additional_quals);
}
#if PG12
#if PG12_GE
static List *
remove_exclusion_fns(List *restrictinfo)
{
@ -1066,7 +1066,7 @@ ts_plan_expand_hypertable_chunks(Hypertable *ht, PlannerInfo *root, Oid parent_o
};
Size old_rel_array_len;
Index first_chunk_index = 0;
#if PG12
#if PG12_GE
Index i;
#endif
@ -1086,7 +1086,7 @@ ts_plan_expand_hypertable_chunks(Hypertable *ht, PlannerInfo *root, Oid parent_o
/* Walk the tree and find restrictions or chunk exclusion functions */
collect_quals_walker((Node *) root->parse->jointree, &ctx);
#if PG12
#if PG12_GE
rel->baserestrictinfo = remove_exclusion_fns(rel->baserestrictinfo);
#endif
@ -1131,11 +1131,11 @@ ts_plan_expand_hypertable_chunks(Hypertable *ht, PlannerInfo *root, Oid parent_o
RangeTblEntry *childrte;
Index child_rtindex;
AppendRelInfo *appinfo;
#if PG12
#if PG12_LT
LOCKMODE chunk_lock = NoLock;
#else
// FIXME this lock should not be needed...
LOCKMODE chunk_lock = rte->rellockmode;
#else
LOCKMODE chunk_lock = NoLock;
#endif
/* Open rel if needed */
@ -1161,7 +1161,7 @@ ts_plan_expand_hypertable_chunks(Hypertable *ht, PlannerInfo *root, Oid parent_o
* other base restriction clauses, so we don't need to do it here.
*/
childrte = copyObject(rte);
#if PG12
#if PG12_GE
childrte->rellockmode = rte->rellockmode;
#endif
childrte->relid = child_oid;
@ -1213,7 +1213,7 @@ ts_plan_expand_hypertable_chunks(Hypertable *ht, PlannerInfo *root, Oid parent_o
setup_append_rel_array(root);
#endif
#if PG12
#if PG12_GE
/* In pg12 postgres will not set up the child rels for use, due to the games
* we're playing with inheritance, so we must do it ourselves.
* build_simple_rel will look things up in the append_rel_array, so we can

View File

@ -8,16 +8,21 @@
#include <nodes/nodeFuncs.h>
#include <nodes/nodes.h>
#include <nodes/pg_list.h>
#if PG12_LT
#include <nodes/relation.h>
#include <optimizer/var.h>
#endif
#include <optimizer/planner.h>
#include <optimizer/cost.h>
#include <optimizer/tlist.h>
#include <parser/parse_func.h>
#include <utils/lsyscache.h>
#include "compat.h"
#if PG12_LT
#include <nodes/relation.h>
#include <optimizer/var.h>
#else
#include <nodes/pathnodes.h>
#include <optimizer/optimizer.h>
#endif
#include "plan_partialize.h"
#include "extension_constants.h"
#include "utils.h"

View File

@ -4,6 +4,7 @@
* LICENSE-APACHE for a copy of the license.
*/
#include <postgres.h>
#include <math.h>
#include <access/tsmapi.h>
#include <nodes/plannodes.h>
#include <parser/parsetree.h>
@ -38,8 +39,8 @@
#include "compat-msvc-exit.h"
#if PG12_LT
#include <optimizer/var.h> /* f09346a */
#elif PG12_GE
#include <optimizer/var.h>
#else
#include <optimizer/appendinfo.h>
#include <optimizer/optimizer.h>
#endif
@ -389,11 +390,8 @@ is_hypertable_chunk_dml(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTblE
parent_oid = appinfo->parent_reloid;
if (parent_oid != InvalidOid && rte->relid != parent_oid)
{
Cache *hcache = ts_hypertable_cache_pin();
Hypertable *parent_ht = ts_hypertable_cache_get_entry(hcache, parent_oid);
ts_cache_release(hcache);
if (parent_ht)
return parent_oid;
if (ts_is_hypertable(parent_oid))
return parent_oid;
}
#else
/* In PG12 UPDATE/DELETE on inheritance relations are planned in two
@ -502,7 +500,7 @@ timescaledb_set_rel_pathlist_query(PlannerInfo *root, RelOptInfo *rel, Index rti
return;
}
#if PG12
#if PG12_GE
static void set_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTblEntry *rte);
@ -1439,7 +1437,7 @@ timescaledb_set_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, Index rti, Rang
Oid ht_reloid = rte->relid;
Oid is_htdml;
#if PG12
#if PG12_GE
// if(inheritance_disabled_counter > inheritance_reenabled_counter)
reenable_inheritance(root, rel, rti, rte);
#endif
@ -1496,7 +1494,7 @@ timescaledb_get_relation_info_hook(PlannerInfo *root, Oid relation_objectid, boo
if (!ts_extension_is_loaded())
return;
#if PG12
#if PG12_GE
/* in earlier versions this is done during expand_hypertable_inheritance() below */
ts_plan_expand_timebucket_annotate(root, rel);
#endif
@ -1518,8 +1516,7 @@ timescaledb_get_relation_info_hook(PlannerInfo *root, Oid relation_objectid, boo
if (rte->relid == ht_oid)
return;
hcache = ts_hypertable_cache_pin();
ht = ts_hypertable_cache_get_entry(hcache, ht_oid, true);
ht = ts_hypertable_cache_get_cache_and_entry(ht_oid, true, &hcache);
if (ht != NULL && TS_HYPERTABLE_HAS_COMPRESSION(ht))
{

View File

@ -21,23 +21,22 @@
#include <executor/nodeAgg.h>
#include <nodes/makefuncs.h>
#include <nodes/nodeFuncs.h>
#include <optimizer/clauses.h>
#include <optimizer/cost.h>
#include <optimizer/paths.h>
#include <optimizer/placeholder.h>
#include <optimizer/planner.h>
#include <optimizer/subselect.h>
#include <optimizer/tlist.h>
#include <parser/parsetree.h>
#include <utils/datum.h>
#include <utils/lsyscache.h>
#include <utils/rel.h>
#include <utils/selfuncs.h>
#include "compat.h"
#if PG12_LT
#include <optimizer/var.h> /* f09346a */
#elif PG12_GE
#include <optimizer/clauses.h>
#include <optimizer/subselect.h>
#include <optimizer/var.h>
#else
#include <optimizer/optimizer.h>
#endif

View File

@ -18,13 +18,8 @@
#define TIMESCALEDB_PLANNER_IMPORT_H
#include <postgres.h>
#include <nodes/execnodes.h>
#include <utils/lsyscache.h>
#include <utils/relcache.h>
#include <utils/selfuncs.h>
#include "export.h"
extern void ts_make_inh_translation_list(Relation oldrelation, Relation newrelation, Index newvarno,
List **translated_vars);
extern size_t ts_estimate_hashagg_tablesize(struct Path *path,

View File

@ -638,7 +638,7 @@ process_vacuum(ProcessUtilityArgs *args)
PreventCommandDuringRecovery((stmt->options && VACOPT_VACUUM) ? "VACUUM" : "ANALYZE");
/* ACL permission checks inside vacuum_rel and analyze_rel called by this ExecVacuum */
ExecVacuum(
#if PG12
#if PG12_GE
args->parse_state,
#endif
stmt,
@ -1100,7 +1100,7 @@ reindex_chunk(Hypertable *ht, Oid chunk_relid, void *arg)
stmt->relation->schemaname = NameStr(chunk->fd.schema_name);
ReindexTable(stmt->relation,
stmt->options
#if PG12
#if PG12_GE
,
stmt->concurrent /* TODO test */
#endif
@ -2705,7 +2705,7 @@ process_altertable_end_subcmd(Hypertable *ht, Node *parsetree, ObjectAddress *ob
case AT_SetStorage:
case AT_ColumnDefault:
case AT_SetNotNull:
#if PG12
#if PG12_GE
case AT_CheckNotNull: /*TODO test*/
#endif
case AT_DropNotNull:

View File

@ -10,7 +10,6 @@
#include <storage/bufmgr.h>
#include <utils/rel.h>
#include "compat.h"
#include "scanner.h"
enum ScannerType
@ -174,7 +173,7 @@ ts_scanner_start_scan(ScannerCtx *ctx, InternalScannerCtx *ictx)
ictx->tinfo.scanrel = ictx->tablerel;
ictx->tinfo.desc = tuple_desc;
ictx->tinfo.mctx = ctx->result_mctx == NULL ? CurrentMemoryContext : ctx->result_mctx;
#if PG12 /* TODO we should not materialize a HeapTuple unless needed */
#if PG12_GE /* TODO we should not materialize a HeapTuple unless needed */
ictx->tinfo.slot = MakeSingleTupleTableSlot(tuple_desc, &TTSOpsBufferHeapTuple);
#endif
@ -203,7 +202,7 @@ ts_scanner_end_scan(ScannerCtx *ctx, InternalScannerCtx *ictx)
scanner->endscan(ictx);
scanner->closeheap(ictx);
#if PG12
#if PG12_GE
ExecDropSingleTupleTableSlot(ictx->tinfo.slot);
#endif
ictx->closed = true;

View File

@ -8,14 +8,11 @@
#include <postgres.h>
#include <access/genam.h>
#include <access/relscan.h>
#include <utils/fmgroids.h>
#include <access/heapam.h>
#include <nodes/lockoptions.h>
#include <utils.h>
#include "compat.h"
#include "export.h"
/* Tuple information passed on to handlers when scanning for tuples. */
typedef struct TupleInfo
@ -24,7 +21,7 @@ typedef struct TupleInfo
/* TODO in PG12+ we should not materialize a HeapTuple unless needed */
HeapTuple tuple;
TupleDesc desc;
#if PG12
#if PG12_GE
TupleTableSlot *slot;
#endif
/* return index tuple if it was requested -- only for index scans */

View File

@ -27,21 +27,14 @@
#include <utils/relcache.h>
#include <utils/syscache.h>
#include "chunk.h"
#include "utils.h"
#include "compat.h"
#include <nodes/primnodes.h>
#if PG12_LT /* nodes/relation.h renamed in fa2cf16 */
#include <nodes/relation.h>
#else
#include <nodes/pathnodes.h>
#endif
#if !PG96
#include <utils/fmgrprotos.h>
#endif
#include "chunk.h"
#include "utils.h"
TS_FUNCTION_INFO_V1(ts_pg_timestamp_to_unix_microseconds);
/*
@ -571,11 +564,11 @@ ts_get_operator(const char *name, Oid namespace, Oid left, Oid right)
ObjectIdGetDatum(namespace));
if (HeapTupleIsValid(tup))
{
#if PG12
#if PG12_LT
opoid = HeapTupleGetOid(tup);
#else
Form_pg_operator oprform = (Form_pg_operator) GETSTRUCT(tup);
opoid = oprform->oid;
#else
opoid = HeapTupleGetOid(tup);
#endif
ReleaseSysCache(tup);
}

View File

@ -7,23 +7,12 @@
#define TIMESCALEDB_UTILS_H
#include <postgres.h>
#include <fmgr.h>
#include <access/htup_details.h>
#include <catalog/pg_proc.h>
#include <utils/datetime.h>
#include "compat.h"
#include <nodes/primnodes.h>
#if PG12_LT /* nodes/relation.h renamed in fa2cf16 */
#include <nodes/relation.h>
#else
#include <nodes/pathnodes.h>
#endif
#include "export.h"
#include "compat.h"
#if PG11_GE
#include <common/int.h>
#endif

View File

@ -15,16 +15,16 @@
#include <utils/lsyscache.h>
#include <utils/rel.h>
#include "compat.h"
#if PG12_LT
#include <utils/tqual.h>
#endif
#include "params.h"
#include "timer_mock.h"
#include "log.h"
#include "scanner.h"
#include "catalog.h"
#include "compat.h"
#if PG12_LT
#include <utils/tqual.h>
#endif
typedef struct FormData_bgw_dsm_handle
{

View File

@ -13,18 +13,18 @@
#include <utils/lsyscache.h>
#include <utils/rel.h>
#include "compat.h"
#if PG12_LT
#include <utils/tqual.h>
#endif
#include "timer_mock.h"
#include "log.h"
#include "scanner.h"
#include "catalog.h"
#include "compat.h"
#include "params.h"
#include "bgw/launcher_interface.h"
#if PG12_LT
#include <utils/tqual.h>
#endif
static BackgroundWorkerHandle *bgw_handle = NULL;
static bool mock_wait(TimestampTz until);

View File

@ -25,9 +25,6 @@
#include "license.h"
#include "reorder_api.h"
#include "utils.h"
#include "hypertable.h"
#include "bgw/job.h"
#include <bgw_policy/reorder.h>
/*
* Default scheduled interval for reorder jobs should be 1/2 of the default chunk length.

View File

@ -34,7 +34,7 @@
#include <catalog.h>
#include <utils.h>
#include <compat.h>
#include "compat.h"
#include "array.h"
#include "deltadelta.h"

View File

@ -739,13 +739,13 @@ validate_existing_constraints(Hypertable *ht, CompressColInfo *colinfo)
&is_null);
if (is_null)
{
#if PG12
#if PG12_LT
Oid oid = HeapTupleGetOid(tuple);
#else
Oid oid = heap_getattr(tuple,
Anum_pg_constraint_oid,
RelationGetDescr(pg_constr),
&is_null);
#else
Oid oid = HeapTupleGetOid(tuple);
#endif
elog(ERROR, "null conkey for constraint %u", oid);
}

View File

@ -4,10 +4,7 @@
* Please see the included NOTICE for copyright information and
* LICENSE-TIMESCALE for a copy of the license.
*/
#include "postgres.h"
#include "compression/dictionary.h"
#include <postgres.h>
#include <access/htup_details.h>
#include <access/tupmacs.h>
#include <catalog/pg_aggregate.h>
@ -21,9 +18,10 @@
#include <utils/syscache.h>
#include <utils/typcache.h>
#include <base64_compat.h>
#include "base64_compat.h"
#include "compression/compression.h"
#include "compression/dictionary.h"
#include "compression/simple8b_rle.h"
#include "compression/array.h"
#include "compression/dictionary_hash.h"

View File

@ -17,7 +17,7 @@
#include <funcapi.h>
#include <utils/typcache.h>
#include <compat.h>
#include "compat.h"
typedef struct HashMeta
{
@ -86,7 +86,7 @@ dictionary_hash_alloc(TypeCacheEntry *tentry)
{
HashMeta *meta = palloc(sizeof(*meta));
Oid collation = InvalidOid;
#if PG12
#if PG12_GE
collation = tentry->typcollation;
#endif

View File

@ -4,9 +4,6 @@
* LICENSE-TIMESCALE for a copy of the license.
*/
#include <postgres.h>
#include "compression/gorilla.h"
#include <access/htup_details.h>
#include <catalog/pg_type.h>
#include <funcapi.h>
@ -15,21 +12,17 @@
#include <utils/memutils.h>
#include "compat.h"
#include "export.h"
#include <utils.h>
#include "utils.h"
#include <adts/bit_array.h>
#include <base64_compat.h>
#include "compression/compression.h"
#include "compression/simple8b_rle.h"
#if PG12
#if PG12_GE
#include <port/pg_bitutils.h>
#endif
#include "compression/gorilla.h"
#include "utils.h"
#include "adts/bit_array.h"
#include "base64_compat.h"
#include "compression/compression.h"
#include "compression/simple8b_rle.h"
/*
* Gorilla compressed data is stored as
* uint16 compression_algorithm: id number for the compression scheme

View File

@ -64,9 +64,9 @@
#include <c.h>
#include <fmgr.h>
#include <lib/stringinfo.h>
#include "compression/compression.h"
#include <export.h>
#include "compression/compression.h"
#include "export.h"
typedef struct GorillaCompressor GorillaCompressor;
typedef struct GorillaCompressed GorillaCompressed;

View File

@ -53,7 +53,10 @@
#include <utils/typcache.h>
#include "compat.h"
#if PG12_GE
#if PG12_LT
#include <optimizer/clauses.h>
#include <optimizer/tlist.h>
#else
#include <optimizer/optimizer.h>
#endif

View File

@ -6,7 +6,6 @@
#ifndef TIMESCALEDB_TSL_CONTINUOUS_AGGS_CAGG_CREATE_H
#define TIMESCALEDB_TSL_CONTINUOUS_AGGS_CAGG_CREATE_H
#include <postgres.h>
#include <nodes/parsenodes.h>
#include "with_clause_parser.h"
#include "continuous_agg.h"

View File

@ -23,6 +23,8 @@
#include <interval.h>
#include <continuous_agg.h>
#include "compat.h"
#include "chunk.h"
#include "dimension.h"
#include "hypertable.h"
@ -35,8 +37,6 @@
#include "continuous_aggs/insert.h"
#include "compat.h"
/*
* When tuples in a hypertable that has a continuous aggregate are modified, the
* lowest modified value and the greatest modified value must be tracked over

View File

@ -7,7 +7,6 @@
#define TIMESCALEDB_TSL_CONTINUOUS_AGGS_INSERT_H
#include <postgres.h>
#include <fmgr.h>
extern Datum continuous_agg_trigfn(PG_FUNCTION_ARGS);

View File

@ -272,7 +272,7 @@ continuous_agg_materialize(int32 materialization_id, ContinuousAggMatOptions *op
materialization_invalidation_threshold);
}
relation_close(materialization_invalidation_log_table_relation, NoLock);
table_close(materialization_invalidation_log_table_relation, NoLock);
if (!options->within_single_transaction)
{
@ -1130,7 +1130,7 @@ invalidation_threshold_set(int32 raw_hypertable_id, int64 invalidation_threshold
Int64GetDatum(invalidation_threshold);
ts_catalog_insert_values(rel, desc, values, nulls);
relation_close(rel, NoLock);
table_close(rel, NoLock);
}
}
@ -1547,6 +1547,6 @@ continuous_aggs_completed_threshold_set(int32 materialization_id, int64 complete
Int64GetDatum(completed_threshold);
ts_catalog_insert_values(rel, desc, values, nulls);
relation_close(rel, NoLock);
table_close(rel, NoLock);
}
}

View File

@ -9,12 +9,9 @@
#include <nodes/bitmapset.h>
#include <nodes/makefuncs.h>
#include <nodes/nodeFuncs.h>
#include <optimizer/clauses.h>
#include <optimizer/cost.h>
#include <optimizer/pathnode.h>
#include <optimizer/paths.h>
#include <optimizer/restrictinfo.h>
#include <optimizer/tlist.h>
#include <parser/parsetree.h>
#include <utils/builtins.h>
#include <utils/lsyscache.h>
@ -23,13 +20,14 @@
#include "compat.h"
#if PG12_LT
#include <optimizer/var.h> /* f09346a */
#elif PG12_GE
#include <optimizer/clauses.h>
#include <optimizer/restrictinfo.h>
#include <optimizer/tlist.h>
#include <optimizer/var.h>
#else
#include <optimizer/optimizer.h>
#endif
#include "chunk.h"
#include "hypertable.h"
#include "hypertable_compression.h"
#include "compression/create.h"
#include "nodes/decompress_chunk/decompress_chunk.h"
@ -1027,7 +1025,7 @@ decompress_chunk_make_rte(Oid compressed_relid, LOCKMODE lockmode)
rte->rtekind = RTE_RELATION;
rte->relid = compressed_relid;
rte->relkind = r->rd_rel->relkind;
#if PG12
#if PG12_GE
rte->rellockmode = lockmode;
#endif
rte->eref = makeAlias(RelationGetRelationName(r), NULL);

View File

@ -10,14 +10,6 @@
#include <nodes/bitmapset.h>
#include <nodes/extensible.h>
#include "compat.h"
#if PG12_LT /* nodes/relation.h renamed in fa2cf16 */
#include <nodes/relation.h>
#else
#include <nodes/pathnodes.h>
#endif
#include "chunk.h"
#include "hypertable.h"

View File

@ -11,11 +11,6 @@
#include <nodes/bitmapset.h>
#include <nodes/makefuncs.h>
#include <nodes/nodeFuncs.h>
#include <optimizer/clauses.h>
#include <optimizer/cost.h>
#include <optimizer/plancat.h>
#include <optimizer/prep.h>
#include <optimizer/restrictinfo.h>
#include <parser/parsetree.h>
#include <rewrite/rewriteManip.h>
#include <utils/builtins.h>
@ -24,15 +19,6 @@
#include <utils/typcache.h>
#include "compat.h"
#if PG12_LT /* nodes/relation.h renamed in fa2cf16 */
#include <nodes/relation.h>
#include <optimizer/predtest.h>
#else
#include <nodes/pathnodes.h>
#include <optimizer/optimizer.h>
#endif
#include "compression/array.h"
#include "compression/compression.h"
#include "nodes/decompress_chunk/decompress_chunk.h"

View File

@ -8,18 +8,6 @@
#define TIMESCALEDB_DECOMPRESS_CHUNK_EXEC_H
#include <postgres.h>
#include <nodes/bitmapset.h>
#include <nodes/extensible.h>
#include "compat.h"
#if PG12_LT /* nodes/relation.h renamed in fa2cf16 */
#include <nodes/relation.h>
#else
#include <nodes/pathnodes.h>
#endif
#include "compression/compression.h"
#define DECOMPRESS_CHUNK_COUNT_ID -9
#define DECOMPRESS_CHUNK_SEQUENCE_NUM_ID -10

View File

@ -12,14 +12,8 @@
#include <nodes/extensible.h>
#include <nodes/makefuncs.h>
#include <nodes/nodeFuncs.h>
#include <optimizer/clauses.h>
#include <optimizer/pathnode.h>
#include <optimizer/paths.h>
#include <optimizer/placeholder.h>
#include <optimizer/planmain.h>
#include <optimizer/prep.h>
#include <optimizer/restrictinfo.h>
#include <optimizer/subselect.h>
#include <optimizer/tlist.h>
#include <parser/parsetree.h>
#include <utils/builtins.h>
@ -27,11 +21,18 @@
#include "compat.h"
#if PG12_LT
#include <optimizer/var.h> /* f09346a */
#elif PG12_GE
#include <optimizer/clauses.h>
#include <optimizer/pathnode.h>
#include <optimizer/placeholder.h>
#include <optimizer/planmain.h>
#include <optimizer/prep.h>
#include <optimizer/subselect.h>
#include <optimizer/var.h>
#else
#include <optimizer/optimizer.h>
#endif
#include "compression/compression.h"
#include "compression/create.h"
#include "nodes/decompress_chunk/decompress_chunk.h"
#include "nodes/decompress_chunk/planner.h"

View File

@ -8,15 +8,6 @@
#define TIMESCALEDB_DECOMPRESS_CHUNK_PLANNER_H
#include <postgres.h>
#include <nodes/extensible.h>
#include "compat.h"
#if PG12_LT /* nodes/relation.h renamed in fa2cf16 */
#include <nodes/relation.h>
#else
#include <nodes/pathnodes.h>
#endif
extern Plan *decompress_chunk_plan_create(PlannerInfo *root, RelOptInfo *rel, CustomPath *path,
List *tlist, List *clauses, List *custom_plans);

View File

@ -7,22 +7,19 @@
#include <postgres.h>
#include <nodes/makefuncs.h>
#include <nodes/nodeFuncs.h>
#include <optimizer/clauses.h>
#include <optimizer/pathnode.h>
#include <optimizer/restrictinfo.h>
#include <optimizer/tlist.h>
#include <parser/parsetree.h>
#include <parser/parse_func.h>
#include <utils/builtins.h>
#include <utils/typcache.h>
#include "compat.h"
#if PG12_LT /* nodes/relation.h renamed in fa2cf16 */
#include <nodes/relation.h>
#include <optimizer/var.h> /* f09346a */
#if PG12_LT
#include <optimizer/clauses.h>
#include <optimizer/pathnode.h>
#include <optimizer/tlist.h>
#include <optimizer/var.h>
#else
#include <nodes/pathnodes.h>
#include <optimizer/optimizer.h>
#endif

View File

@ -6,7 +6,5 @@
#include <postgres.h>
#include "nodes/decompress_chunk/decompress_chunk.h"
void pushdown_quals(PlannerInfo *root, RelOptInfo *chunk_rel, RelOptInfo *compressed_rel,
List *compression_info);

View File

@ -25,8 +25,8 @@
#include "compat.h"
#if PG12_LT
#include <optimizer/var.h> /* f09346a */
#elif PG12_GE
#include <optimizer/var.h>
#else
#include <optimizer/optimizer.h>
#endif

View File

@ -8,7 +8,6 @@
#include <postgres.h>
#include <nodes/execnodes.h>
#include <executor/tuptable.h>
/*
* GapFillFetchState describes the state of subslot in GapFillState:

View File

@ -11,15 +11,15 @@
#include <optimizer/clauses.h>
#include <optimizer/pathnode.h>
#include <optimizer/paths.h>
#include <optimizer/planner.h>
#include <optimizer/tlist.h>
#include <utils/lsyscache.h>
#include <parser/parse_func.h>
#include "compat.h"
#if PG12_LT
#include <optimizer/var.h> /* f09346a */
#elif PG12_GE
#include <optimizer/planner.h>
#include <optimizer/var.h>
#else
#include <optimizer/optimizer.h>
#endif

View File

@ -7,7 +7,6 @@
#define TIMESCALEDB_TSL_NODES_GAPFILL_PLANNER_H
#include <postgres.h>
#include <optimizer/planner.h>
void plan_add_gapfill(PlannerInfo *, RelOptInfo *);
void gapfill_adjust_window_targetlist(PlannerInfo *root, RelOptInfo *input_rel,

View File

@ -669,7 +669,7 @@ copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex, bool verbose,
get_namespace_name(RelationGetNamespace(OldHeap)),
RelationGetRelationName(OldHeap))));
#if PG12
#if PG12_GE
table_relation_copy_for_cluster(OldHeap,
NewHeap,
OldIndex,
@ -1055,16 +1055,16 @@ finish_heap_swaps(Oid OIDOldHeap, Oid OIDNewHeap, List *old_index_oids, List *ne
RenameRelationInternalCompat(toastidx, NewToastName, true, true);
}
relation_close(newrel, NoLock);
table_close(newrel, NoLock);
}
#if PG12
#if PG12_GE
/* it's not a catalog table, clear any missing attribute settings */
{
Relation newrel;
newrel = table_open(OIDOldHeap, NoLock);
RelationClearMissing(newrel);
relation_close(newrel, NoLock);
table_close(newrel, NoLock);
}
#endif
}

View File

@ -8,10 +8,6 @@
#define TIMESCALEDB_TSL_REORDER_H
#include <postgres.h>
#include <fmgr.h>
#include <nodes/parsenodes.h>
#include <storage/lock.h>
#include <utils/relcache.h>
extern Datum tsl_reorder_chunk(PG_FUNCTION_ARGS);
extern Datum tsl_move_chunk(PG_FUNCTION_ARGS);