Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions src/chunk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions src/chunk.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 3 additions & 6 deletions src/chunk_index.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand All @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions src/chunk_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 2 additions & 8 deletions src/chunk_insert_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/hypertable.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/hypertable_restrict_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/hypertable_restrict_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/planner/expand_hypertable.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 2 additions & 6 deletions src/process_utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/telemetry/stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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();

Expand Down Expand Up @@ -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;
}
Expand Down
14 changes: 4 additions & 10 deletions src/ts_catalog/chunk_column_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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)
{
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions src/ts_catalog/tablespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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,
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/ts_catalog/tablespace.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Loading