Skip to content

Commit f7ea931

Browse files
committed
Some minor code cleanup, falling out from the removal of rtree. SK_NEGATE
isn't being used anywhere anymore, and there seems no point in a generic index_keytest() routine when two out of three remaining access methods aren't using it. Also, add a comment documenting a convention for letting access methods define private flag bits in ScanKey sk_flags. There are no such flags at the moment but I'm thinking about changing btree's handling of "required keys" to use flag bits in the keys rather than a count of required key positions. Also, if some AM did still want SK_NEGATE then it would be reasonable to treat it as a private flag bit.
1 parent 7930e62 commit f7ea931

File tree

7 files changed

+57
-131
lines changed

7 files changed

+57
-131
lines changed

src/backend/access/common/Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@
44
# Makefile for access/common
55
#
66
# IDENTIFICATION
7-
# $PostgreSQL: pgsql/src/backend/access/common/Makefile,v 1.20 2003/11/29 19:51:39 pgsql Exp $
7+
# $PostgreSQL: pgsql/src/backend/access/common/Makefile,v 1.21 2006/01/14 22:03:35 tgl Exp $
88
#
99
#-------------------------------------------------------------------------
1010

1111
subdir = src/backend/access/common
1212
top_builddir = ../../../..
1313
include $(top_builddir)/src/Makefile.global
1414

15-
OBJS = heaptuple.o indextuple.o indexvalid.o printtup.o \
16-
scankey.o tupdesc.o
15+
OBJS = heaptuple.o indextuple.o printtup.o scankey.o tupdesc.o
1716

1817
all: SUBSYS.o
1918

src/backend/access/common/indexvalid.c

Lines changed: 0 additions & 78 deletions
This file was deleted.

src/backend/access/gist/gistget.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.54 2005/11/22 18:17:05 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.55 2006/01/14 22:03:35 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -332,13 +332,15 @@ gistnext(IndexScanDesc scan, ScanDirection dir, ItemPointer tids, int maxtids, b
332332
}
333333

334334
/*
335-
* Similar to index_keytest, but first decompress the key in the
336-
* IndexTuple before passing it to the sk_func (and we have previously
337-
* overwritten the sk_func to use the user-defined Consistent method,
338-
* so we actually invoke that). Note that this function is always
339-
* invoked in a short-lived memory context, so we don't need to worry
340-
* about cleaning up allocated memory (either here or in the
341-
* implementation of any Consistent methods).
335+
* gistindex_keytest() -- does this index tuple satisfy the scan key(s)?
336+
*
337+
* We must decompress the key in the IndexTuple before passing it to the
338+
* sk_func (and we have previously overwritten the sk_func to use the
339+
* user-defined Consistent method, so we actually are invoking that).
340+
*
341+
* Note that this function is always invoked in a short-lived memory context,
342+
* so we don't need to worry about cleaning up allocated memory, either here
343+
* or in the implementation of any Consistent methods.
342344
*/
343345
static bool
344346
gistindex_keytest(IndexTuple tuple,

src/backend/access/hash/hashutil.c

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/hash/hashutil.c,v 1.44 2005/11/22 18:17:05 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/hash/hashutil.c,v 1.45 2006/01/14 22:03:35 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
1515
#include "postgres.h"
1616

1717
#include "access/genam.h"
1818
#include "access/hash.h"
19-
#include "access/iqual.h"
19+
#include "executor/execdebug.h"
2020

2121

2222
/*
@@ -25,8 +25,39 @@
2525
bool
2626
_hash_checkqual(IndexScanDesc scan, IndexTuple itup)
2727
{
28-
return index_keytest(itup, RelationGetDescr(scan->indexRelation),
29-
scan->numberOfKeys, scan->keyData);
28+
TupleDesc tupdesc = RelationGetDescr(scan->indexRelation);
29+
ScanKey key = scan->keyData;
30+
int scanKeySize = scan->numberOfKeys;
31+
32+
IncrIndexProcessed();
33+
34+
while (scanKeySize > 0)
35+
{
36+
Datum datum;
37+
bool isNull;
38+
Datum test;
39+
40+
datum = index_getattr(itup,
41+
key->sk_attno,
42+
tupdesc,
43+
&isNull);
44+
45+
/* assume sk_func is strict */
46+
if (isNull)
47+
return false;
48+
if (key->sk_flags & SK_ISNULL)
49+
return false;
50+
51+
test = FunctionCall2(&key->sk_func, datum, key->sk_argument);
52+
53+
if (!DatumGetBool(test))
54+
return false;
55+
56+
key++;
57+
scanKeySize--;
58+
}
59+
60+
return true;
3061
}
3162

3263
/*

src/backend/executor/execUtils.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/executor/execUtils.c,v 1.131 2005/12/03 05:51:01 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/executor/execUtils.c,v 1.132 2006/01/14 22:03:35 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -67,9 +67,7 @@ int NTupleReplaced;
6767
int NTupleAppended;
6868
int NTupleDeleted;
6969
int NIndexTupleInserted;
70-
extern int NIndexTupleProcessed; /* have to be defined in the access
71-
* method level so that the
72-
* cinterface.a will link ok. */
70+
int NIndexTupleProcessed;
7371

7472

7573
static void ShutdownExprContext(ExprContext *econtext);

src/include/access/iqual.h

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/include/access/skey.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/access/skey.h,v 1.29 2005/06/24 00:18:52 tgl Exp $
10+
* $PostgreSQL: pgsql/src/include/access/skey.h,v 1.30 2006/01/14 22:03:35 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -69,10 +69,15 @@ typedef struct ScanKeyData
6969

7070
typedef ScanKeyData *ScanKey;
7171

72-
/* ScanKeyData sk_flags */
72+
/*
73+
* ScanKeyData sk_flags
74+
*
75+
* sk_flags bits 0-15 are reserved for system-wide use (symbols for those
76+
* bits should be defined here). Bits 16-31 are reserved for use within
77+
* individual index access methods.
78+
*/
7379
#define SK_ISNULL 0x0001 /* sk_argument is NULL */
7480
#define SK_UNARY 0x0002 /* unary operator (currently unsupported) */
75-
#define SK_NEGATE 0x0004 /* must negate the function result */
7681

7782

7883
/*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy