|
8 | 8 | * |
9 | 9 | * |
10 | 10 | * IDENTIFICATION |
11 | | - * $PostgreSQL: pgsql/src/backend/access/index/genam.c,v 1.71 2008/06/19 00:46:03 alvherre Exp $ |
| 11 | + * $PostgreSQL: pgsql/src/backend/access/index/genam.c,v 1.72 2008/11/06 13:07:08 heikki Exp $ |
12 | 12 | * |
13 | 13 | * NOTES |
14 | 14 | * many of the old access method routines have been turned into |
@@ -194,16 +194,21 @@ systable_beginscan(Relation heapRelation, |
194 | 194 | { |
195 | 195 | inti; |
196 | 196 |
|
197 | | -/* |
198 | | - * Change attribute numbers to be index column numbers. |
199 | | - * |
200 | | - * This code could be generalized to search for the index key numbers |
201 | | - * to substitute, but for now there's no need. |
202 | | - */ |
| 197 | +/* Change attribute numbers to be index column numbers. */ |
203 | 198 | for (i=0;i<nkeys;i++) |
204 | 199 | { |
205 | | -Assert(key[i].sk_attno==irel->rd_index->indkey.values[i]); |
206 | | -key[i].sk_attno=i+1; |
| 200 | +intj; |
| 201 | + |
| 202 | +for (j=0;j<irel->rd_index->indnatts;j++) |
| 203 | +{ |
| 204 | +if (key[i].sk_attno==irel->rd_index->indkey.values[j]) |
| 205 | +{ |
| 206 | +key[i].sk_attno=j+1; |
| 207 | +break; |
| 208 | +} |
| 209 | +} |
| 210 | +if (j==irel->rd_index->indnatts) |
| 211 | +elog(ERROR,"column is not in index"); |
207 | 212 | } |
208 | 213 |
|
209 | 214 | sysscan->iscan=index_beginscan(heapRelation,irel, |
@@ -352,16 +357,21 @@ systable_beginscan_ordered(Relation heapRelation, |
352 | 357 | sysscan->heap_rel=heapRelation; |
353 | 358 | sysscan->irel=indexRelation; |
354 | 359 |
|
355 | | -/* |
356 | | - * Change attribute numbers to be index column numbers. |
357 | | - * |
358 | | - * This code could be generalized to search for the index key numbers |
359 | | - * to substitute, but for now there's no need. |
360 | | - */ |
| 360 | +/* Change attribute numbers to be index column numbers. */ |
361 | 361 | for (i=0;i<nkeys;i++) |
362 | 362 | { |
363 | | -Assert(key[i].sk_attno==indexRelation->rd_index->indkey.values[i]); |
364 | | -key[i].sk_attno=i+1; |
| 363 | +intj; |
| 364 | + |
| 365 | +for (j=0;j<indexRelation->rd_index->indnatts;j++) |
| 366 | +{ |
| 367 | +if (key[i].sk_attno==indexRelation->rd_index->indkey.values[j]) |
| 368 | +{ |
| 369 | +key[i].sk_attno=j+1; |
| 370 | +break; |
| 371 | +} |
| 372 | +} |
| 373 | +if (j==indexRelation->rd_index->indnatts) |
| 374 | +elog(ERROR,"column is not in index"); |
365 | 375 | } |
366 | 376 |
|
367 | 377 | sysscan->iscan=index_beginscan(heapRelation,indexRelation, |
|