mirror of
https://github.com/postgres/postgres.git
synced 2025-04-21 12:05:57 +03:00
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.
This commit is contained in:
parent
7930e627d8
commit
f7ea931287
@ -4,7 +4,7 @@
|
|||||||
# Makefile for access/common
|
# Makefile for access/common
|
||||||
#
|
#
|
||||||
# IDENTIFICATION
|
# IDENTIFICATION
|
||||||
# $PostgreSQL: pgsql/src/backend/access/common/Makefile,v 1.20 2003/11/29 19:51:39 pgsql Exp $
|
# $PostgreSQL: pgsql/src/backend/access/common/Makefile,v 1.21 2006/01/14 22:03:35 tgl Exp $
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -12,8 +12,7 @@ subdir = src/backend/access/common
|
|||||||
top_builddir = ../../../..
|
top_builddir = ../../../..
|
||||||
include $(top_builddir)/src/Makefile.global
|
include $(top_builddir)/src/Makefile.global
|
||||||
|
|
||||||
OBJS = heaptuple.o indextuple.o indexvalid.o printtup.o \
|
OBJS = heaptuple.o indextuple.o printtup.o scankey.o tupdesc.o
|
||||||
scankey.o tupdesc.o
|
|
||||||
|
|
||||||
all: SUBSYS.o
|
all: SUBSYS.o
|
||||||
|
|
||||||
|
@ -1,78 +0,0 @@
|
|||||||
/*-------------------------------------------------------------------------
|
|
||||||
*
|
|
||||||
* indexvalid.c
|
|
||||||
* index tuple qualification validity checking code
|
|
||||||
*
|
|
||||||
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* IDENTIFICATION
|
|
||||||
* $PostgreSQL: pgsql/src/backend/access/common/indexvalid.c,v 1.34 2005/06/24 00:18:52 tgl Exp $
|
|
||||||
*
|
|
||||||
*-------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "postgres.h"
|
|
||||||
|
|
||||||
#include "access/iqual.h"
|
|
||||||
#include "executor/execdebug.h"
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------
|
|
||||||
* index scan key qualification code
|
|
||||||
* ----------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
int NIndexTupleProcessed;
|
|
||||||
|
|
||||||
|
|
||||||
/* ----------------
|
|
||||||
* index_keytest - does this index tuple satisfy the scan key(s)?
|
|
||||||
* ----------------
|
|
||||||
*/
|
|
||||||
bool
|
|
||||||
index_keytest(IndexTuple tuple,
|
|
||||||
TupleDesc tupdesc,
|
|
||||||
int scanKeySize,
|
|
||||||
ScanKey key)
|
|
||||||
{
|
|
||||||
IncrIndexProcessed();
|
|
||||||
|
|
||||||
while (scanKeySize > 0)
|
|
||||||
{
|
|
||||||
Datum datum;
|
|
||||||
bool isNull;
|
|
||||||
Datum test;
|
|
||||||
|
|
||||||
datum = index_getattr(tuple,
|
|
||||||
key->sk_attno,
|
|
||||||
tupdesc,
|
|
||||||
&isNull);
|
|
||||||
|
|
||||||
if (isNull)
|
|
||||||
{
|
|
||||||
/* XXX eventually should check if SK_ISNULL */
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (key->sk_flags & SK_ISNULL)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
test = FunctionCall2(&key->sk_func, datum, key->sk_argument);
|
|
||||||
|
|
||||||
if (key->sk_flags & SK_NEGATE)
|
|
||||||
{
|
|
||||||
if (DatumGetBool(test))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!DatumGetBool(test))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
key++;
|
|
||||||
scanKeySize--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
@ -8,7 +8,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.54 2005/11/22 18:17:05 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.55 2006/01/14 22:03:35 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -332,13 +332,15 @@ gistnext(IndexScanDesc scan, ScanDirection dir, ItemPointer tids, int maxtids, b
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Similar to index_keytest, but first decompress the key in the
|
* gistindex_keytest() -- does this index tuple satisfy the scan key(s)?
|
||||||
* IndexTuple before passing it to the sk_func (and we have previously
|
*
|
||||||
* overwritten the sk_func to use the user-defined Consistent method,
|
* We must decompress the key in the IndexTuple before passing it to the
|
||||||
* so we actually invoke that). Note that this function is always
|
* sk_func (and we have previously overwritten the sk_func to use the
|
||||||
* invoked in a short-lived memory context, so we don't need to worry
|
* user-defined Consistent method, so we actually are invoking that).
|
||||||
* about cleaning up allocated memory (either here or in the
|
*
|
||||||
* implementation of any Consistent methods).
|
* Note that this function is always invoked in a short-lived memory context,
|
||||||
|
* so we don't need to worry about cleaning up allocated memory, either here
|
||||||
|
* or in the implementation of any Consistent methods.
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
gistindex_keytest(IndexTuple tuple,
|
gistindex_keytest(IndexTuple tuple,
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/access/hash/hashutil.c,v 1.44 2005/11/22 18:17:05 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/access/hash/hashutil.c,v 1.45 2006/01/14 22:03:35 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
#include "access/genam.h"
|
#include "access/genam.h"
|
||||||
#include "access/hash.h"
|
#include "access/hash.h"
|
||||||
#include "access/iqual.h"
|
#include "executor/execdebug.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -25,8 +25,39 @@
|
|||||||
bool
|
bool
|
||||||
_hash_checkqual(IndexScanDesc scan, IndexTuple itup)
|
_hash_checkqual(IndexScanDesc scan, IndexTuple itup)
|
||||||
{
|
{
|
||||||
return index_keytest(itup, RelationGetDescr(scan->indexRelation),
|
TupleDesc tupdesc = RelationGetDescr(scan->indexRelation);
|
||||||
scan->numberOfKeys, scan->keyData);
|
ScanKey key = scan->keyData;
|
||||||
|
int scanKeySize = scan->numberOfKeys;
|
||||||
|
|
||||||
|
IncrIndexProcessed();
|
||||||
|
|
||||||
|
while (scanKeySize > 0)
|
||||||
|
{
|
||||||
|
Datum datum;
|
||||||
|
bool isNull;
|
||||||
|
Datum test;
|
||||||
|
|
||||||
|
datum = index_getattr(itup,
|
||||||
|
key->sk_attno,
|
||||||
|
tupdesc,
|
||||||
|
&isNull);
|
||||||
|
|
||||||
|
/* assume sk_func is strict */
|
||||||
|
if (isNull)
|
||||||
|
return false;
|
||||||
|
if (key->sk_flags & SK_ISNULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
test = FunctionCall2(&key->sk_func, datum, key->sk_argument);
|
||||||
|
|
||||||
|
if (!DatumGetBool(test))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
key++;
|
||||||
|
scanKeySize--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/executor/execUtils.c,v 1.131 2005/12/03 05:51:01 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/executor/execUtils.c,v 1.132 2006/01/14 22:03:35 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -67,9 +67,7 @@ int NTupleReplaced;
|
|||||||
int NTupleAppended;
|
int NTupleAppended;
|
||||||
int NTupleDeleted;
|
int NTupleDeleted;
|
||||||
int NIndexTupleInserted;
|
int NIndexTupleInserted;
|
||||||
extern int NIndexTupleProcessed; /* have to be defined in the access
|
int NIndexTupleProcessed;
|
||||||
* method level so that the
|
|
||||||
* cinterface.a will link ok. */
|
|
||||||
|
|
||||||
|
|
||||||
static void ShutdownExprContext(ExprContext *econtext);
|
static void ShutdownExprContext(ExprContext *econtext);
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
/*-------------------------------------------------------------------------
|
|
||||||
*
|
|
||||||
* iqual.h
|
|
||||||
* Index scan key qualification definitions.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
|
||||||
*
|
|
||||||
* $PostgreSQL: pgsql/src/include/access/iqual.h,v 1.23 2004/12/31 22:03:21 pgsql Exp $
|
|
||||||
*
|
|
||||||
*-------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
#ifndef IQUAL_H
|
|
||||||
#define IQUAL_H
|
|
||||||
|
|
||||||
#include "access/itup.h"
|
|
||||||
#include "access/skey.h"
|
|
||||||
|
|
||||||
|
|
||||||
/* ----------------
|
|
||||||
* index tuple qualification support
|
|
||||||
* ----------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
extern int NIndexTupleProcessed;
|
|
||||||
|
|
||||||
extern bool index_keytest(IndexTuple tuple, TupleDesc tupdesc,
|
|
||||||
int scanKeySize, ScanKey key);
|
|
||||||
|
|
||||||
#endif /* IQUAL_H */
|
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/access/skey.h,v 1.29 2005/06/24 00:18:52 tgl Exp $
|
* $PostgreSQL: pgsql/src/include/access/skey.h,v 1.30 2006/01/14 22:03:35 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -69,10 +69,15 @@ typedef struct ScanKeyData
|
|||||||
|
|
||||||
typedef ScanKeyData *ScanKey;
|
typedef ScanKeyData *ScanKey;
|
||||||
|
|
||||||
/* ScanKeyData sk_flags */
|
/*
|
||||||
|
* ScanKeyData sk_flags
|
||||||
|
*
|
||||||
|
* sk_flags bits 0-15 are reserved for system-wide use (symbols for those
|
||||||
|
* bits should be defined here). Bits 16-31 are reserved for use within
|
||||||
|
* individual index access methods.
|
||||||
|
*/
|
||||||
#define SK_ISNULL 0x0001 /* sk_argument is NULL */
|
#define SK_ISNULL 0x0001 /* sk_argument is NULL */
|
||||||
#define SK_UNARY 0x0002 /* unary operator (currently unsupported) */
|
#define SK_UNARY 0x0002 /* unary operator (currently unsupported) */
|
||||||
#define SK_NEGATE 0x0004 /* must negate the function result */
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user