diff --git a/src/chunk.c b/src/chunk.c index 27354497f58..476dd7717dd 100644 --- a/src/chunk.c +++ b/src/chunk.c @@ -3001,8 +3001,7 @@ ts_chunk_delete_by_name(const char *schema, const char *table, DropBehavior beha } int -ts_chunk_delete_by_relid_and_relname(Oid relid, const char *schemaname, const char *tablename, - DropBehavior behavior) +ts_chunk_delete_by_relid(Oid relid, DropBehavior behavior) { if (!OidIsValid(relid)) { @@ -3620,16 +3619,16 @@ ts_chunk_drop(const Chunk *chunk, DropBehavior behavior, int32 log_level) .objectId = chunk->fd.relid, }; - const char *schema_name = ts_chunk_get_schema_name(chunk); - const char *table_name = ts_chunk_get_table_name(chunk); - if (log_level >= 0) { + const char *schema_name = ts_chunk_get_schema_name(chunk); + const char *table_name = ts_chunk_get_table_name(chunk); + elog(log_level, "dropping chunk %s.%s", schema_name, table_name); } /* Remove the chunk from the chunk table */ - ts_chunk_delete_by_relid_and_relname(chunk->fd.relid, schema_name, table_name, behavior); + ts_chunk_delete_by_relid(chunk->fd.relid, behavior); /* Drop the table */ performDeletion(&objaddr, behavior, 0); @@ -3646,16 +3645,16 @@ ts_chunk_drop_by_relid(Oid relid, DropBehavior behavior, int32 log_level) .objectId = relid, }; - const char *schema_name = get_namespace_name(get_rel_namespace(relid)); - const char *table_name = get_rel_name(relid); - if (log_level >= 0) { + const char *schema_name = get_namespace_name(get_rel_namespace(relid)); + const char *table_name = get_rel_name(relid); + elog(log_level, "dropping chunk %s.%s", schema_name, table_name); } /* Remove the chunk from the chunk table */ - ts_chunk_delete_by_relid_and_relname(relid, schema_name, table_name, behavior); + ts_chunk_delete_by_relid(relid, behavior); /* Drop the table */ performDeletion(&objaddr, behavior, 0); diff --git a/src/chunk.h b/src/chunk.h index 49ed6542075..32e306a6a1c 100644 --- a/src/chunk.h +++ b/src/chunk.h @@ -199,8 +199,7 @@ extern void ts_chunk_recreate_all_constraints_for_dimension(Hypertable *ht, int3 extern int ts_chunk_delete_by_hypertable_id(int32 hypertable_id); extern TSDLLEXPORT int ts_chunk_delete_by_name(const char *schema, const char *table, DropBehavior behavior); -extern int ts_chunk_delete_by_relid_and_relname(Oid relid, const char *schemaname, - const char *tablename, DropBehavior behavior); +extern int ts_chunk_delete_by_relid(Oid relid, DropBehavior behavior); extern TSDLLEXPORT bool ts_chunk_set_partial(Chunk *chunk); extern TSDLLEXPORT bool ts_chunk_set_unordered(Chunk *chunk); diff --git a/src/chunk_index.c b/src/chunk_index.c index a60595e4716..488463be04e 100644 --- a/src/chunk_index.c +++ b/src/chunk_index.c @@ -349,8 +349,8 @@ chunk_index_create_from_indexinfo(int32 hypertable_id, Relation template_indexre * it should, for each hypertable index, have a corresponding index of its own. */ static void -chunk_index_create(Relation hypertable_rel, int32 hypertable_id, Relation hypertable_idxrel, - int32 chunk_id, Relation chunkrel, Oid constraint_oid, Oid index_tblspc) +chunk_index_create(Relation hypertable_rel, Relation hypertable_idxrel, Relation chunkrel, + Oid constraint_oid, Oid index_tblspc) { if (OidIsValid(constraint_oid)) { @@ -375,8 +375,7 @@ chunk_index_create(Relation hypertable_rel, int32 hypertable_id, Relation hypert void ts_chunk_index_create_from_adjusted_index_info(int32 hypertable_id, Relation hypertable_idxrel, - int32 chunk_id, Relation chunkrel, - IndexInfo *indexinfo) + Relation chunkrel, IndexInfo *indexinfo) { chunk_index_create_from_indexinfo(hypertable_id, hypertable_idxrel, @@ -432,9 +431,7 @@ ts_chunk_index_create_all(int32 hypertable_id, Oid hypertable_relid, int32 chunk Relation hypertable_idxrel = index_open(hypertable_idxoid, AccessShareLock); chunk_index_create(htrel, - hypertable_id, hypertable_idxrel, - chunk_id, chunkrel, get_index_constraint(hypertable_idxoid), index_tblspc); diff --git a/src/chunk_index.h b/src/chunk_index.h index 2d5194b3c92..c6ec08e9545 100644 --- a/src/chunk_index.h +++ b/src/chunk_index.h @@ -31,8 +31,7 @@ extern void ts_chunk_index_create(Relation hypertable_rel, int32 hypertable_id, void ts_adjust_indexinfo_attnos(IndexInfo *indexinfo, Oid ht_relid, Relation chunkrel); extern void ts_chunk_index_create_from_adjusted_index_info(int32 hypertable_id, Relation hypertable_idxrel, - int32 chunk_id, Relation chunkrel, - IndexInfo *indexinfo); + Relation chunkrel, IndexInfo *indexinfo); extern TSDLLEXPORT void ts_chunk_index_create_all(int32 hypertable_id, Oid hypertable_relid, int32 chunk_id, Oid chunkrelid, Oid index_tblspc); extern TSDLLEXPORT void ts_chunk_index_move_all(Oid chunk_relid, Oid index_tblspc); diff --git a/src/chunk_insert_state.c b/src/chunk_insert_state.c index c981f3ffdce..151ccc910bc 100644 --- a/src/chunk_insert_state.c +++ b/src/chunk_insert_state.c @@ -148,8 +148,7 @@ get_adjusted_projection_info_returning(ProjectionInfo *orig, List *returning_cla } static List * -translate_clause(List *inclause, TupleConversionMap *chunk_map, Index varno, Relation hyper_rel, - Relation chunk_rel) +translate_clause(List *inclause, TupleConversionMap *chunk_map, Index varno, Relation chunk_rel) { List *clause = copyObject(inclause); bool found_whole_row; @@ -292,11 +291,7 @@ setup_on_conflict_state(ResultRelInfo *ht_rri, ModifyTableState *mtstate, ChunkI convert_tuples_by_name(RelationGetDescr(chunk_rel), RelationGetDescr(hyper_rel)); } - onconflset = translate_clause(onconflset, - chunk_map, - ht_rri->ri_RangeTableIndex, - hyper_rel, - chunk_rel); + onconflset = translate_clause(onconflset, chunk_map, ht_rri->ri_RangeTableIndex, chunk_rel); chunk_rri->ri_ChildToRootMap = chunk_map; chunk_rri->ri_ChildToRootMapValid = true; @@ -334,7 +329,6 @@ setup_on_conflict_state(ResultRelInfo *ht_rri, ModifyTableState *mtstate, ChunkI List *clause = translate_clause(castNode(List, onconflict_where), chunk_map, ht_rri->ri_RangeTableIndex, - hyper_rel, chunk_rel); chunk_rri->ri_onConflict->oc_WhereClause = ExecInitQual(clause, NULL); diff --git a/src/hypertable.c b/src/hypertable.c index e8847e4f24c..8bed5a81b6a 100644 --- a/src/hypertable.c +++ b/src/hypertable.c @@ -658,7 +658,7 @@ hypertable_tuple_delete(TupleInfo *ti, void *data) bool isnull; int hypertable_id = DatumGetInt32(slot_getattr(ti->slot, Anum_hypertable_id, &isnull)); - ts_tablespace_delete(hypertable_id, NULL, InvalidOid); + ts_tablespace_delete(hypertable_id, NULL); ts_chunk_delete_by_hypertable_id(hypertable_id); ts_dimension_delete_by_hypertable_id(hypertable_id, true); diff --git a/src/hypertable_restrict_info.c b/src/hypertable_restrict_info.c index c45e2c6a115..4e897dd7c53 100644 --- a/src/hypertable_restrict_info.c +++ b/src/hypertable_restrict_info.c @@ -291,7 +291,7 @@ dimension_restrict_info_closed_add(DimensionRestrictInfoClosed *dri, StrategyNum } HypertableRestrictInfo * -ts_hypertable_restrict_info_create(RelOptInfo *rel, Hypertable *ht) +ts_hypertable_restrict_info_create(Hypertable *ht) { /* If chunk skipping is disabled, we have to empty range_space * in case it was cached earlier. diff --git a/src/hypertable_restrict_info.h b/src/hypertable_restrict_info.h index 0660c0a6178..61439ccf89b 100644 --- a/src/hypertable_restrict_info.h +++ b/src/hypertable_restrict_info.h @@ -45,7 +45,7 @@ typedef struct HypertableRestrictInfo DimensionRestrictInfo *dimension_restriction[FLEXIBLE_ARRAY_MEMBER]; } HypertableRestrictInfo; -extern HypertableRestrictInfo *ts_hypertable_restrict_info_create(RelOptInfo *rel, Hypertable *ht); +extern HypertableRestrictInfo *ts_hypertable_restrict_info_create(Hypertable *ht); /* Add restrictions based on a List of RestrictInfo */ extern void ts_hypertable_restrict_info_add(HypertableRestrictInfo *hri, PlannerInfo *root, diff --git a/src/planner/expand_hypertable.c b/src/planner/expand_hypertable.c index 1ffb5705d3c..03eaef5ebe4 100644 --- a/src/planner/expand_hypertable.c +++ b/src/planner/expand_hypertable.c @@ -1088,7 +1088,7 @@ get_chunks(PlannerInfo *root, RelOptInfo *rel, Hypertable *ht, bool include_osm, bool reverse; int order_attno; - HypertableRestrictInfo *hri = ts_hypertable_restrict_info_create(rel, ht); + HypertableRestrictInfo *hri = ts_hypertable_restrict_info_create(ht); /* * This is where the magic happens: use our HypertableRestrictInfo diff --git a/src/process_utility.c b/src/process_utility.c index 1edfa5b8fb1..7c9f8df5b7c 100644 --- a/src/process_utility.c +++ b/src/process_utility.c @@ -3479,7 +3479,6 @@ process_index_chunk(Hypertable *ht, Oid chunk_relid, void *arg) ts_chunk_index_create_from_adjusted_index_info(ht->fd.id, hypertable_index_rel, - chunk->fd.id, chunk_rel, indexinfo); @@ -3575,7 +3574,6 @@ process_index_chunk_multitransaction(int32 hypertable_id, Oid chunk_relid, void ts_chunk_index_create_from_adjusted_index_info(hypertable_id, hypertable_index_rel, - chunk->fd.id, chunk_rel, indexinfo); @@ -4635,9 +4633,7 @@ process_altertable_set_tablespace_end(Hypertable *ht, AlterTableCmd *cmd) if (tspcs->num_tablespaces == 1) { Assert(ts_hypertable_has_tablespace(ht, tspcs->tablespaces[0].tablespace_oid)); - ts_tablespace_delete(ht->fd.id, - NameStr(tspcs->tablespaces[0].fd.tablespace_name), - tspcs->tablespaces[0].tablespace_oid); + ts_tablespace_delete(ht->fd.id, NameStr(tspcs->tablespaces[0].fd.tablespace_name)); } ts_tablespace_attach_internal(&tspc_name, ht->main_table_relid, true); @@ -6218,7 +6214,7 @@ process_drop_table(EventTriggerDropObject *obj) EventTriggerDropRelation *table = (EventTriggerDropRelation *) obj; Assert(obj->type == EVENT_TRIGGER_DROP_TABLE || obj->type == EVENT_TRIGGER_DROP_FOREIGN_TABLE); - ts_chunk_delete_by_relid_and_relname(table->relid, table->schema, table->name, DROP_RESTRICT); + ts_chunk_delete_by_relid(table->relid, DROP_RESTRICT); ts_hypertable_delete_by_name(table->schema, table->name); /* * Normally, dependent catalogs (like compression settings) are cleaned up diff --git a/src/telemetry/stats.c b/src/telemetry/stats.c index 80784d7da76..31147b1b3d6 100644 --- a/src/telemetry/stats.c +++ b/src/telemetry/stats.c @@ -91,7 +91,7 @@ classify_partitioned_table(const Form_pg_class class) } static StatsRelType -classify_foreign_table(Cache *htcache, Oid relid, const Hypertable **ht, const Chunk **chunk) +classify_foreign_table(Oid relid, const Chunk **chunk) { *chunk = ts_chunk_get_by_relid(relid, false); if (*chunk) @@ -107,7 +107,7 @@ classify_foreign_table(Cache *htcache, Oid relid, const Hypertable **ht, const C } static StatsRelType -classify_view(const Form_pg_class class, Cache *htcache, const ContinuousAgg **cagg) +classify_view(const Form_pg_class class, const ContinuousAgg **cagg) { const Catalog *catalog = ts_catalog_get(); @@ -141,11 +141,11 @@ classify_relation(const Form_pg_class class, Cache *htcache, const Hypertable ** case RELKIND_PARTITIONED_TABLE: return classify_partitioned_table(class); case RELKIND_FOREIGN_TABLE: - return classify_foreign_table(htcache, class->oid, ht, chunk); + return classify_foreign_table(class->oid, chunk); case RELKIND_MATVIEW: return RELTYPE_MATVIEW; case RELKIND_VIEW: - return classify_view(class, htcache, cagg); + return classify_view(class, cagg); default: return RELTYPE_OTHER; } diff --git a/src/ts_catalog/chunk_column_stats.c b/src/ts_catalog/chunk_column_stats.c index c29bd767709..e5eb07736c2 100644 --- a/src/ts_catalog/chunk_column_stats.c +++ b/src/ts_catalog/chunk_column_stats.c @@ -254,8 +254,7 @@ ts_chunk_column_stats_update_by_id(int32 chunk_column_stats_id, } static void -ts_chunk_column_stats_validate(Form_chunk_column_stats info, const Oid hypertable_relid, - bool if_not_exists) +ts_chunk_column_stats_validate(Form_chunk_column_stats info, const Oid hypertable_relid) { HeapTuple tuple; Datum datum; @@ -317,7 +316,7 @@ ts_chunk_column_stats_add_internal(FunctionCallInfo fcinfo, Oid table_relid, Nam namestrcpy(&fd.column_name, NameStr(*colname)); LockRelationOid(table_relid, AccessShareLock); - ts_chunk_column_stats_validate(&fd, table_relid, if_not_exists); + ts_chunk_column_stats_validate(&fd, table_relid); ht = ts_hypertable_cache_get_cache_and_entry(table_relid, CACHE_FLAG_NONE, &hcache); @@ -574,7 +573,7 @@ ts_chunk_column_stats_fill_dummy_dimension(FormData_chunk_column_stats *r, Oid m */ static Constraint * create_col_stats_check_constraint(const Form_chunk_column_stats info, Oid main_table_relid, - Oid chunk_relid, const char *name) + const char *name) { Constraint *constr = NULL; Node *rangedef; @@ -1502,7 +1501,6 @@ ts_chunk_column_stats_set_invalid(int32 hypertable_id, int32 chunk_id) typedef struct CheckList { - Oid chunk_relid; Oid main_table_relid; List *cclist; } CheckList; @@ -1518,10 +1516,7 @@ construct_check_constraint_range_tuple(TupleInfo *ti, void *data) fill_form_from_slot(ti->slot, &fd); - constr = create_col_stats_check_constraint(&fd, - checklist->main_table_relid, - checklist->chunk_relid, - NULL); + constr = create_col_stats_check_constraint(&fd, checklist->main_table_relid, NULL); if (constr) { @@ -1556,7 +1551,6 @@ ts_chunk_column_stats_construct_check_constraints(Relation relation, Oid reloid, return NIL; } - clist.chunk_relid = reloid; clist.main_table_relid = ts_hypertable_id_to_relid(fd.hypertable_id, false); Assert(fd.id != INVALID_CHUNK_ID); diff --git a/src/ts_catalog/tablespace.c b/src/ts_catalog/tablespace.c index 3359525ef16..092946aad24 100644 --- a/src/ts_catalog/tablespace.c +++ b/src/ts_catalog/tablespace.c @@ -384,7 +384,7 @@ tablespace_tuple_delete(TupleInfo *ti, void *data) } int -ts_tablespace_delete(int32 hypertable_id, const char *tspcname, Oid tspcoid) +ts_tablespace_delete(int32 hypertable_id, const char *tspcname) { ScanKeyData scankey[2]; @@ -400,7 +400,7 @@ ts_tablespace_delete(int32 hypertable_id, const char *tspcname, Oid tspcoid) F_INT4EQ, Int32GetDatum(hypertable_id)); - if (NULL != tspcname) + if (tspcname) { ScanKeyInit(&scankey[nkeys++], Anum_tablespace_hypertable_id_tablespace_name_idx_tablespace_name, @@ -647,7 +647,7 @@ tablespace_detach_one(Oid hypertable_oid, const char *tspcname, Oid tspcoid, boo if (ts_hypertable_has_tablespace(ht, tspcoid)) { - ret = ts_tablespace_delete(ht->fd.id, tspcname, tspcoid); + ret = ts_tablespace_delete(ht->fd.id, tspcname); } else if (if_attached) { @@ -682,7 +682,7 @@ tablespace_detach_all(Oid hypertable_oid) ht = ts_hypertable_cache_get_cache_and_entry(hypertable_oid, CACHE_FLAG_NONE, &hcache); - ret = ts_tablespace_delete(ht->fd.id, NULL, InvalidOid); + ret = ts_tablespace_delete(ht->fd.id, NULL); ts_cache_release(&hcache); diff --git a/src/ts_catalog/tablespace.h b/src/ts_catalog/tablespace.h index d9074538d6d..e90f7ed613b 100644 --- a/src/ts_catalog/tablespace.h +++ b/src/ts_catalog/tablespace.h @@ -29,7 +29,7 @@ extern bool ts_tablespaces_contain(const Tablespaces *tablespaces, Oid tspc_oid) extern Tablespaces *ts_tablespace_scan(int32 hypertable_id); extern TSDLLEXPORT void ts_tablespace_attach_internal(Name tspcname, Oid hypertable_oid, bool if_not_attached); -extern int ts_tablespace_delete(int32 hypertable_id, const char *tspcname, Oid tspcoid); +extern int ts_tablespace_delete(int32 hypertable_id, const char *tspcname); extern int ts_tablespace_count_attached(const char *tspcname); extern void ts_tablespace_validate_revoke(GrantStmt *stmt); extern void ts_tablespace_validate_revoke_role(GrantRoleStmt *stmt);