mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-18 19:59:48 +08:00
Switch to using get_attnum function
This is a fix for a rebase on master since `attno_find_by_attname` was removed.
This commit is contained in:
parent
4140c58f1b
commit
6465a4e85a
@ -422,9 +422,10 @@ row_compressor_init(RowCompressor *row_compressor, TupleDesc uncompressed_tuple_
|
|||||||
Name sequence_num_metadata_name = DatumGetName(
|
Name sequence_num_metadata_name = DatumGetName(
|
||||||
DirectFunctionCall1(namein,
|
DirectFunctionCall1(namein,
|
||||||
CStringGetDatum(COMPRESSION_COLUMN_METADATA_SEQUENCE_NUM_NAME)));
|
CStringGetDatum(COMPRESSION_COLUMN_METADATA_SEQUENCE_NUM_NAME)));
|
||||||
AttrNumber count_metadata_column_num = attno_find_by_attname(out_desc, count_metadata_name);
|
AttrNumber count_metadata_column_num =
|
||||||
|
get_attnum(compressed_table->rd_id, NameStr(*count_metadata_name));
|
||||||
AttrNumber sequence_num_column_num =
|
AttrNumber sequence_num_column_num =
|
||||||
attno_find_by_attname(out_desc, sequence_num_metadata_name);
|
get_attnum(compressed_table->rd_id, NameStr(*sequence_num_metadata_name));
|
||||||
Oid compressed_data_type_oid = ts_custom_type_cache_get(CUSTOM_TYPE_COMPRESSED_DATA)->type_oid;
|
Oid compressed_data_type_oid = ts_custom_type_cache_get(CUSTOM_TYPE_COMPRESSED_DATA)->type_oid;
|
||||||
|
|
||||||
if (count_metadata_column_num == InvalidAttrNumber)
|
if (count_metadata_column_num == InvalidAttrNumber)
|
||||||
@ -463,7 +464,7 @@ row_compressor_init(RowCompressor *row_compressor, TupleDesc uncompressed_tuple_
|
|||||||
PerColumn *column = &row_compressor->per_column[in_column_offset];
|
PerColumn *column = &row_compressor->per_column[in_column_offset];
|
||||||
Form_pg_attribute column_attr = TupleDescAttr(uncompressed_tuple_desc, in_column_offset);
|
Form_pg_attribute column_attr = TupleDescAttr(uncompressed_tuple_desc, in_column_offset);
|
||||||
AttrNumber compressed_colnum =
|
AttrNumber compressed_colnum =
|
||||||
attno_find_by_attname(out_desc, (Name) &compression_info->attname);
|
get_attnum(compressed_table->rd_id, NameStr(compression_info->attname));
|
||||||
Form_pg_attribute compressed_column_attr =
|
Form_pg_attribute compressed_column_attr =
|
||||||
TupleDescAttr(out_desc, AttrNumberGetAttrOffset(compressed_colnum));
|
TupleDescAttr(out_desc, AttrNumberGetAttrOffset(compressed_colnum));
|
||||||
row_compressor->uncompressed_col_to_compressed_col[in_column_offset] =
|
row_compressor->uncompressed_col_to_compressed_col[in_column_offset] =
|
||||||
@ -482,10 +483,7 @@ row_compressor_init(RowCompressor *row_compressor, TupleDesc uncompressed_tuple_
|
|||||||
{
|
{
|
||||||
char *segment_col_name = compression_column_segment_min_max_name(compression_info);
|
char *segment_col_name = compression_column_segment_min_max_name(compression_info);
|
||||||
AttrNumber segment_min_max_attr_number =
|
AttrNumber segment_min_max_attr_number =
|
||||||
attno_find_by_attname(out_desc,
|
get_attnum(compressed_table->rd_id, segment_col_name);
|
||||||
DatumGetName(DirectFunctionCall1(namein,
|
|
||||||
CStringGetDatum(
|
|
||||||
segment_col_name))));
|
|
||||||
if (segment_min_max_attr_number == InvalidAttrNumber)
|
if (segment_min_max_attr_number == InvalidAttrNumber)
|
||||||
elog(ERROR, "couldn't find metadata column %s", segment_col_name);
|
elog(ERROR, "couldn't find metadata column %s", segment_col_name);
|
||||||
segment_min_max_attr_offset = AttrNumberGetAttrOffset(segment_min_max_attr_number);
|
segment_min_max_attr_offset = AttrNumberGetAttrOffset(segment_min_max_attr_number);
|
||||||
@ -894,6 +892,7 @@ typedef struct RowDecompressor
|
|||||||
} RowDecompressor;
|
} RowDecompressor;
|
||||||
|
|
||||||
static PerCompressedColumn *create_per_compressed_column(TupleDesc in_desc, TupleDesc out_desc,
|
static PerCompressedColumn *create_per_compressed_column(TupleDesc in_desc, TupleDesc out_desc,
|
||||||
|
Oid out_relid,
|
||||||
Oid compressed_data_type_oid);
|
Oid compressed_data_type_oid);
|
||||||
static void populate_per_compressed_columns_from_data(PerCompressedColumn *per_compressed_cols,
|
static void populate_per_compressed_columns_from_data(PerCompressedColumn *per_compressed_cols,
|
||||||
int16 num_cols, Datum *compressed_datums,
|
int16 num_cols, Datum *compressed_datums,
|
||||||
@ -932,8 +931,10 @@ decompress_chunk(Oid in_table, Oid out_table)
|
|||||||
|
|
||||||
{
|
{
|
||||||
RowDecompressor decompressor = {
|
RowDecompressor decompressor = {
|
||||||
.per_compressed_cols =
|
.per_compressed_cols = create_per_compressed_column(in_desc,
|
||||||
create_per_compressed_column(in_desc, out_desc, compressed_data_type_oid),
|
out_desc,
|
||||||
|
out_table,
|
||||||
|
compressed_data_type_oid),
|
||||||
.num_compressed_columns = in_desc->natts,
|
.num_compressed_columns = in_desc->natts,
|
||||||
|
|
||||||
.out_desc = out_desc,
|
.out_desc = out_desc,
|
||||||
@ -982,12 +983,12 @@ decompress_chunk(Oid in_table, Oid out_table)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static PerCompressedColumn *
|
static PerCompressedColumn *
|
||||||
create_per_compressed_column(TupleDesc in_desc, TupleDesc out_desc, Oid compressed_data_type_oid)
|
create_per_compressed_column(TupleDesc in_desc, TupleDesc out_desc, Oid out_relid,
|
||||||
|
Oid compressed_data_type_oid)
|
||||||
{
|
{
|
||||||
PerCompressedColumn *per_compressed_cols =
|
PerCompressedColumn *per_compressed_cols =
|
||||||
palloc(sizeof(*per_compressed_cols) * in_desc->natts);
|
palloc(sizeof(*per_compressed_cols) * in_desc->natts);
|
||||||
|
|
||||||
Assert(in_desc->natts >= out_desc->natts);
|
|
||||||
Assert(OidIsValid(compressed_data_type_oid));
|
Assert(OidIsValid(compressed_data_type_oid));
|
||||||
|
|
||||||
for (int16 col = 0; col < in_desc->natts; col++)
|
for (int16 col = 0; col < in_desc->natts; col++)
|
||||||
@ -997,13 +998,13 @@ create_per_compressed_column(TupleDesc in_desc, TupleDesc out_desc, Oid compress
|
|||||||
int16 decompressed_column_offset;
|
int16 decompressed_column_offset;
|
||||||
PerCompressedColumn *per_compressed_col = &per_compressed_cols[col];
|
PerCompressedColumn *per_compressed_col = &per_compressed_cols[col];
|
||||||
Form_pg_attribute compressed_attr = TupleDescAttr(in_desc, col);
|
Form_pg_attribute compressed_attr = TupleDescAttr(in_desc, col);
|
||||||
|
char *col_name = NameStr(compressed_attr->attname);
|
||||||
|
|
||||||
/* find the mapping from compressed column to uncompressed column, setting
|
/* find the mapping from compressed column to uncompressed column, setting
|
||||||
* the index of columns that don't have an uncompressed version
|
* the index of columns that don't have an uncompressed version
|
||||||
* (such as metadata) to -1
|
* (such as metadata) to -1
|
||||||
*/
|
*/
|
||||||
Name col_name = &compressed_attr->attname;
|
AttrNumber decompressed_colnum = get_attnum(out_relid, col_name);
|
||||||
AttrNumber decompressed_colnum = attno_find_by_attname(out_desc, col_name);
|
|
||||||
if (!AttributeNumberIsValid(decompressed_colnum))
|
if (!AttributeNumberIsValid(decompressed_colnum))
|
||||||
{
|
{
|
||||||
*per_compressed_col = (PerCompressedColumn){
|
*per_compressed_col = (PerCompressedColumn){
|
||||||
@ -1025,7 +1026,7 @@ create_per_compressed_column(TupleDesc in_desc, TupleDesc out_desc, Oid compress
|
|||||||
"segment-by column \"%s\"",
|
"segment-by column \"%s\"",
|
||||||
format_type_be(compressed_attr->atttypid),
|
format_type_be(compressed_attr->atttypid),
|
||||||
format_type_be(decompressed_type),
|
format_type_be(decompressed_type),
|
||||||
NameStr(*col_name));
|
col_name);
|
||||||
|
|
||||||
*per_compressed_col = (PerCompressedColumn){
|
*per_compressed_col = (PerCompressedColumn){
|
||||||
.decompressed_column_offset = decompressed_column_offset,
|
.decompressed_column_offset = decompressed_column_offset,
|
||||||
|
@ -182,7 +182,7 @@ compresscolinfo_init(CompressColInfo *cc, Oid srctbl_relid, List *segmentby_cols
|
|||||||
foreach (lc, segmentby_cols)
|
foreach (lc, segmentby_cols)
|
||||||
{
|
{
|
||||||
CompressedParsedCol *col = (CompressedParsedCol *) lfirst(lc);
|
CompressedParsedCol *col = (CompressedParsedCol *) lfirst(lc);
|
||||||
AttrNumber col_attno = attno_find_by_attname(tupdesc, &col->colname);
|
AttrNumber col_attno = get_attnum(rel->rd_id, NameStr(col->colname));
|
||||||
if (col_attno == InvalidAttrNumber)
|
if (col_attno == InvalidAttrNumber)
|
||||||
{
|
{
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -198,7 +198,7 @@ compresscolinfo_init(CompressColInfo *cc, Oid srctbl_relid, List *segmentby_cols
|
|||||||
foreach (lc, orderby_cols)
|
foreach (lc, orderby_cols)
|
||||||
{
|
{
|
||||||
CompressedParsedCol *col = (CompressedParsedCol *) lfirst(lc);
|
CompressedParsedCol *col = (CompressedParsedCol *) lfirst(lc);
|
||||||
AttrNumber col_attno = attno_find_by_attname(tupdesc, &col->colname);
|
AttrNumber col_attno = get_attnum(rel->rd_id, NameStr(col->colname));
|
||||||
if (col_attno == InvalidAttrNumber)
|
if (col_attno == InvalidAttrNumber)
|
||||||
{
|
{
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user