mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-17 02:53:51 +08:00
Use AttrNumberGetAttrOffset instead of Anum_name - 1 for array indexing
Use the postgres macro instead of manual subtraction everywhere to be more readable, and gain the Assert. Done with `find ./src -type f -exec sed -i -e 's/Anum_\(.*\) - 1/AttrNumberGetAttrOffset(Anum_\1)/' {} \;`
This commit is contained in:
parent
d1710efde5
commit
8571e41297
@ -51,10 +51,10 @@ chunk_insert_relation(Relation rel, Chunk *chunk)
|
|||||||
CatalogSecurityContext sec_ctx;
|
CatalogSecurityContext sec_ctx;
|
||||||
|
|
||||||
memset(values, 0, sizeof(values));
|
memset(values, 0, sizeof(values));
|
||||||
values[Anum_chunk_id - 1] = Int32GetDatum(chunk->fd.id);
|
values[AttrNumberGetAttrOffset(Anum_chunk_id)] = Int32GetDatum(chunk->fd.id);
|
||||||
values[Anum_chunk_hypertable_id - 1] = Int32GetDatum(chunk->fd.hypertable_id);
|
values[AttrNumberGetAttrOffset(Anum_chunk_hypertable_id)] = Int32GetDatum(chunk->fd.hypertable_id);
|
||||||
values[Anum_chunk_schema_name - 1] = NameGetDatum(&chunk->fd.schema_name);
|
values[AttrNumberGetAttrOffset(Anum_chunk_schema_name)] = NameGetDatum(&chunk->fd.schema_name);
|
||||||
values[Anum_chunk_table_name - 1] = NameGetDatum(&chunk->fd.table_name);
|
values[AttrNumberGetAttrOffset(Anum_chunk_table_name)] = NameGetDatum(&chunk->fd.table_name);
|
||||||
|
|
||||||
catalog_become_owner(catalog_get(), &sec_ctx);
|
catalog_become_owner(catalog_get(), &sec_ctx);
|
||||||
catalog_insert_values(rel, desc, values, nulls);
|
catalog_insert_values(rel, desc, values, nulls);
|
||||||
|
@ -148,16 +148,16 @@ chunk_constraint_fill_tuple_values(ChunkConstraint *cc,
|
|||||||
bool nulls[Natts_chunk_constraint])
|
bool nulls[Natts_chunk_constraint])
|
||||||
{
|
{
|
||||||
memset(values, 0, sizeof(Datum) * Natts_chunk_constraint);
|
memset(values, 0, sizeof(Datum) * Natts_chunk_constraint);
|
||||||
values[Anum_chunk_constraint_chunk_id - 1] = Int32GetDatum(cc->fd.chunk_id);
|
values[AttrNumberGetAttrOffset(Anum_chunk_constraint_chunk_id)] = Int32GetDatum(cc->fd.chunk_id);
|
||||||
values[Anum_chunk_constraint_dimension_slice_id - 1] = Int32GetDatum(cc->fd.dimension_slice_id);
|
values[AttrNumberGetAttrOffset(Anum_chunk_constraint_dimension_slice_id)] = Int32GetDatum(cc->fd.dimension_slice_id);
|
||||||
values[Anum_chunk_constraint_constraint_name - 1] = NameGetDatum(&cc->fd.constraint_name);
|
values[AttrNumberGetAttrOffset(Anum_chunk_constraint_constraint_name)] = NameGetDatum(&cc->fd.constraint_name);
|
||||||
values[Anum_chunk_constraint_hypertable_constraint_name - 1] =
|
values[AttrNumberGetAttrOffset(Anum_chunk_constraint_hypertable_constraint_name)] =
|
||||||
NameGetDatum(&cc->fd.hypertable_constraint_name);
|
NameGetDatum(&cc->fd.hypertable_constraint_name);
|
||||||
|
|
||||||
if (is_dimension_constraint(cc))
|
if (is_dimension_constraint(cc))
|
||||||
nulls[Anum_chunk_constraint_hypertable_constraint_name - 1] = true;
|
nulls[AttrNumberGetAttrOffset(Anum_chunk_constraint_hypertable_constraint_name)] = true;
|
||||||
else
|
else
|
||||||
nulls[Anum_chunk_constraint_dimension_slice_id - 1] = true;
|
nulls[AttrNumberGetAttrOffset(Anum_chunk_constraint_dimension_slice_id)] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -223,21 +223,21 @@ chunk_constraints_add_from_tuple(ChunkConstraints *ccs, TupleInfo *ti)
|
|||||||
|
|
||||||
heap_deform_tuple(ti->tuple, ti->desc, values, nulls);
|
heap_deform_tuple(ti->tuple, ti->desc, values, nulls);
|
||||||
|
|
||||||
constraint_name = DatumGetName(values[Anum_chunk_constraint_constraint_name - 1]);
|
constraint_name = DatumGetName(values[AttrNumberGetAttrOffset(Anum_chunk_constraint_constraint_name)]);
|
||||||
|
|
||||||
if (nulls[Anum_chunk_constraint_dimension_slice_id - 1])
|
if (nulls[AttrNumberGetAttrOffset(Anum_chunk_constraint_dimension_slice_id)])
|
||||||
{
|
{
|
||||||
dimension_slice_id = 0;
|
dimension_slice_id = 0;
|
||||||
hypertable_constraint_name = DatumGetName(values[Anum_chunk_constraint_hypertable_constraint_name - 1]);
|
hypertable_constraint_name = DatumGetName(values[AttrNumberGetAttrOffset(Anum_chunk_constraint_hypertable_constraint_name)]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dimension_slice_id = DatumGetInt32(values[Anum_chunk_constraint_dimension_slice_id - 1]);
|
dimension_slice_id = DatumGetInt32(values[AttrNumberGetAttrOffset(Anum_chunk_constraint_dimension_slice_id)]);
|
||||||
hypertable_constraint_name = DatumGetName(DirectFunctionCall1(namein, CStringGetDatum("")));
|
hypertable_constraint_name = DatumGetName(DirectFunctionCall1(namein, CStringGetDatum("")));
|
||||||
}
|
}
|
||||||
|
|
||||||
return chunk_constraints_add(ccs,
|
return chunk_constraints_add(ccs,
|
||||||
DatumGetInt32(values[Anum_chunk_constraint_chunk_id - 1]),
|
DatumGetInt32(values[AttrNumberGetAttrOffset(Anum_chunk_constraint_chunk_id)]),
|
||||||
dimension_slice_id,
|
dimension_slice_id,
|
||||||
NameStr(*constraint_name),
|
NameStr(*constraint_name),
|
||||||
NameStr(*hypertable_constraint_name));
|
NameStr(*hypertable_constraint_name));
|
||||||
@ -733,10 +733,10 @@ hypertable_constraint_tuple_filter(TupleInfo *ti, void *data)
|
|||||||
|
|
||||||
heap_deform_tuple(ti->tuple, ti->desc, values, nulls);
|
heap_deform_tuple(ti->tuple, ti->desc, values, nulls);
|
||||||
|
|
||||||
if (nulls[Anum_chunk_constraint_hypertable_constraint_name - 1])
|
if (nulls[AttrNumberGetAttrOffset(Anum_chunk_constraint_hypertable_constraint_name)])
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
constrname = NameStr(*DatumGetName(values[Anum_chunk_constraint_hypertable_constraint_name - 1]));
|
constrname = NameStr(*DatumGetName(values[AttrNumberGetAttrOffset(Anum_chunk_constraint_hypertable_constraint_name)]));
|
||||||
|
|
||||||
return NULL != info->hypertable_constraint_name &&
|
return NULL != info->hypertable_constraint_name &&
|
||||||
strcmp(info->hypertable_constraint_name, constrname) == 0;
|
strcmp(info->hypertable_constraint_name, constrname) == 0;
|
||||||
@ -868,7 +868,7 @@ chunk_constraint_rename_hypertable_tuple(TupleInfo *ti, void *data)
|
|||||||
|
|
||||||
heap_deform_tuple(ti->tuple, ti->desc, values, nulls);
|
heap_deform_tuple(ti->tuple, ti->desc, values, nulls);
|
||||||
|
|
||||||
chunk_id = DatumGetInt32(values[Anum_chunk_constraint_chunk_id - 1]);
|
chunk_id = DatumGetInt32(values[AttrNumberGetAttrOffset(Anum_chunk_constraint_chunk_id)]);
|
||||||
namestrcpy(&new_hypertable_constraint_name, info->newname);
|
namestrcpy(&new_hypertable_constraint_name, info->newname);
|
||||||
chunk_constraint_choose_name(&new_chunk_constraint_name,
|
chunk_constraint_choose_name(&new_chunk_constraint_name,
|
||||||
false,
|
false,
|
||||||
@ -876,11 +876,11 @@ chunk_constraint_rename_hypertable_tuple(TupleInfo *ti, void *data)
|
|||||||
info->newname,
|
info->newname,
|
||||||
chunk_id);
|
chunk_id);
|
||||||
|
|
||||||
values[Anum_chunk_constraint_hypertable_constraint_name - 1] = NameGetDatum(&new_hypertable_constraint_name);
|
values[AttrNumberGetAttrOffset(Anum_chunk_constraint_hypertable_constraint_name)] = NameGetDatum(&new_hypertable_constraint_name);
|
||||||
repl[Anum_chunk_constraint_hypertable_constraint_name - 1] = true;
|
repl[AttrNumberGetAttrOffset(Anum_chunk_constraint_hypertable_constraint_name)] = true;
|
||||||
old_chunk_constraint_name = DatumGetName(values[Anum_chunk_constraint_constraint_name - 1]);
|
old_chunk_constraint_name = DatumGetName(values[AttrNumberGetAttrOffset(Anum_chunk_constraint_constraint_name)]);
|
||||||
values[Anum_chunk_constraint_constraint_name - 1] = NameGetDatum(&new_chunk_constraint_name);
|
values[AttrNumberGetAttrOffset(Anum_chunk_constraint_constraint_name)] = NameGetDatum(&new_chunk_constraint_name);
|
||||||
repl[Anum_chunk_constraint_constraint_name - 1] = true;
|
repl[AttrNumberGetAttrOffset(Anum_chunk_constraint_constraint_name)] = true;
|
||||||
|
|
||||||
chunk_constraint_rename_on_chunk_table(chunk_id,
|
chunk_constraint_rename_on_chunk_table(chunk_id,
|
||||||
NameStr(*old_chunk_constraint_name),
|
NameStr(*old_chunk_constraint_name),
|
||||||
@ -921,7 +921,7 @@ chunk_constraint_get_name_from_hypertable_tuple(TupleInfo *ti, void *data)
|
|||||||
|
|
||||||
|
|
||||||
heap_deform_tuple(ti->tuple, ti->desc, values, nulls);
|
heap_deform_tuple(ti->tuple, ti->desc, values, nulls);
|
||||||
info->chunk_constraint_name = DatumGetName(values[Anum_chunk_constraint_constraint_name - 1]);
|
info->chunk_constraint_name = DatumGetName(values[AttrNumberGetAttrOffset(Anum_chunk_constraint_constraint_name)]);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -318,11 +318,11 @@ chunk_index_insert_relation(Relation rel,
|
|||||||
bool nulls[Natts_chunk_index] = {false};
|
bool nulls[Natts_chunk_index] = {false};
|
||||||
CatalogSecurityContext sec_ctx;
|
CatalogSecurityContext sec_ctx;
|
||||||
|
|
||||||
values[Anum_chunk_index_chunk_id - 1] = Int32GetDatum(chunk_id);
|
values[AttrNumberGetAttrOffset(Anum_chunk_index_chunk_id)] = Int32GetDatum(chunk_id);
|
||||||
values[Anum_chunk_index_index_name - 1] =
|
values[AttrNumberGetAttrOffset(Anum_chunk_index_index_name)] =
|
||||||
DirectFunctionCall1(namein, CStringGetDatum(chunk_index));
|
DirectFunctionCall1(namein, CStringGetDatum(chunk_index));
|
||||||
values[Anum_chunk_index_hypertable_id - 1] = Int32GetDatum(hypertable_id);
|
values[AttrNumberGetAttrOffset(Anum_chunk_index_hypertable_id)] = Int32GetDatum(hypertable_id);
|
||||||
values[Anum_chunk_index_hypertable_index_name - 1] =
|
values[AttrNumberGetAttrOffset(Anum_chunk_index_hypertable_index_name)] =
|
||||||
DirectFunctionCall1(namein, CStringGetDatum(parent_index));
|
DirectFunctionCall1(namein, CStringGetDatum(parent_index));
|
||||||
|
|
||||||
catalog_become_owner(catalog_get(), &sec_ctx);
|
catalog_become_owner(catalog_get(), &sec_ctx);
|
||||||
|
@ -122,24 +122,24 @@ dimension_fill_in_from_tuple(Dimension *d, TupleInfo *ti, Oid main_table_relid)
|
|||||||
heap_deform_tuple(ti->tuple, ti->desc, values, isnull);
|
heap_deform_tuple(ti->tuple, ti->desc, values, isnull);
|
||||||
|
|
||||||
d->type = dimension_type(ti->tuple);
|
d->type = dimension_type(ti->tuple);
|
||||||
d->fd.id = DatumGetInt32(values[Anum_dimension_id - 1]);
|
d->fd.id = DatumGetInt32(values[AttrNumberGetAttrOffset(Anum_dimension_id)]);
|
||||||
d->fd.hypertable_id = DatumGetInt32(values[Anum_dimension_hypertable_id - 1]);
|
d->fd.hypertable_id = DatumGetInt32(values[AttrNumberGetAttrOffset(Anum_dimension_hypertable_id)]);
|
||||||
d->fd.aligned = DatumGetBool(values[Anum_dimension_aligned - 1]);
|
d->fd.aligned = DatumGetBool(values[AttrNumberGetAttrOffset(Anum_dimension_aligned)]);
|
||||||
d->fd.column_type = DatumGetObjectId(values[Anum_dimension_column_type - 1]);
|
d->fd.column_type = DatumGetObjectId(values[AttrNumberGetAttrOffset(Anum_dimension_column_type)]);
|
||||||
memcpy(&d->fd.column_name,
|
memcpy(&d->fd.column_name,
|
||||||
DatumGetName(values[Anum_dimension_column_name - 1]),
|
DatumGetName(values[AttrNumberGetAttrOffset(Anum_dimension_column_name)]),
|
||||||
NAMEDATALEN);
|
NAMEDATALEN);
|
||||||
|
|
||||||
if (d->type == DIMENSION_TYPE_CLOSED)
|
if (d->type == DIMENSION_TYPE_CLOSED)
|
||||||
{
|
{
|
||||||
MemoryContext old;
|
MemoryContext old;
|
||||||
|
|
||||||
d->fd.num_slices = DatumGetInt16(values[Anum_dimension_num_slices - 1]);
|
d->fd.num_slices = DatumGetInt16(values[AttrNumberGetAttrOffset(Anum_dimension_num_slices)]);
|
||||||
memcpy(&d->fd.partitioning_func_schema,
|
memcpy(&d->fd.partitioning_func_schema,
|
||||||
DatumGetName(values[Anum_dimension_partitioning_func_schema - 1]),
|
DatumGetName(values[AttrNumberGetAttrOffset(Anum_dimension_partitioning_func_schema)]),
|
||||||
NAMEDATALEN);
|
NAMEDATALEN);
|
||||||
memcpy(&d->fd.partitioning_func,
|
memcpy(&d->fd.partitioning_func,
|
||||||
DatumGetName(values[Anum_dimension_partitioning_func - 1]),
|
DatumGetName(values[AttrNumberGetAttrOffset(Anum_dimension_partitioning_func)]),
|
||||||
NAMEDATALEN);
|
NAMEDATALEN);
|
||||||
|
|
||||||
old = MemoryContextSwitchTo(ti->mctx);
|
old = MemoryContextSwitchTo(ti->mctx);
|
||||||
@ -150,7 +150,7 @@ dimension_fill_in_from_tuple(Dimension *d, TupleInfo *ti, Oid main_table_relid)
|
|||||||
MemoryContextSwitchTo(old);
|
MemoryContextSwitchTo(old);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
d->fd.interval_length = DatumGetInt64(values[Anum_dimension_interval_length - 1]);
|
d->fd.interval_length = DatumGetInt64(values[AttrNumberGetAttrOffset(Anum_dimension_interval_length)]);
|
||||||
|
|
||||||
d->column_attno = get_attnum(main_table_relid, NameStr(d->fd.column_name));
|
d->column_attno = get_attnum(main_table_relid, NameStr(d->fd.column_name));
|
||||||
}
|
}
|
||||||
@ -465,19 +465,19 @@ dimension_tuple_update(TupleInfo *ti, void *data)
|
|||||||
|
|
||||||
heap_deform_tuple(ti->tuple, ti->desc, values, nulls);
|
heap_deform_tuple(ti->tuple, ti->desc, values, nulls);
|
||||||
|
|
||||||
values[Anum_dimension_column_name - 1] = NameGetDatum(&dim->fd.column_name);
|
values[AttrNumberGetAttrOffset(Anum_dimension_column_name)] = NameGetDatum(&dim->fd.column_name);
|
||||||
values[Anum_dimension_column_type - 1] = ObjectIdGetDatum(dim->fd.column_type);
|
values[AttrNumberGetAttrOffset(Anum_dimension_column_type)] = ObjectIdGetDatum(dim->fd.column_type);
|
||||||
values[Anum_dimension_num_slices - 1] = Int16GetDatum(dim->fd.num_slices);
|
values[AttrNumberGetAttrOffset(Anum_dimension_num_slices)] = Int16GetDatum(dim->fd.num_slices);
|
||||||
|
|
||||||
if (!nulls[Anum_dimension_partitioning_func - 1] &&
|
if (!nulls[AttrNumberGetAttrOffset(Anum_dimension_partitioning_func)] &&
|
||||||
!nulls[Anum_dimension_partitioning_func_schema - 1])
|
!nulls[AttrNumberGetAttrOffset(Anum_dimension_partitioning_func_schema)])
|
||||||
{
|
{
|
||||||
values[Anum_dimension_partitioning_func - 1] = NameGetDatum(&dim->fd.partitioning_func);
|
values[AttrNumberGetAttrOffset(Anum_dimension_partitioning_func)] = NameGetDatum(&dim->fd.partitioning_func);
|
||||||
values[Anum_dimension_partitioning_func_schema - 1] = NameGetDatum(&dim->fd.partitioning_func_schema);
|
values[AttrNumberGetAttrOffset(Anum_dimension_partitioning_func_schema)] = NameGetDatum(&dim->fd.partitioning_func_schema);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!nulls[Anum_dimension_interval_length - 1])
|
if (!nulls[AttrNumberGetAttrOffset(Anum_dimension_interval_length)])
|
||||||
values[Anum_dimension_interval_length - 1] = Int64GetDatum(dim->fd.interval_length);
|
values[AttrNumberGetAttrOffset(Anum_dimension_interval_length)] = Int64GetDatum(dim->fd.interval_length);
|
||||||
|
|
||||||
tuple = heap_form_tuple(ti->desc, values, nulls);
|
tuple = heap_form_tuple(ti->desc, values, nulls);
|
||||||
|
|
||||||
@ -498,33 +498,33 @@ dimension_insert_relation(Relation rel, int32 hypertable_id,
|
|||||||
bool nulls[Natts_dimension] = {false};
|
bool nulls[Natts_dimension] = {false};
|
||||||
CatalogSecurityContext sec_ctx;
|
CatalogSecurityContext sec_ctx;
|
||||||
|
|
||||||
values[Anum_dimension_hypertable_id - 1] = Int32GetDatum(hypertable_id);
|
values[AttrNumberGetAttrOffset(Anum_dimension_hypertable_id)] = Int32GetDatum(hypertable_id);
|
||||||
values[Anum_dimension_column_name - 1] = NameGetDatum(colname);
|
values[AttrNumberGetAttrOffset(Anum_dimension_column_name)] = NameGetDatum(colname);
|
||||||
values[Anum_dimension_column_type - 1] = ObjectIdGetDatum(coltype);
|
values[AttrNumberGetAttrOffset(Anum_dimension_column_type)] = ObjectIdGetDatum(coltype);
|
||||||
|
|
||||||
if (OidIsValid(partitioning_func))
|
if (OidIsValid(partitioning_func))
|
||||||
{
|
{
|
||||||
Oid pronamespace = get_func_namespace(partitioning_func);
|
Oid pronamespace = get_func_namespace(partitioning_func);
|
||||||
|
|
||||||
values[Anum_dimension_partitioning_func - 1] =
|
values[AttrNumberGetAttrOffset(Anum_dimension_partitioning_func)] =
|
||||||
DirectFunctionCall1(namein, CStringGetDatum(get_func_name(partitioning_func)));
|
DirectFunctionCall1(namein, CStringGetDatum(get_func_name(partitioning_func)));
|
||||||
values[Anum_dimension_partitioning_func_schema - 1] =
|
values[AttrNumberGetAttrOffset(Anum_dimension_partitioning_func_schema)] =
|
||||||
DirectFunctionCall1(namein, CStringGetDatum(get_namespace_name(pronamespace)));
|
DirectFunctionCall1(namein, CStringGetDatum(get_namespace_name(pronamespace)));
|
||||||
values[Anum_dimension_num_slices - 1] = Int16GetDatum(num_slices);
|
values[AttrNumberGetAttrOffset(Anum_dimension_num_slices)] = Int16GetDatum(num_slices);
|
||||||
values[Anum_dimension_aligned - 1] = BoolGetDatum(false);
|
values[AttrNumberGetAttrOffset(Anum_dimension_aligned)] = BoolGetDatum(false);
|
||||||
nulls[Anum_dimension_interval_length - 1] = true;
|
nulls[AttrNumberGetAttrOffset(Anum_dimension_interval_length)] = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
values[Anum_dimension_interval_length - 1] = Int64GetDatum(interval_length);
|
values[AttrNumberGetAttrOffset(Anum_dimension_interval_length)] = Int64GetDatum(interval_length);
|
||||||
values[Anum_dimension_aligned - 1] = BoolGetDatum(true);
|
values[AttrNumberGetAttrOffset(Anum_dimension_aligned)] = BoolGetDatum(true);
|
||||||
nulls[Anum_dimension_num_slices - 1] = true;
|
nulls[AttrNumberGetAttrOffset(Anum_dimension_num_slices)] = true;
|
||||||
nulls[Anum_dimension_partitioning_func - 1] = true;
|
nulls[AttrNumberGetAttrOffset(Anum_dimension_partitioning_func)] = true;
|
||||||
nulls[Anum_dimension_partitioning_func_schema - 1] = true;
|
nulls[AttrNumberGetAttrOffset(Anum_dimension_partitioning_func_schema)] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
catalog_become_owner(catalog_get(), &sec_ctx);
|
catalog_become_owner(catalog_get(), &sec_ctx);
|
||||||
values[Anum_dimension_id - 1] = Int32GetDatum(catalog_table_next_seq_id(catalog_get(), DIMENSION));
|
values[AttrNumberGetAttrOffset(Anum_dimension_id)] = Int32GetDatum(catalog_table_next_seq_id(catalog_get(), DIMENSION));
|
||||||
catalog_insert_values(rel, desc, values, nulls);
|
catalog_insert_values(rel, desc, values, nulls);
|
||||||
catalog_restore_user(&sec_ctx);
|
catalog_restore_user(&sec_ctx);
|
||||||
}
|
}
|
||||||
|
@ -594,10 +594,10 @@ dimension_slice_insert_relation(Relation rel, DimensionSlice *slice)
|
|||||||
catalog_become_owner(catalog_get(), &sec_ctx);
|
catalog_become_owner(catalog_get(), &sec_ctx);
|
||||||
memset(values, 0, sizeof(values));
|
memset(values, 0, sizeof(values));
|
||||||
slice->fd.id = catalog_table_next_seq_id(catalog_get(), DIMENSION_SLICE);
|
slice->fd.id = catalog_table_next_seq_id(catalog_get(), DIMENSION_SLICE);
|
||||||
values[Anum_dimension_slice_id - 1] = Int32GetDatum(slice->fd.id);
|
values[AttrNumberGetAttrOffset(Anum_dimension_slice_id)] = Int32GetDatum(slice->fd.id);
|
||||||
values[Anum_dimension_slice_dimension_id - 1] = Int32GetDatum(slice->fd.dimension_id);
|
values[AttrNumberGetAttrOffset(Anum_dimension_slice_dimension_id)] = Int32GetDatum(slice->fd.dimension_id);
|
||||||
values[Anum_dimension_slice_range_start - 1] = Int64GetDatum(slice->fd.range_start);
|
values[AttrNumberGetAttrOffset(Anum_dimension_slice_range_start)] = Int64GetDatum(slice->fd.range_start);
|
||||||
values[Anum_dimension_slice_range_end - 1] = Int64GetDatum(slice->fd.range_end);
|
values[AttrNumberGetAttrOffset(Anum_dimension_slice_range_end)] = Int64GetDatum(slice->fd.range_end);
|
||||||
|
|
||||||
catalog_insert_values(rel, desc, values, nulls);
|
catalog_insert_values(rel, desc, values, nulls);
|
||||||
catalog_restore_user(&sec_ctx);
|
catalog_restore_user(&sec_ctx);
|
||||||
|
@ -213,12 +213,12 @@ hypertable_tuple_update(TupleInfo *ti, void *data)
|
|||||||
|
|
||||||
heap_deform_tuple(ti->tuple, ti->desc, values, nulls);
|
heap_deform_tuple(ti->tuple, ti->desc, values, nulls);
|
||||||
|
|
||||||
values[Anum_hypertable_schema_name - 1] = NameGetDatum(&ht->fd.schema_name);
|
values[AttrNumberGetAttrOffset(Anum_hypertable_schema_name)] = NameGetDatum(&ht->fd.schema_name);
|
||||||
values[Anum_hypertable_table_name - 1] = NameGetDatum(&ht->fd.table_name);
|
values[AttrNumberGetAttrOffset(Anum_hypertable_table_name)] = NameGetDatum(&ht->fd.table_name);
|
||||||
values[Anum_hypertable_associated_schema_name - 1] = NameGetDatum(&ht->fd.associated_schema_name);
|
values[AttrNumberGetAttrOffset(Anum_hypertable_associated_schema_name)] = NameGetDatum(&ht->fd.associated_schema_name);
|
||||||
values[Anum_hypertable_associated_table_prefix - 1] = NameGetDatum(&ht->fd.associated_table_prefix);
|
values[AttrNumberGetAttrOffset(Anum_hypertable_associated_table_prefix)] = NameGetDatum(&ht->fd.associated_table_prefix);
|
||||||
values[Anum_hypertable_num_dimensions - 1] = Int16GetDatum(ht->fd.num_dimensions);
|
values[AttrNumberGetAttrOffset(Anum_hypertable_num_dimensions)] = Int16GetDatum(ht->fd.num_dimensions);
|
||||||
values[Anum_hypertable_chunk_target_size - 1] = Int64GetDatum(ht->fd.chunk_target_size);
|
values[AttrNumberGetAttrOffset(Anum_hypertable_chunk_target_size)] = Int64GetDatum(ht->fd.chunk_target_size);
|
||||||
|
|
||||||
memset(nulls, 0, sizeof(nulls));
|
memset(nulls, 0, sizeof(nulls));
|
||||||
|
|
||||||
@ -236,15 +236,15 @@ hypertable_tuple_update(TupleInfo *ti, void *data)
|
|||||||
namestrcpy(&ht->fd.chunk_sizing_func_schema, NameStr(info.func_schema));
|
namestrcpy(&ht->fd.chunk_sizing_func_schema, NameStr(info.func_schema));
|
||||||
namestrcpy(&ht->fd.chunk_sizing_func_name, NameStr(info.func_name));
|
namestrcpy(&ht->fd.chunk_sizing_func_name, NameStr(info.func_name));
|
||||||
|
|
||||||
values[Anum_hypertable_chunk_sizing_func_schema - 1] =
|
values[AttrNumberGetAttrOffset(Anum_hypertable_chunk_sizing_func_schema)] =
|
||||||
NameGetDatum(&ht->fd.chunk_sizing_func_schema);
|
NameGetDatum(&ht->fd.chunk_sizing_func_schema);
|
||||||
values[Anum_hypertable_chunk_sizing_func_name - 1] =
|
values[AttrNumberGetAttrOffset(Anum_hypertable_chunk_sizing_func_name)] =
|
||||||
NameGetDatum(&ht->fd.chunk_sizing_func_name);
|
NameGetDatum(&ht->fd.chunk_sizing_func_name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nulls[Anum_hypertable_chunk_sizing_func_schema - 1] = true;
|
nulls[AttrNumberGetAttrOffset(Anum_hypertable_chunk_sizing_func_schema)] = true;
|
||||||
nulls[Anum_hypertable_chunk_sizing_func_name - 1] = true;
|
nulls[AttrNumberGetAttrOffset(Anum_hypertable_chunk_sizing_func_name)] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
copy = heap_form_tuple(ti->desc, values, nulls);
|
copy = heap_form_tuple(ti->desc, values, nulls);
|
||||||
@ -546,40 +546,40 @@ hypertable_insert_relation(Relation rel,
|
|||||||
NameData default_associated_table_prefix;
|
NameData default_associated_table_prefix;
|
||||||
CatalogSecurityContext sec_ctx;
|
CatalogSecurityContext sec_ctx;
|
||||||
|
|
||||||
values[Anum_hypertable_schema_name - 1] = NameGetDatum(schema_name);
|
values[AttrNumberGetAttrOffset(Anum_hypertable_schema_name)] = NameGetDatum(schema_name);
|
||||||
values[Anum_hypertable_table_name - 1] = NameGetDatum(table_name);
|
values[AttrNumberGetAttrOffset(Anum_hypertable_table_name)] = NameGetDatum(table_name);
|
||||||
values[Anum_hypertable_associated_schema_name - 1] = NameGetDatum(associated_schema_name);
|
values[AttrNumberGetAttrOffset(Anum_hypertable_associated_schema_name)] = NameGetDatum(associated_schema_name);
|
||||||
values[Anum_hypertable_num_dimensions - 1] = Int16GetDatum(num_dimensions);
|
values[AttrNumberGetAttrOffset(Anum_hypertable_num_dimensions)] = Int16GetDatum(num_dimensions);
|
||||||
|
|
||||||
if (NULL != chunk_sizing_func_schema && NULL != chunk_sizing_func_name)
|
if (NULL != chunk_sizing_func_schema && NULL != chunk_sizing_func_name)
|
||||||
{
|
{
|
||||||
values[Anum_hypertable_chunk_sizing_func_schema - 1] = NameGetDatum(chunk_sizing_func_schema);
|
values[AttrNumberGetAttrOffset(Anum_hypertable_chunk_sizing_func_schema)] = NameGetDatum(chunk_sizing_func_schema);
|
||||||
values[Anum_hypertable_chunk_sizing_func_name - 1] = NameGetDatum(chunk_sizing_func_name);
|
values[AttrNumberGetAttrOffset(Anum_hypertable_chunk_sizing_func_name)] = NameGetDatum(chunk_sizing_func_name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nulls[Anum_hypertable_chunk_sizing_func_schema - 1] = true;
|
nulls[AttrNumberGetAttrOffset(Anum_hypertable_chunk_sizing_func_schema)] = true;
|
||||||
nulls[Anum_hypertable_chunk_sizing_func_name - 1] = true;
|
nulls[AttrNumberGetAttrOffset(Anum_hypertable_chunk_sizing_func_name)] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chunk_target_size < 0)
|
if (chunk_target_size < 0)
|
||||||
chunk_target_size = 0;
|
chunk_target_size = 0;
|
||||||
|
|
||||||
values[Anum_hypertable_chunk_target_size - 1] = Int64GetDatum(chunk_target_size);
|
values[AttrNumberGetAttrOffset(Anum_hypertable_chunk_target_size)] = Int64GetDatum(chunk_target_size);
|
||||||
|
|
||||||
catalog_become_owner(catalog_get(), &sec_ctx);
|
catalog_become_owner(catalog_get(), &sec_ctx);
|
||||||
values[Anum_hypertable_id - 1] = Int32GetDatum(catalog_table_next_seq_id(catalog_get(), HYPERTABLE));
|
values[AttrNumberGetAttrOffset(Anum_hypertable_id)] = Int32GetDatum(catalog_table_next_seq_id(catalog_get(), HYPERTABLE));
|
||||||
|
|
||||||
if (NULL != associated_table_prefix)
|
if (NULL != associated_table_prefix)
|
||||||
values[Anum_hypertable_associated_table_prefix - 1] = NameGetDatum(associated_table_prefix);
|
values[AttrNumberGetAttrOffset(Anum_hypertable_associated_table_prefix)] = NameGetDatum(associated_table_prefix);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
memset(NameStr(default_associated_table_prefix), '\0', NAMEDATALEN);
|
memset(NameStr(default_associated_table_prefix), '\0', NAMEDATALEN);
|
||||||
snprintf(NameStr(default_associated_table_prefix),
|
snprintf(NameStr(default_associated_table_prefix),
|
||||||
NAMEDATALEN,
|
NAMEDATALEN,
|
||||||
DEFAULT_ASSOCIATED_TABLE_PREFIX_FORMAT,
|
DEFAULT_ASSOCIATED_TABLE_PREFIX_FORMAT,
|
||||||
DatumGetInt32(values[Anum_hypertable_id - 1]));
|
DatumGetInt32(values[AttrNumberGetAttrOffset(Anum_hypertable_id)]));
|
||||||
values[Anum_hypertable_associated_table_prefix - 1] =
|
values[AttrNumberGetAttrOffset(Anum_hypertable_associated_table_prefix)] =
|
||||||
NameGetDatum(&default_associated_table_prefix);
|
NameGetDatum(&default_associated_table_prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,9 +321,9 @@ tablespace_insert_relation(Relation rel, int32 hypertable_id, const char *tspcna
|
|||||||
|
|
||||||
memset(values, 0, sizeof(values));
|
memset(values, 0, sizeof(values));
|
||||||
id = catalog_table_next_seq_id(catalog_get(), TABLESPACE);
|
id = catalog_table_next_seq_id(catalog_get(), TABLESPACE);
|
||||||
values[Anum_tablespace_id - 1] = Int32GetDatum(id);
|
values[AttrNumberGetAttrOffset(Anum_tablespace_id)] = Int32GetDatum(id);
|
||||||
values[Anum_tablespace_hypertable_id - 1] = Int32GetDatum(hypertable_id);
|
values[AttrNumberGetAttrOffset(Anum_tablespace_hypertable_id)] = Int32GetDatum(hypertable_id);
|
||||||
values[Anum_tablespace_tablespace_name - 1] =
|
values[AttrNumberGetAttrOffset(Anum_tablespace_tablespace_name)] =
|
||||||
DirectFunctionCall1(namein, CStringGetDatum(tspcname));
|
DirectFunctionCall1(namein, CStringGetDatum(tspcname));
|
||||||
|
|
||||||
catalog_insert_values(rel, desc, values, nulls);
|
catalog_insert_values(rel, desc, values, nulls);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user