mirror of https://github.com/citusdata/citus.git
Move the logic that builds relation col list into a function (#4964)
parent
59fea712e2
commit
7def297a3b
|
@ -109,6 +109,7 @@ static void ColumnarProcessUtility(PlannedStmt *pstmt,
|
||||||
QueryCompletionCompat *completionTag);
|
QueryCompletionCompat *completionTag);
|
||||||
static bool ConditionalLockRelationWithTimeout(Relation rel, LOCKMODE lockMode,
|
static bool ConditionalLockRelationWithTimeout(Relation rel, LOCKMODE lockMode,
|
||||||
int timeout, int retryInterval);
|
int timeout, int retryInterval);
|
||||||
|
static List * NeededColumnsList(TupleDesc tupdesc, Bitmapset *attr_needed);
|
||||||
static void LogRelationStats(Relation rel, int elevel);
|
static void LogRelationStats(Relation rel, int elevel);
|
||||||
static void TruncateColumnar(Relation rel, int elevel);
|
static void TruncateColumnar(Relation rel, int elevel);
|
||||||
static HeapTuple ColumnarSlotCopyHeapTuple(TupleTableSlot *slot);
|
static HeapTuple ColumnarSlotCopyHeapTuple(TupleTableSlot *slot);
|
||||||
|
@ -212,17 +213,7 @@ static ColumnarReadState *
|
||||||
init_columnar_read_state(Relation relation, TupleDesc tupdesc, Bitmapset *attr_needed,
|
init_columnar_read_state(Relation relation, TupleDesc tupdesc, Bitmapset *attr_needed,
|
||||||
List *scanQual)
|
List *scanQual)
|
||||||
{
|
{
|
||||||
List *neededColumnList = NIL;
|
List *neededColumnList = NeededColumnsList(tupdesc, attr_needed);
|
||||||
|
|
||||||
for (int i = 0; i < tupdesc->natts; i++)
|
|
||||||
{
|
|
||||||
if (bms_is_member(i, attr_needed) && !tupdesc->attrs[i].attisdropped)
|
|
||||||
{
|
|
||||||
/* attr_needed is 0-indexed; neededColumnList is 1-indexed */
|
|
||||||
neededColumnList = lappend_int(neededColumnList, i + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ColumnarReadState *readState = ColumnarBeginRead(relation, tupdesc, neededColumnList,
|
ColumnarReadState *readState = ColumnarBeginRead(relation, tupdesc, neededColumnList,
|
||||||
scanQual);
|
scanQual);
|
||||||
|
|
||||||
|
@ -615,16 +606,10 @@ columnar_relation_copy_for_cluster(Relation OldHeap, Relation NewHeap,
|
||||||
columnarOptions,
|
columnarOptions,
|
||||||
targetDesc);
|
targetDesc);
|
||||||
|
|
||||||
List *projectedColumnList = NIL;
|
/* we need all columns */
|
||||||
for (int i = 0; i < sourceDesc->natts; i++)
|
int natts = OldHeap->rd_att->natts;
|
||||||
{
|
Bitmapset *attr_needed = bms_add_range(NULL, 0, natts - 1);
|
||||||
if (!sourceDesc->attrs[i].attisdropped)
|
List *projectedColumnList = NeededColumnsList(sourceDesc, attr_needed);
|
||||||
{
|
|
||||||
/* projectedColumnList is 1-indexed */
|
|
||||||
projectedColumnList = lappend_int(projectedColumnList, i + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ColumnarReadState *readState = ColumnarBeginRead(OldHeap, sourceDesc,
|
ColumnarReadState *readState = ColumnarBeginRead(OldHeap, sourceDesc,
|
||||||
projectedColumnList,
|
projectedColumnList,
|
||||||
NULL);
|
NULL);
|
||||||
|
@ -647,6 +632,34 @@ columnar_relation_copy_for_cluster(Relation OldHeap, Relation NewHeap,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NeededColumnsList returns a list of AttrNumber's for the columns that
|
||||||
|
* are not dropped and specified by attr_needed.
|
||||||
|
*/
|
||||||
|
static List *
|
||||||
|
NeededColumnsList(TupleDesc tupdesc, Bitmapset *attr_needed)
|
||||||
|
{
|
||||||
|
List *columnList = NIL;
|
||||||
|
|
||||||
|
for (int i = 0; i < tupdesc->natts; i++)
|
||||||
|
{
|
||||||
|
if (tupdesc->attrs[i].attisdropped)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* attr_needed is 0-indexed but columnList is 1-indexed */
|
||||||
|
if (bms_is_member(i, attr_needed))
|
||||||
|
{
|
||||||
|
AttrNumber varattno = i + 1;
|
||||||
|
columnList = lappend_int(columnList, varattno);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return columnList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* columnar_vacuum_rel implements VACUUM without FULL option.
|
* columnar_vacuum_rel implements VACUUM without FULL option.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue