diff --git a/src/chunk_adaptive.c b/src/chunk_adaptive.c index 1df35897d..8524a8f8b 100644 --- a/src/chunk_adaptive.c +++ b/src/chunk_adaptive.c @@ -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 diff --git a/src/chunk_append/chunk_append.c b/src/chunk_append/chunk_append.c index 2a525fac4..e464b9d8b 100644 --- a/src/chunk_append/chunk_append.c +++ b/src/chunk_append/chunk_append.c @@ -5,7 +5,6 @@ */ #include #include -#include #include #include #include @@ -14,12 +13,12 @@ #include "compat.h" #if PG12_LT -#include /* f09346a */ -#elif PG12_GE +#include +#include +#else #include #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 */ diff --git a/src/chunk_append/chunk_append.h b/src/chunk_append/chunk_append.h index fb8a66493..eab90d9d4 100644 --- a/src/chunk_append/chunk_append.h +++ b/src/chunk_append/chunk_append.h @@ -7,11 +7,10 @@ #define TIMESCALEDB_CHUNK_APPEND_H #include +#include #include "compat.h" - -#include -#if PG12_LT /* nodes/relation.h renamed in fa2cf16 */ +#if PG12_LT #include #else #include diff --git a/src/chunk_append/exec.c b/src/chunk_append/exec.c index 65fb5b8d8..a2a3a4bfc 100644 --- a/src/chunk_append/exec.c +++ b/src/chunk_append/exec.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -25,8 +24,8 @@ #include #include "compat.h" - -#if PG12_LT /* nodes/relation.h renamed in fa2cf16 */ +#if PG12_LT +#include #include #include #else @@ -34,8 +33,8 @@ #include #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 } diff --git a/src/chunk_append/exec.h b/src/chunk_append/exec.h index f4f0d35d3..881e19e7b 100644 --- a/src/chunk_append/exec.h +++ b/src/chunk_append/exec.h @@ -10,14 +10,6 @@ #include #include -#include "compat.h" - -#if PG12_LT /* nodes/relation.h renamed in fa2cf16 */ -#include -#else -#include -#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; diff --git a/src/chunk_append/planner.c b/src/chunk_append/planner.c index acb3e23ff..6afd2ecae 100644 --- a/src/chunk_append/planner.c +++ b/src/chunk_append/planner.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -21,8 +20,9 @@ #include "compat.h" #if PG12_LT -#include /* f09346a */ -#elif PG12_GE +#include +#include +#else #include #include #endif diff --git a/src/chunk_append/planner.h b/src/chunk_append/planner.h index d4097fd39..3eec79522 100644 --- a/src/chunk_append/planner.h +++ b/src/chunk_append/planner.h @@ -9,14 +9,6 @@ #include #include -#include "compat.h" - -#if PG12_LT /* nodes/relation.h renamed in fa2cf16 */ -#include -#else -#include -#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); diff --git a/src/chunk_append/transform.c b/src/chunk_append/transform.c index 05e2c7726..c16f422d6 100644 --- a/src/chunk_append/transform.c +++ b/src/chunk_append/transform.c @@ -8,9 +8,15 @@ #include #include #include -#include #include +#include "compat.h" +#ifdef PG12_LT +#include +#else +#include +#endif + #include "chunk_append/transform.h" #include "utils.h" diff --git a/src/chunk_append/transform.h b/src/chunk_append/transform.h index fab5d9e62..3743faa07 100644 --- a/src/chunk_append/transform.h +++ b/src/chunk_append/transform.h @@ -9,14 +9,6 @@ #include #include -#include "compat.h" - -#if PG12_LT /* nodes/relation.h renamed in fa2cf16 */ -#include -#else -#include -#endif - extern Expr *ts_transform_cross_datatype_comparison(Expr *clause); #endif /* TIMESCALEDB_CHUNK_APPEND_TRANSFORM_H */ diff --git a/src/chunk_dispatch_state.c b/src/chunk_dispatch_state.c index 89ef55c83..06603f713 100644 --- a/src/chunk_dispatch_state.c +++ b/src/chunk_dispatch_state.c @@ -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 } diff --git a/src/chunk_dispatch_state.h b/src/chunk_dispatch_state.h index e8b57dd77..d6eb49365 100644 --- a/src/chunk_dispatch_state.h +++ b/src/chunk_dispatch_state.h @@ -33,7 +33,7 @@ typedef struct ChunkDispatchState * for each chunk. */ ChunkDispatch *dispatch; -#if PG12 +#if PG12_GE TupleTableSlot *slot; #endif } ChunkDispatchState; diff --git a/src/chunk_index.c b/src/chunk_index.c index fd3b2812a..3e9aecf43 100644 --- a/src/chunk_index.c +++ b/src/chunk_index.c @@ -25,19 +25,17 @@ #include "compat.h" #if PG12_LT -#include /* f09346a */ -#elif PG12_GE +#include +#else #include #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); diff --git a/src/chunk_index.h b/src/chunk_index.h index 32ca6c5a0..45cb78308 100644 --- a/src/chunk_index.h +++ b/src/chunk_index.h @@ -12,8 +12,8 @@ #include #include -#include -#include +#include "compat.h" +#include "export.h" typedef struct Chunk Chunk; typedef struct Hypertable Hypertable; diff --git a/src/chunk_insert_state.c b/src/chunk_insert_state.c index 120b2f0e0..83281f2f3 100644 --- a/src/chunk_insert_state.c +++ b/src/chunk_insert_state.c @@ -12,9 +12,6 @@ #include #include #include -#include -#include -#include #include #include #include @@ -22,15 +19,18 @@ #include #include "compat.h" -#if PG12 +#if PG12_LT +#include +#include +#include +#else #include #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); diff --git a/src/chunk_insert_state.h b/src/chunk_insert_state.h index 8bebe1a4e..e6673f1dc 100644 --- a/src/chunk_insert_state.h +++ b/src/chunk_insert_state.h @@ -11,11 +11,7 @@ #include #include -#include "hypertable.h" #include "chunk.h" -#include "cache.h" -#include "chunk_dispatch_state.h" -#include "compat.h" typedef struct ChunkInsertState { diff --git a/src/compat.h b/src/compat.h index 97228db0c..17626c0b8 100644 --- a/src/compat.h +++ b/src/compat.h @@ -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 diff --git a/src/constraint_aware_append.c b/src/constraint_aware_append.c index 3a5c28fb3..ce68c7540 100644 --- a/src/constraint_aware_append.c +++ b/src/constraint_aware_append.c @@ -15,9 +15,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -25,8 +23,10 @@ #include #include "compat.h" - -#if PG12_GE +#if PG12_LT +#include +#include +#else #include #include #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 } diff --git a/src/constraint_aware_append.h b/src/constraint_aware_append.h index a9457ff9d..2d6310cb7 100644 --- a/src/constraint_aware_append.h +++ b/src/constraint_aware_append.h @@ -9,14 +9,6 @@ #include #include -#include "compat.h" - -#if PG12_LT /* nodes/relation.h renamed in fa2cf16 */ -#include -#else -#include -#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; diff --git a/src/copy.c b/src/copy.c index faee6face..734aec910 100644 --- a/src/copy.c +++ b/src/copy.c @@ -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 diff --git a/src/dimension_slice.h b/src/dimension_slice.h index f28d45d41..7fd896abf 100644 --- a/src/dimension_slice.h +++ b/src/dimension_slice.h @@ -9,8 +9,6 @@ #include #include -#include "catalog.h" -#include "dimension.h" #include "chunk_constraint.h" #define DIMENSION_SLICE_MAXVALUE ((int64) PG_INT64_MAX) diff --git a/src/estimate.c b/src/estimate.c index d5175a618..173dd1c40 100644 --- a/src/estimate.c +++ b/src/estimate.c @@ -6,20 +6,22 @@ #include #include #include -#include -#include -#include #include +#include "compat.h" +#if PG12_LT +#include +#include +#include +#else +#include +#endif + #include "func_cache.h" #include "estimate.h" #include "planner_import.h" #include "utils.h" -#include "compat.h" -#if PG12 -#include -#endif /* * This module contains functions for estimating, e.g., the number of groups * formed in various grouping expressions that involve time bucketing. diff --git a/src/extension_utils.c b/src/extension_utils.c index cd448bd31..a95196bdb 100644 --- a/src/extension_utils.c +++ b/src/extension_utils.c @@ -25,7 +25,7 @@ #include #include "compat.h" -#if PG12 +#if PG12_GE #include #endif diff --git a/src/func_cache.c b/src/func_cache.c index 9509f23ea..b82502464 100644 --- a/src/func_cache.c +++ b/src/func_cache.c @@ -6,8 +6,6 @@ #include #include #include -#include -#include #include #include #include @@ -21,8 +19,12 @@ #include #include "compat.h" - -#if PG12 +#if PG12_LT +#include +#include +#include +#else +#include #include #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 } diff --git a/src/hypertable_restrict_info.c b/src/hypertable_restrict_info.c index 97f7c794e..28d34eb47 100644 --- a/src/hypertable_restrict_info.c +++ b/src/hypertable_restrict_info.c @@ -5,13 +5,14 @@ */ #include #include -#include #include #include #include #include "compat.h" -#if PG12_GE +#if PG12_LT +#include +#else #include #endif diff --git a/src/indexing.c b/src/indexing.c index 2dc2d2192..48c98bc54 100644 --- a/src/indexing.c +++ b/src/indexing.c @@ -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. diff --git a/src/partitioning.c b/src/partitioning.c index 6814d6ee2..79d9bf7cf 100644 --- a/src/partitioning.c +++ b/src/partitioning.c @@ -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); diff --git a/src/plan_add_hashagg.c b/src/plan_add_hashagg.c index bb2442c46..fe5cd194d 100644 --- a/src/plan_add_hashagg.c +++ b/src/plan_add_hashagg.c @@ -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 */ diff --git a/src/plan_add_hashagg.h b/src/plan_add_hashagg.h index 4d4e4f890..026365aab 100644 --- a/src/plan_add_hashagg.h +++ b/src/plan_add_hashagg.h @@ -6,15 +6,6 @@ #ifndef TIMESCALEDB_PLAN_ADD_HASHAGG_H #define TIMESCALEDB_PLAN_ADD_HASHAGG_H -#include "compat.h" - -#include -#if PG12_LT /* nodes/relation.h renamed in fa2cf16 */ -#include -#else -#include -#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 diff --git a/src/plan_agg_bookend.c b/src/plan_agg_bookend.c index 2edb0b5d2..6f5a3259b 100644 --- a/src/plan_agg_bookend.c +++ b/src/plan_agg_bookend.c @@ -32,40 +32,42 @@ * * */ -#include "postgres.h" +#include -#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 +#include #include -#include "utils/typcache.h" -#include "access/stratnum.h" -#include "plan_agg_bookend.h" -#include "utils.h" -#include "extension.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "compat.h" - -#if PG12 -#include "optimizer/optimizer.h" +#if PG12_LT +#include +#else +#include #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 */ diff --git a/src/plan_agg_bookend.h b/src/plan_agg_bookend.h index d2e72c183..95435389a 100644 --- a/src/plan_agg_bookend.h +++ b/src/plan_agg_bookend.h @@ -6,14 +6,5 @@ #ifndef TIMESCALEDB_PLAN_AGG_BOOKEND_H #define TIMESCALEDB_PLAN_AGG_BOOKEND_H -#include "compat.h" - -#include -#if PG12_LT /* nodes/relation.h renamed in fa2cf16 */ -#include -#else -#include -#endif - extern void ts_preprocess_first_last_aggregates(PlannerInfo *root, List *tlist); #endif /* TIMESCALEDB_PLAN_AGG_BOOKEND_H */ diff --git a/src/plan_expand_hypertable.c b/src/plan_expand_hypertable.c index b142bcbd0..49d339b28 100644 --- a/src/plan_expand_hypertable.c +++ b/src/plan_expand_hypertable.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include @@ -33,7 +32,8 @@ #endif #if PG12_LT -#include /* f09346a */ +#include +#include #elif PG12_GE #include #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 diff --git a/src/plan_partialize.c b/src/plan_partialize.c index c13da39d7..b5a49e456 100644 --- a/src/plan_partialize.c +++ b/src/plan_partialize.c @@ -8,16 +8,21 @@ #include #include #include -#if PG12_LT -#include -#include -#endif #include #include #include #include #include +#include "compat.h" +#if PG12_LT +#include +#include +#else +#include +#include +#endif + #include "plan_partialize.h" #include "extension_constants.h" #include "utils.h" diff --git a/src/planner.c b/src/planner.c index bf7580b6c..0a0b26e37 100644 --- a/src/planner.c +++ b/src/planner.c @@ -4,6 +4,7 @@ * LICENSE-APACHE for a copy of the license. */ #include +#include #include #include #include @@ -38,8 +39,8 @@ #include "compat-msvc-exit.h" #if PG12_LT -#include /* f09346a */ -#elif PG12_GE +#include +#else #include #include #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)) { diff --git a/src/planner_import.c b/src/planner_import.c index 8b72662a7..8f31498ab 100644 --- a/src/planner_import.c +++ b/src/planner_import.c @@ -21,23 +21,22 @@ #include #include #include -#include #include #include #include #include -#include #include #include #include #include #include -#include #include "compat.h" #if PG12_LT -#include /* f09346a */ -#elif PG12_GE +#include +#include +#include +#else #include #endif diff --git a/src/planner_import.h b/src/planner_import.h index 844784676..8852f55ae 100644 --- a/src/planner_import.h +++ b/src/planner_import.h @@ -18,13 +18,8 @@ #define TIMESCALEDB_PLANNER_IMPORT_H #include -#include -#include -#include #include -#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, diff --git a/src/process_utility.c b/src/process_utility.c index 654745538..8bdaa4be1 100644 --- a/src/process_utility.c +++ b/src/process_utility.c @@ -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: diff --git a/src/scanner.c b/src/scanner.c index 986938664..9e370b62b 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -10,7 +10,6 @@ #include #include -#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; diff --git a/src/scanner.h b/src/scanner.h index 48fb84167..37d36cf99 100644 --- a/src/scanner.h +++ b/src/scanner.h @@ -8,14 +8,11 @@ #include #include -#include #include #include -#include #include #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 */ diff --git a/src/utils.c b/src/utils.c index aeead44fa..6eb1099e1 100644 --- a/src/utils.c +++ b/src/utils.c @@ -27,21 +27,14 @@ #include #include -#include "chunk.h" -#include "utils.h" #include "compat.h" - -#include -#if PG12_LT /* nodes/relation.h renamed in fa2cf16 */ -#include -#else -#include -#endif - #if !PG96 #include #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); } diff --git a/src/utils.h b/src/utils.h index ea941c22c..7da24aa3a 100644 --- a/src/utils.h +++ b/src/utils.h @@ -7,23 +7,12 @@ #define TIMESCALEDB_UTILS_H #include -#include #include #include #include #include "compat.h" -#include -#if PG12_LT /* nodes/relation.h renamed in fa2cf16 */ -#include -#else -#include -#endif - -#include "export.h" -#include "compat.h" - #if PG11_GE #include #endif diff --git a/test/src/bgw/params.c b/test/src/bgw/params.c index fcd728ee1..92368837f 100644 --- a/test/src/bgw/params.c +++ b/test/src/bgw/params.c @@ -15,16 +15,16 @@ #include #include +#include "compat.h" +#if PG12_LT +#include +#endif + #include "params.h" #include "timer_mock.h" #include "log.h" #include "scanner.h" #include "catalog.h" -#include "compat.h" - -#if PG12_LT -#include -#endif typedef struct FormData_bgw_dsm_handle { diff --git a/test/src/bgw/timer_mock.c b/test/src/bgw/timer_mock.c index 7d9e8e5e8..2fe9eaa7b 100644 --- a/test/src/bgw/timer_mock.c +++ b/test/src/bgw/timer_mock.c @@ -13,18 +13,18 @@ #include #include +#include "compat.h" +#if PG12_LT +#include +#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 -#endif - static BackgroundWorkerHandle *bgw_handle = NULL; static bool mock_wait(TimestampTz until); diff --git a/tsl/src/bgw_policy/reorder_api.c b/tsl/src/bgw_policy/reorder_api.c index a199fbb52..e683076b8 100644 --- a/tsl/src/bgw_policy/reorder_api.c +++ b/tsl/src/bgw_policy/reorder_api.c @@ -25,9 +25,6 @@ #include "license.h" #include "reorder_api.h" #include "utils.h" -#include "hypertable.h" -#include "bgw/job.h" -#include /* * Default scheduled interval for reorder jobs should be 1/2 of the default chunk length. diff --git a/tsl/src/compression/compression.c b/tsl/src/compression/compression.c index 44afa18ad..1033494bd 100644 --- a/tsl/src/compression/compression.c +++ b/tsl/src/compression/compression.c @@ -34,7 +34,7 @@ #include #include -#include +#include "compat.h" #include "array.h" #include "deltadelta.h" diff --git a/tsl/src/compression/create.c b/tsl/src/compression/create.c index 1d0ea4c99..c3d241d26 100644 --- a/tsl/src/compression/create.c +++ b/tsl/src/compression/create.c @@ -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); } diff --git a/tsl/src/compression/dictionary.c b/tsl/src/compression/dictionary.c index 2a5d60f9e..6368d4844 100644 --- a/tsl/src/compression/dictionary.c +++ b/tsl/src/compression/dictionary.c @@ -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 #include #include #include @@ -21,9 +18,10 @@ #include #include -#include +#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" diff --git a/tsl/src/compression/dictionary_hash.h b/tsl/src/compression/dictionary_hash.h index 93837f287..f88c06858 100644 --- a/tsl/src/compression/dictionary_hash.h +++ b/tsl/src/compression/dictionary_hash.h @@ -17,7 +17,7 @@ #include #include -#include +#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 diff --git a/tsl/src/compression/gorilla.c b/tsl/src/compression/gorilla.c index 19d0de037..9939b3e26 100644 --- a/tsl/src/compression/gorilla.c +++ b/tsl/src/compression/gorilla.c @@ -4,9 +4,6 @@ * LICENSE-TIMESCALE for a copy of the license. */ #include - -#include "compression/gorilla.h" - #include #include #include @@ -15,21 +12,17 @@ #include #include "compat.h" -#include "export.h" - -#include -#include "utils.h" - -#include -#include - -#include "compression/compression.h" -#include "compression/simple8b_rle.h" - -#if PG12 +#if PG12_GE #include #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 diff --git a/tsl/src/compression/gorilla.h b/tsl/src/compression/gorilla.h index 8eb7dba30..8dd45350e 100644 --- a/tsl/src/compression/gorilla.h +++ b/tsl/src/compression/gorilla.h @@ -64,9 +64,9 @@ #include #include #include -#include "compression/compression.h" -#include +#include "compression/compression.h" +#include "export.h" typedef struct GorillaCompressor GorillaCompressor; typedef struct GorillaCompressed GorillaCompressed; diff --git a/tsl/src/continuous_aggs/create.c b/tsl/src/continuous_aggs/create.c index fc0e6035d..e718533be 100644 --- a/tsl/src/continuous_aggs/create.c +++ b/tsl/src/continuous_aggs/create.c @@ -53,7 +53,10 @@ #include #include "compat.h" -#if PG12_GE +#if PG12_LT +#include +#include +#else #include #endif diff --git a/tsl/src/continuous_aggs/create.h b/tsl/src/continuous_aggs/create.h index 95308d0f1..3f0000747 100644 --- a/tsl/src/continuous_aggs/create.h +++ b/tsl/src/continuous_aggs/create.h @@ -6,7 +6,6 @@ #ifndef TIMESCALEDB_TSL_CONTINUOUS_AGGS_CAGG_CREATE_H #define TIMESCALEDB_TSL_CONTINUOUS_AGGS_CAGG_CREATE_H #include -#include #include "with_clause_parser.h" #include "continuous_agg.h" diff --git a/tsl/src/continuous_aggs/insert.c b/tsl/src/continuous_aggs/insert.c index 364b234f5..e3d1fde26 100644 --- a/tsl/src/continuous_aggs/insert.c +++ b/tsl/src/continuous_aggs/insert.c @@ -23,6 +23,8 @@ #include #include +#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 diff --git a/tsl/src/continuous_aggs/insert.h b/tsl/src/continuous_aggs/insert.h index b3e418cdb..e4e53c613 100644 --- a/tsl/src/continuous_aggs/insert.h +++ b/tsl/src/continuous_aggs/insert.h @@ -7,7 +7,6 @@ #define TIMESCALEDB_TSL_CONTINUOUS_AGGS_INSERT_H #include -#include extern Datum continuous_agg_trigfn(PG_FUNCTION_ARGS); diff --git a/tsl/src/continuous_aggs/materialize.c b/tsl/src/continuous_aggs/materialize.c index c96a802c4..8792c7b7f 100644 --- a/tsl/src/continuous_aggs/materialize.c +++ b/tsl/src/continuous_aggs/materialize.c @@ -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); } } diff --git a/tsl/src/nodes/decompress_chunk/decompress_chunk.c b/tsl/src/nodes/decompress_chunk/decompress_chunk.c index ada68f8a4..bedefb06c 100644 --- a/tsl/src/nodes/decompress_chunk/decompress_chunk.c +++ b/tsl/src/nodes/decompress_chunk/decompress_chunk.c @@ -9,12 +9,9 @@ #include #include #include -#include #include #include #include -#include -#include #include #include #include @@ -23,13 +20,14 @@ #include "compat.h" #if PG12_LT -#include /* f09346a */ -#elif PG12_GE +#include +#include +#include +#include +#else #include #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); diff --git a/tsl/src/nodes/decompress_chunk/decompress_chunk.h b/tsl/src/nodes/decompress_chunk/decompress_chunk.h index 8fd143e19..96ce31d63 100644 --- a/tsl/src/nodes/decompress_chunk/decompress_chunk.h +++ b/tsl/src/nodes/decompress_chunk/decompress_chunk.h @@ -10,14 +10,6 @@ #include #include -#include "compat.h" - -#if PG12_LT /* nodes/relation.h renamed in fa2cf16 */ -#include -#else -#include -#endif - #include "chunk.h" #include "hypertable.h" diff --git a/tsl/src/nodes/decompress_chunk/exec.c b/tsl/src/nodes/decompress_chunk/exec.c index e8c723706..cc0c9039e 100644 --- a/tsl/src/nodes/decompress_chunk/exec.c +++ b/tsl/src/nodes/decompress_chunk/exec.c @@ -11,11 +11,6 @@ #include #include #include -#include -#include -#include -#include -#include #include #include #include @@ -24,15 +19,6 @@ #include #include "compat.h" - -#if PG12_LT /* nodes/relation.h renamed in fa2cf16 */ -#include -#include -#else -#include -#include -#endif - #include "compression/array.h" #include "compression/compression.h" #include "nodes/decompress_chunk/decompress_chunk.h" diff --git a/tsl/src/nodes/decompress_chunk/exec.h b/tsl/src/nodes/decompress_chunk/exec.h index 693d58af4..b439eec08 100644 --- a/tsl/src/nodes/decompress_chunk/exec.h +++ b/tsl/src/nodes/decompress_chunk/exec.h @@ -8,18 +8,6 @@ #define TIMESCALEDB_DECOMPRESS_CHUNK_EXEC_H #include -#include -#include - -#include "compat.h" - -#if PG12_LT /* nodes/relation.h renamed in fa2cf16 */ -#include -#else -#include -#endif - -#include "compression/compression.h" #define DECOMPRESS_CHUNK_COUNT_ID -9 #define DECOMPRESS_CHUNK_SEQUENCE_NUM_ID -10 diff --git a/tsl/src/nodes/decompress_chunk/planner.c b/tsl/src/nodes/decompress_chunk/planner.c index 7dd81649c..e75a996b7 100644 --- a/tsl/src/nodes/decompress_chunk/planner.c +++ b/tsl/src/nodes/decompress_chunk/planner.c @@ -12,14 +12,8 @@ #include #include #include -#include -#include #include -#include -#include -#include #include -#include #include #include #include @@ -27,11 +21,18 @@ #include "compat.h" #if PG12_LT -#include /* f09346a */ -#elif PG12_GE +#include +#include +#include +#include +#include +#include +#include +#else #include #endif +#include "compression/compression.h" #include "compression/create.h" #include "nodes/decompress_chunk/decompress_chunk.h" #include "nodes/decompress_chunk/planner.h" diff --git a/tsl/src/nodes/decompress_chunk/planner.h b/tsl/src/nodes/decompress_chunk/planner.h index b5263cea1..e211b823b 100644 --- a/tsl/src/nodes/decompress_chunk/planner.h +++ b/tsl/src/nodes/decompress_chunk/planner.h @@ -8,15 +8,6 @@ #define TIMESCALEDB_DECOMPRESS_CHUNK_PLANNER_H #include -#include - -#include "compat.h" - -#if PG12_LT /* nodes/relation.h renamed in fa2cf16 */ -#include -#else -#include -#endif extern Plan *decompress_chunk_plan_create(PlannerInfo *root, RelOptInfo *rel, CustomPath *path, List *tlist, List *clauses, List *custom_plans); diff --git a/tsl/src/nodes/decompress_chunk/qual_pushdown.c b/tsl/src/nodes/decompress_chunk/qual_pushdown.c index 4662a35d8..e1ea15805 100644 --- a/tsl/src/nodes/decompress_chunk/qual_pushdown.c +++ b/tsl/src/nodes/decompress_chunk/qual_pushdown.c @@ -7,22 +7,19 @@ #include #include #include -#include -#include #include -#include #include #include #include #include #include "compat.h" - -#if PG12_LT /* nodes/relation.h renamed in fa2cf16 */ -#include -#include /* f09346a */ +#if PG12_LT +#include +#include +#include +#include #else -#include #include #endif diff --git a/tsl/src/nodes/decompress_chunk/qual_pushdown.h b/tsl/src/nodes/decompress_chunk/qual_pushdown.h index 453e7d03a..8a9e926bf 100644 --- a/tsl/src/nodes/decompress_chunk/qual_pushdown.h +++ b/tsl/src/nodes/decompress_chunk/qual_pushdown.h @@ -6,7 +6,5 @@ #include -#include "nodes/decompress_chunk/decompress_chunk.h" - void pushdown_quals(PlannerInfo *root, RelOptInfo *chunk_rel, RelOptInfo *compressed_rel, List *compression_info); diff --git a/tsl/src/nodes/gapfill/exec.c b/tsl/src/nodes/gapfill/exec.c index 6a7f92c41..951f77b21 100644 --- a/tsl/src/nodes/gapfill/exec.c +++ b/tsl/src/nodes/gapfill/exec.c @@ -25,8 +25,8 @@ #include "compat.h" #if PG12_LT -#include /* f09346a */ -#elif PG12_GE +#include +#else #include #endif diff --git a/tsl/src/nodes/gapfill/exec.h b/tsl/src/nodes/gapfill/exec.h index b8c801c69..9a61f9b9e 100644 --- a/tsl/src/nodes/gapfill/exec.h +++ b/tsl/src/nodes/gapfill/exec.h @@ -8,7 +8,6 @@ #include #include -#include /* * GapFillFetchState describes the state of subslot in GapFillState: diff --git a/tsl/src/nodes/gapfill/planner.c b/tsl/src/nodes/gapfill/planner.c index 259021d40..25dc794d7 100644 --- a/tsl/src/nodes/gapfill/planner.c +++ b/tsl/src/nodes/gapfill/planner.c @@ -11,15 +11,15 @@ #include #include #include -#include #include #include #include #include "compat.h" #if PG12_LT -#include /* f09346a */ -#elif PG12_GE +#include +#include +#else #include #endif diff --git a/tsl/src/nodes/gapfill/planner.h b/tsl/src/nodes/gapfill/planner.h index ed01a8cbd..d3fe60a5b 100644 --- a/tsl/src/nodes/gapfill/planner.h +++ b/tsl/src/nodes/gapfill/planner.h @@ -7,7 +7,6 @@ #define TIMESCALEDB_TSL_NODES_GAPFILL_PLANNER_H #include -#include void plan_add_gapfill(PlannerInfo *, RelOptInfo *); void gapfill_adjust_window_targetlist(PlannerInfo *root, RelOptInfo *input_rel, diff --git a/tsl/src/reorder.c b/tsl/src/reorder.c index 47f40e1e9..9f46a074e 100644 --- a/tsl/src/reorder.c +++ b/tsl/src/reorder.c @@ -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 } diff --git a/tsl/src/reorder.h b/tsl/src/reorder.h index f8d39514a..6618f0c02 100644 --- a/tsl/src/reorder.h +++ b/tsl/src/reorder.h @@ -8,10 +8,6 @@ #define TIMESCALEDB_TSL_REORDER_H #include -#include -#include -#include -#include extern Datum tsl_reorder_chunk(PG_FUNCTION_ARGS); extern Datum tsl_move_chunk(PG_FUNCTION_ARGS);