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

Commitc3d6c7d

Browse files
committed
Calculation of keys_are_unique flag was wrong for cases involving
redundant cross-datatype comparisons. Per example from Merlin Moncure.
1 parent6ad835f commitc3d6c7d

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

‎src/backend/access/nbtree/nbtutils.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtutils.c,v 1.60 2004/08/29 05:06:40 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtutils.c,v 1.61 2004/12/15 19:16:39 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -224,11 +224,11 @@ _bt_preprocess_keys(IndexScanDesc scan)
224224
BTScanOpaqueso= (BTScanOpaque)scan->opaque;
225225
intnumberOfKeys=scan->numberOfKeys;
226226
intnew_numberOfKeys;
227+
intnumberOfEqualCols;
227228
ScanKeyinkeys;
228229
ScanKeyoutkeys;
229230
ScanKeycur;
230231
ScanKeyxform[BTMaxStrategyNumber];
231-
boolallEqualSoFar;
232232
boolhasOtherTypeEqual;
233233
Datumtest;
234234
inti,
@@ -278,7 +278,7 @@ _bt_preprocess_keys(IndexScanDesc scan)
278278
* Otherwise, do the full set of pushups.
279279
*/
280280
new_numberOfKeys=0;
281-
allEqualSoFar=true;
281+
numberOfEqualCols=0;
282282

283283
/*
284284
* Initialize for processing of keys for attr 1.
@@ -321,7 +321,7 @@ _bt_preprocess_keys(IndexScanDesc scan)
321321
*/
322322
if (i==numberOfKeys||cur->sk_attno!=attno)
323323
{
324-
boolpriorAllEqualSoFar=allEqualSoFar;
324+
intpriorNumberOfEqualCols=numberOfEqualCols;
325325

326326
/* check input keys are correctly ordered */
327327
if (i<numberOfKeys&&cur->sk_attno!=attno+1)
@@ -355,14 +355,14 @@ _bt_preprocess_keys(IndexScanDesc scan)
355355
xform[BTLessEqualStrategyNumber-1]=NULL;
356356
xform[BTGreaterEqualStrategyNumber-1]=NULL;
357357
xform[BTGreaterStrategyNumber-1]=NULL;
358+
/* track number of attrs for which we have "=" keys */
359+
numberOfEqualCols++;
358360
}
359361
else
360362
{
361-
/*
362-
* If no "=" for this key, we're done with required keys
363-
*/
364-
if (!hasOtherTypeEqual)
365-
allEqualSoFar= false;
363+
/* track number of attrs for which we have "=" keys */
364+
if (hasOtherTypeEqual)
365+
numberOfEqualCols++;
366366
}
367367

368368
/* keep only one of <, <= */
@@ -411,7 +411,7 @@ _bt_preprocess_keys(IndexScanDesc scan)
411411
* If all attrs before this one had "=", include these keys
412412
* into the required-keys count.
413413
*/
414-
if (priorAllEqualSoFar)
414+
if (priorNumberOfEqualCols==attno-1)
415415
so->numberOfRequiredKeys=new_numberOfKeys;
416416

417417
/*
@@ -468,8 +468,8 @@ _bt_preprocess_keys(IndexScanDesc scan)
468468
* If unique index and we have equality keys for all columns, set
469469
* keys_are_unique flag for higher levels.
470470
*/
471-
if (allEqualSoFar&&relation->rd_index->indisunique&&
472-
relation->rd_rel->relnatts==new_numberOfKeys)
471+
if (relation->rd_index->indisunique&&
472+
relation->rd_rel->relnatts==numberOfEqualCols)
473473
scan->keys_are_unique= true;
474474
}
475475

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp