Re: possible wierd boolean bug? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: possible wierd boolean bug?
Date
Msg-id 5605.1103138330@sss.pgh.pa.us
Whole thread Raw
In response to Re: possible wierd boolean bug?  ("Merlin Moncure" <merlin.moncure@rcsonline.com>)
List pgsql-hackers
"Merlin Moncure" <merlin.moncure@rcsonline.com> 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-keyscount.              */
 
!             if (priorAllEqualSoFar)                 so->numberOfRequiredKeys = new_numberOfKeys;              /*
--- 411,417 ----              * If all attrs before this one had "=", include these keys              * into the
required-keyscount.              */
 
!             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
higherlevels.      */
 
!     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
higherlevels.      */
 
!     if (relation->rd_index->indisunique &&
!         relation->rd_rel->relnatts == numberOfEqualCols)         scan->keys_are_unique = true; } 


pgsql-hackers by date:

Previous
From: Josh Berkus
Date:
Subject: Re: [Testperf-general] BufferSync and bgwriter
Next
From: Matthias Schmidt
Date:
Subject: Re: somebody working on: Prevent default re-use of sysids for dropped users and groups?