* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/gin/ginget.c,v 1.27 2009/06/11 14:48:53 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/access/gin/ginget.c,v 1.28 2009/11/13 11:17:04 teodor Exp $
*-------------------------------------------------------------------------
*/
typedef struct pendingPosition
{
- Buffer pendingBuffer;
- OffsetNumber firstOffset;
- OffsetNumber lastOffset;
- ItemPointerData item;
+ Buffer pendingBuffer;
+ OffsetNumber firstOffset;
+ OffsetNumber lastOffset;
+ ItemPointerData item;
+ bool *hasMatchKey;
} pendingPosition;
return false;
}
+static bool
+hasAllMatchingKeys(GinScanOpaque so, pendingPosition *pos)
+{
+ int i;
+
+ for (i = 0; i < so->nkeys; i++)
+ if (pos->hasMatchKey[i] == false)
+ return false;
+
+ return true;
+}
+
/*
* Sets entryRes array for each key by looking at
* every entry per indexed value (heap's row) in pending list.
IndexTuple itup;
int i,
j;
- bool hasMatch = false;
/*
* Resets entryRes
memset(key->entryRes, FALSE, key->nentries);
}
+ memset(pos->hasMatchKey, FALSE, so->nkeys);
for (;;)
{
entry->extra_data);
}
- hasMatch |= key->entryRes[j];
+ pos->hasMatchKey[i] |= key->entryRes[j];
}
}
* We scan all values from one tuple, go to next one
*/
- return hasMatch;
+ return hasAllMatchingKeys(so, pos);
}
else
{
}
}
- return hasMatch;
+ return hasAllMatchingKeys(so, pos);
}
/*
LockBuffer(pos.pendingBuffer, GIN_SHARE);
pos.firstOffset = FirstOffsetNumber;
UnlockReleaseBuffer(metabuffer);
+ pos.hasMatchKey = palloc(sizeof(bool) * so->nkeys);
/*
* loop for each heap row. scanGetCandidate returns full row or row's
(*ntids)++;
}
}
+
+ pfree(pos.hasMatchKey);
}
/*