提交 0340f543 编写于 作者: H Heikki Linnakangas

Remove list_find_* functions.

They don't exist in the upstream. All but one of the callers actually just
needed list_member_*().
上级 15ae5084
......@@ -445,7 +445,7 @@ AOCSDrop(Relation aorel,
for(i = 0 ; i < total_segfiles ; i++)
{
segno = segfile_array[i]->segno;
if (list_find_int(compaction_segno, segno) < 0)
if (!list_member_int(compaction_segno, segno))
{
continue;
}
......@@ -538,7 +538,7 @@ AOCSCompact(Relation aorel,
for(i = 0 ; i < total_segfiles ; i++)
{
segno = segfile_array[i]->segno;
if (list_find_int(compaction_segno, segno) < 0)
if (!list_member_int(compaction_segno, segno))
{
continue;
}
......
......@@ -521,7 +521,7 @@ AppendOnlyDrop(Relation aorel, List *compaction_segno)
for(i = 0 ; i < total_segfiles ; i++)
{
segno = segfile_array[i]->segno;
if (list_find_int(compaction_segno, segno) < 0)
if (!list_member_int(compaction_segno, segno))
{
continue;
}
......@@ -672,7 +672,7 @@ AppendOnlyCompact(Relation aorel,
for(i = 0 ; i < total_segfiles ; i++)
{
segno = segfile_array[i]->segno;
if (list_find_int(compaction_segno, segno) < 0)
if (!list_member_int(compaction_segno, segno))
{
continue;
}
......
......@@ -705,7 +705,7 @@ DeregisterSegnoForCompactionDrop(Oid relid, List *compactedSegmentFileList)
{
AOSegfileStatus *segfilestat = &aoentry->relsegfiles[i];
if (list_find_int(compactedSegmentFileList, i) >= 0)
if (list_member_int(compactedSegmentFileList, i))
{
ereportif(Debug_appendonly_print_segfile_choice, LOG,
(errmsg("Deregister segno %d for drop "
......@@ -751,7 +751,7 @@ RegisterSegnoForCompactionDrop(Oid relid, List *compactedSegmentFileList)
{
AOSegfileStatus *segfilestat = &aoentry->relsegfiles[i];
if (list_find_int(compactedSegmentFileList, i) >= 0)
if (list_member_int(compactedSegmentFileList, i))
{
ereportif(Debug_appendonly_print_segfile_choice, LOG,
(errmsg("Register segno %d for drop "
......@@ -878,8 +878,8 @@ SetSegnoForCompaction(Relation rel,
for (i = 0; i < MAX_AOREL_CONCURRENCY ; i++)
{
AOSegfileStatus *segfilestat = &aoentry->relsegfiles[i];
bool in_compaction_list = list_find_int(compactedSegmentFileList, i) >= 0;
bool in_inserted_list = list_find_int(insertedSegmentFileList, i) >= 0;
bool in_compaction_list = list_member_int(compactedSegmentFileList, i);
bool in_inserted_list = list_member_int(insertedSegmentFileList, i);
ereportif(Debug_appendonly_print_segfile_choice, LOG,
(errmsg("SetSegnoForCompaction: "
......@@ -1005,8 +1005,8 @@ SetSegnoForCompactionInsert(Relation rel,
for (i = 1; i < MAX_AOREL_CONCURRENCY ; i++)
{
AOSegfileStatus *segfilestat = &aoentry->relsegfiles[i];
bool in_compaction_list = list_find_int(compacted_segno, i) >= 0 ||
list_find_int(compactedSegmentFileList, i) >= 0;
bool in_compaction_list = list_member_int(compacted_segno, i) ||
list_member_int(compactedSegmentFileList, i);
if (segfilestat->total_tupcount < min_tupcount &&
segfilestat->state == AVAILABLE &&
......
......@@ -879,7 +879,7 @@ getPartConstraints(Oid partOid, Oid rootOid, List *partKey)
{
int partKeyCol = lfirst_int(lc);
if (list_find_int(keys, partKeyCol) < 0)
if (!list_member_int(keys, partKeyCol))
{
// passed in key is not found in the constraint. return NULL
if (NULL != result)
......
......@@ -450,8 +450,17 @@ rel_partition_keys_kinds_ordered(Oid relid, List **pkeys, List **pkinds)
// now order the keys and kinds by level
for (int i = 0; i< nlevels; i++)
{
int pos = list_find_int(levels, i);
Assert (0 <= pos);
ListCell *cell;
int pos = 0;
/* Find i's position in the 'levels' list. */
foreach(cell, levels)
{
if (lfirst_int(cell) == i)
break;
++pos;
}
Assert (cell != NULL);
if (pkeys != NULL)
*pkeys = lappend(*pkeys, list_nth(keysUnordered, pos));
......@@ -2648,7 +2657,7 @@ getPartConstraintsContainsKeys(Oid partOid, Oid rootOid, List *partKey)
for (int i = 0; i < numKeys; i++)
{
int16 key_elem = DatumGetInt16(dats[i]);
if (list_find_int(partKey, key_elem) >= 0)
if (list_member_int(partKey, key_elem))
{
found = true;
break;
......
......@@ -12026,7 +12026,7 @@ ATExecSetDistributedBy(Relation rel, Node *node, AlterTableCmd *cmd)
goto l_distro_fini;
}
if (list_find_oid(qe_data->relids, tarrelid) < 0)
if (!list_member_oid(qe_data->relids, tarrelid))
{
heap_close(rel, NoLock);
goto l_distro_fini;
......
......@@ -450,77 +450,6 @@ list_nth_oid(List *list, int n)
return lfirst_oid(list_nth_cell(list, n));
}
/*
* find if datum's position in list (0 based). If not in list return -1.
* find predicate is equal(), int==, oid==, ptr== respecitively.
*/
int list_find(List *list, void *datum)
{
ListCell *cell;
int i = 0;
check_list_invariants(list);
foreach(cell, list)
{
if(equal(lfirst(cell), datum))
return i;
++i;
}
return -1;
}
int list_find_int(List *list, int datum)
{
ListCell *cell;
int i = 0;
Assert(IsIntegerList(list));
check_list_invariants(list);
foreach(cell, list)
{
if(lfirst_int(cell) == datum)
return i;
++i;
}
return -1;
}
int list_find_oid(List *list, Oid datum)
{
ListCell *cell;
int i = 0;
Assert(IsOidList(list));
check_list_invariants(list);
foreach(cell, list)
{
if(lfirst_oid(cell) == datum)
return i;
++i;
}
return -1;
}
int list_find_ptr(List *list, void *datum)
{
ListCell *cell;
int i = 0;
Assert(IsPointerList(list));
check_list_invariants(list);
foreach(cell, list)
{
if(lfirst(cell) == datum)
return i;
++i;
}
return -1;
}
/*
* Return true iff 'datum' is a member of the list. Equality is
* determined via equal(), so callers should ensure that they pass a
......
......@@ -224,11 +224,6 @@ extern void *list_nth(List *list, int n);
extern int list_nth_int(List *list, int n);
extern Oid list_nth_oid(List *list, int n);
extern int list_find(List *list, void *datum);
extern int list_find_ptr(List *list, void *datum);
extern int list_find_int(List *list, int datum);
extern int list_find_oid(List *list, Oid datum);
extern bool list_member(List *list, void *datum);
extern bool list_member_ptr(List *list, void *datum);
extern bool list_member_int(List *list, int datum);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册