diff --git a/src/chunk_dispatch.c b/src/chunk_dispatch.c index a0731f081..2b5562472 100644 --- a/src/chunk_dispatch.c +++ b/src/chunk_dispatch.c @@ -59,5 +59,6 @@ chunk_dispatch_get_chunk_insert_state(ChunkDispatch *dispatch, Point *point) subspace_store_add(dispatch->cache, new_chunk->cube, cis, destroy_chunk_insert_state); } + Assert(cis != NULL); return cis; } diff --git a/src/copy.c b/src/copy.c index f239f25ec..ceabec3b3 100644 --- a/src/copy.c +++ b/src/copy.c @@ -248,6 +248,8 @@ timescaledb_CopyFrom(CopyState cstate, Relation main_rel, List *range_table, Hyp /* Find or create the insert state matching the point */ cis = chunk_dispatch_get_chunk_insert_state(dispatch, point); + Assert(cis != NULL); + if (cis != prev_cis) { /* Different chunk so must release BulkInsertState */ diff --git a/src/dimension_slice.c b/src/dimension_slice.c index 304711f16..b3ec0c1fc 100644 --- a/src/dimension_slice.c +++ b/src/dimension_slice.c @@ -25,7 +25,6 @@ dimension_slice_from_form_data(Form_dimension_slice fd) { DimensionSlice *slice = dimension_slice_alloc(); - slice = palloc0(sizeof(DimensionSlice)); memcpy(&slice->fd, fd, sizeof(FormData_dimension_slice)); slice->storage_free = NULL; slice->storage = NULL; diff --git a/src/dimension_vector.c b/src/dimension_vector.c index 00242a184..b21469044 100644 --- a/src/dimension_vector.c +++ b/src/dimension_vector.c @@ -94,7 +94,7 @@ dimension_vec_add_slice(DimensionVec **vecptr, DimensionSlice *slice) DimensionVec * dimension_vec_add_slice_sort(DimensionVec **vecptr, DimensionSlice *slice) { - DimensionVec *vec = *vecptr; + DimensionVec *vec; *vecptr = vec = dimension_vec_add_slice(vecptr, slice); return dimension_vec_sort(vecptr); diff --git a/src/planner_utils.c b/src/planner_utils.c index 7a44a74f6..49c512fc2 100644 --- a/src/planner_utils.c +++ b/src/planner_utils.c @@ -7,7 +7,8 @@ static void plantree_walker(Plan **plan, void (*walker) (Plan **, void *), void *ctx); static inline void -plantree_walk_subplans(List *plans, void (*walker) (Plan **, void *), void *ctx) +plantree_walk_subplans(List *plans, + void (*walker) (Plan **, void *), void *ctx) { ListCell *lc; @@ -21,7 +22,9 @@ plantree_walk_subplans(List *plans, void (*walker) (Plan **, void *), void *ctx) /* A plan tree walker. Similar to planstate_tree_walker in PostgreSQL's * nodeFuncs.c, but this walks a Plan tree as opposed to a PlanState tree. */ static void -plantree_walker(Plan **planptr, void (*walker) (Plan **, void *), void *context) +plantree_walker(Plan **planptr, + void (*walker) (Plan **, void *), + void *context) { Plan *plan = *planptr; @@ -64,7 +67,9 @@ plantree_walker(Plan **planptr, void (*walker) (Plan **, void *), void *context) } void -planned_stmt_walker(PlannedStmt *stmt, void (*walker) (Plan **, void *), void *context) +planned_stmt_walker(PlannedStmt *stmt, + void (*walker) (Plan **, void *), + void *context) { ListCell *lc; diff --git a/src/subspace_store.c b/src/subspace_store.c index f8dec5802..a4d8ac278 100644 --- a/src/subspace_store.c +++ b/src/subspace_store.c @@ -67,6 +67,7 @@ subspace_store_add(SubspaceStore *store, const Hypercube *hc, if (vec == NULL) { + Assert(last != NULL); last->storage = subspace_store_dimension_create(); last->storage_free = subspace_store_free_internal_node; vec = last->storage; @@ -103,7 +104,7 @@ subspace_store_add(SubspaceStore *store, const Hypercube *hc, vecptr = (DimensionVec **) &last->storage; } - Assert(last->storage == NULL); + Assert(last != NULL && last->storage == NULL); last->storage = object; /* at the end we store the object */ last->storage_free = object_free; MemoryContextSwitchTo(old); @@ -128,6 +129,7 @@ subspace_store_get(SubspaceStore *store, Point *target) vec = match->storage; } + Assert(match != NULL); return match->storage; }