mirror of
https://github.com/postgres/postgres.git
synced 2025-05-06 19:59:18 +03:00
The logic in systable_beginscan to translate heap attribute numbers to
index column numbers needs to handle the case where you have more than one scankey on the same index column. toast_fetch_datum_slice() needs it.
This commit is contained in:
parent
53b4e469ca
commit
5ae29525d1
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/access/index/genam.c,v 1.71 2008/06/19 00:46:03 alvherre Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/access/index/genam.c,v 1.72 2008/11/06 13:07:08 heikki Exp $
|
||||
*
|
||||
* NOTES
|
||||
* many of the old access method routines have been turned into
|
||||
@ -194,16 +194,21 @@ systable_beginscan(Relation heapRelation,
|
||||
{
|
||||
int i;
|
||||
|
||||
/*
|
||||
* Change attribute numbers to be index column numbers.
|
||||
*
|
||||
* This code could be generalized to search for the index key numbers
|
||||
* to substitute, but for now there's no need.
|
||||
*/
|
||||
/* Change attribute numbers to be index column numbers. */
|
||||
for (i = 0; i < nkeys; i++)
|
||||
{
|
||||
Assert(key[i].sk_attno == irel->rd_index->indkey.values[i]);
|
||||
key[i].sk_attno = i + 1;
|
||||
int j;
|
||||
|
||||
for (j = 0; j < irel->rd_index->indnatts; j++)
|
||||
{
|
||||
if (key[i].sk_attno == irel->rd_index->indkey.values[j])
|
||||
{
|
||||
key[i].sk_attno = j + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j == irel->rd_index->indnatts)
|
||||
elog(ERROR, "column is not in index");
|
||||
}
|
||||
|
||||
sysscan->iscan = index_beginscan(heapRelation, irel,
|
||||
@ -352,16 +357,21 @@ systable_beginscan_ordered(Relation heapRelation,
|
||||
sysscan->heap_rel = heapRelation;
|
||||
sysscan->irel = indexRelation;
|
||||
|
||||
/*
|
||||
* Change attribute numbers to be index column numbers.
|
||||
*
|
||||
* This code could be generalized to search for the index key numbers
|
||||
* to substitute, but for now there's no need.
|
||||
*/
|
||||
/* Change attribute numbers to be index column numbers. */
|
||||
for (i = 0; i < nkeys; i++)
|
||||
{
|
||||
Assert(key[i].sk_attno == indexRelation->rd_index->indkey.values[i]);
|
||||
key[i].sk_attno = i + 1;
|
||||
int j;
|
||||
|
||||
for (j = 0; j < indexRelation->rd_index->indnatts; j++)
|
||||
{
|
||||
if (key[i].sk_attno == indexRelation->rd_index->indkey.values[j])
|
||||
{
|
||||
key[i].sk_attno = j + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j == indexRelation->rd_index->indnatts)
|
||||
elog(ERROR, "column is not in index");
|
||||
}
|
||||
|
||||
sysscan->iscan = index_beginscan(heapRelation, indexRelation,
|
||||
|
Loading…
x
Reference in New Issue
Block a user