Re: possible wierd boolean bug?
От
Tom Lane
Тема
Re: possible wierd boolean bug?
Дата
Msg-id
5605.1103138330@sss.pgh.pa.us
Ответ на
Re: possible wierd boolean bug? (Merlin Moncure)
Список
Дерево обсуждения
Re: possible wierd boolean bug? "Merlin Moncure" <merlin.moncure@rcsonline.com>
Re: possible wierd boolean bug? Tom Lane <tgl@sss.pgh.pa.us>
"Merlin Moncure" writes:
> I confirmed the problem on a linux server running beta3...so this
> problem is quite reproducible by running the attached scripts on a
> freshly loaded database.
The attached patch fixes the problem for me.
regards, tom lane
*** src/backend/access/nbtree/nbtutils.c.orig Sun Aug 29 01:06:40 2004
--- src/backend/access/nbtree/nbtutils.c Wed Dec 15 14:00:59 2004
***************
*** 224,234 **** BTScanOpaque so = (BTScanOpaque) scan->opaque; int numberOfKeys = scan->numberOfKeys; int new_numberOfKeys; ScanKey inkeys; ScanKey outkeys; ScanKey cur; ScanKey xform[BTMaxStrategyNumber];
- bool allEqualSoFar; bool hasOtherTypeEqual; Datum test; int i,
--- 224,234 ---- BTScanOpaque so = (BTScanOpaque) scan->opaque; int numberOfKeys = scan->numberOfKeys; int new_numberOfKeys;
+ int numberOfEqualCols; ScanKey inkeys; ScanKey outkeys; ScanKey cur; ScanKey xform[BTMaxStrategyNumber]; bool hasOtherTypeEqual; Datum test; int i,
***************
*** 278,284 **** * Otherwise, do the full set of pushups. */ new_numberOfKeys = 0;
! allEqualSoFar = true; /* * Initialize for processing of keys for attr 1.
--- 278,284 ---- * Otherwise, do the full set of pushups. */ new_numberOfKeys = 0;
! numberOfEqualCols = 0; /* * Initialize for processing of keys for attr 1.
***************
*** 321,327 **** */ if (i == numberOfKeys || cur->sk_attno != attno) {
! bool priorAllEqualSoFar = allEqualSoFar; /* check input keys are correctly ordered */ if (i < numberOfKeys && cur->sk_attno != attno + 1)
--- 321,327 ---- */ if (i == numberOfKeys || cur->sk_attno != attno) {
! int priorNumberOfEqualCols = numberOfEqualCols; /* check input keys are correctly ordered */ if (i < numberOfKeys && cur->sk_attno != attno + 1)
***************
*** 355,368 **** xform[BTLessEqualStrategyNumber - 1] = NULL; xform[BTGreaterEqualStrategyNumber - 1] = NULL; xform[BTGreaterStrategyNumber - 1] = NULL; } else {
! /*
! * If no "=" for this key, we're done with required keys
! */
! if (!hasOtherTypeEqual)
! allEqualSoFar = false; } /* keep only one of <, <= */
--- 355,368 ---- xform[BTLessEqualStrategyNumber - 1] = NULL; xform[BTGreaterEqualStrategyNumber - 1] = NULL; xform[BTGreaterStrategyNumber - 1] = NULL;
+ /* track number of attrs for which we have "=" keys */
+ numberOfEqualCols++; } else {
! /* track number of attrs for which we have "=" keys */
! if (hasOtherTypeEqual)
! numberOfEqualCols++; } /* keep only one of <, <= */
***************
*** 411,417 **** * If all attrs before this one had "=", include these keys * into the required-keys count. */
! if (priorAllEqualSoFar) so->numberOfRequiredKeys = new_numberOfKeys; /*
--- 411,417 ---- * If all attrs before this one had "=", include these keys * into the required-keys count. */
! if (priorNumberOfEqualCols == attno - 1) so->numberOfRequiredKeys = new_numberOfKeys; /*
***************
*** 468,475 **** * If unique index and we have equality keys for all columns, set * keys_are_unique flag for higher levels. */
! if (allEqualSoFar && relation->rd_index->indisunique &&
! relation->rd_rel->relnatts == new_numberOfKeys) scan->keys_are_unique = true; }
--- 468,475 ---- * If unique index and we have equality keys for all columns, set * keys_are_unique flag for higher levels. */
! if (relation->rd_index->indisunique &&
! relation->rd_rel->relnatts == numberOfEqualCols) scan->keys_are_unique = true; }
В списке pgsql-hackers по дате отправления
От: Matthias Schmidt
Дата: