Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5ae2952

Browse files
committed
The logic in systable_beginscan to translate heap attribute numbers to
index column numbers needs to handle the case where you have more thanone scankey on the same index column. toast_fetch_datum_slice() needs it.
1 parent53b4e46 commit5ae2952

File tree

1 file changed

+27
-17
lines changed

1 file changed

+27
-17
lines changed

‎src/backend/access/index/genam.c

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* 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 $
1212
*
1313
* NOTES
1414
* many of the old access method routines have been turned into
@@ -194,16 +194,21 @@ systable_beginscan(Relation heapRelation,
194194
{
195195
inti;
196196

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. */
203198
for (i=0;i<nkeys;i++)
204199
{
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");
207212
}
208213

209214
sysscan->iscan=index_beginscan(heapRelation,irel,
@@ -352,16 +357,21 @@ systable_beginscan_ordered(Relation heapRelation,
352357
sysscan->heap_rel=heapRelation;
353358
sysscan->irel=indexRelation;
354359

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. */
361361
for (i=0;i<nkeys;i++)
362362
{
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");
365375
}
366376

367377
sysscan->iscan=index_beginscan(heapRelation,indexRelation,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp