Commit fa5c8a05 authored by Tom Lane's avatar Tom Lane

Cross-data-type comparisons are now indexable by btrees, pursuant to my

pghackers proposal of 8-Nov.  All the existing cross-type comparison
operators (int2/int4/int8 and float4/float8) have appropriate support.
The original proposal of storing the right-hand-side datatype as part of
the primary key for pg_amop and pg_amproc got modified a bit in the event;
it is easier to store zero as the 'default' case and only store a nonzero
when the operator is actually cross-type.  Along the way, remove the
long-since-defunct bigbox_ops operator class.
parent 49f98fa8
......@@ -1357,10 +1357,10 @@ get_pkey_attnames(Oid relid, int16 *numatts)
/* use relid to get all related indexes */
indexRelation = heap_openr(IndexRelationName, AccessShareLock);
ScanKeyEntryInitialize(&entry, 0,
Anum_pg_index_indrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(relid), OIDOID);
ScanKeyInit(&entry,
Anum_pg_index_indrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(relid));
scan = heap_beginscan(indexRelation, SnapshotNow, 1, &entry);
while ((indexTuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
......
......@@ -21,7 +21,6 @@
#include "access/tupdesc.h"
#include "catalog/catname.h"
#include "catalog/pg_listener.h"
#include "catalog/pg_type.h"
#include "commands/async.h"
#include "fmgr.h"
#include "storage/lmgr.h"
......@@ -87,10 +86,10 @@ active_listeners(text *relname)
MemSet(listen_name, 0, NAMEDATALEN);
len = MIN(VARSIZE(relname) - VARHDRSZ, NAMEDATALEN - 1);
memcpy(listen_name, VARDATA(relname), len);
ScanKeyEntryInitialize(&key, 0,
Anum_pg_listener_relname,
BTEqualStrategyNumber, F_NAMEEQ,
PointerGetDatum(listen_name), NAMEOID);
ScanKeyInit(&key,
Anum_pg_listener_relname,
BTEqualStrategyNumber, F_NAMEEQ,
PointerGetDatum(listen_name));
sRel = heap_beginscan(lRel, SnapshotNow, 1, &key);
}
else
......
<!--
Documentation of the system catalogs, directed toward PostgreSQL developers
$Header: /cvsroot/pgsql/doc/src/sgml/catalogs.sgml,v 2.78 2003/11/02 12:53:57 petere Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/catalogs.sgml,v 2.79 2003/11/12 21:15:42 tgl Exp $
-->
<chapter id="catalogs">
......@@ -499,6 +499,14 @@
<entry>The index operator class this entry is for</entry>
</row>
<row>
<entry><structfield>amopsubtype</structfield></entry>
<entry><type>oid</type></entry>
<entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
<entry>Subtype to distinguish multiple entries for one strategy;
zero for default</entry>
</row>
<row>
<entry><structfield>amopstrategy</structfield></entry>
<entry><type>int2</type></entry>
......@@ -562,6 +570,13 @@
<entry>The index operator class this entry is for</entry>
</row>
<row>
<entry><structfield>amprocsubtype</structfield></entry>
<entry><type>oid</type></entry>
<entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
<entry>Subtype, if cross-type routine, else zero</entry>
</row>
<row>
<entry><structfield>amprocnum</structfield></entry>
<entry><type>int2</type></entry>
......@@ -2435,7 +2450,7 @@
<entry><structfield>opcintype</structfield></entry>
<entry><type>oid</type></entry>
<entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
<entry>Input data type of the operator class</entry>
<entry>Data type that the operator class indexes</entry>
</row>
<row>
......@@ -2449,7 +2464,7 @@
<entry><structfield>opckeytype</structfield></entry>
<entry><type>oid</type></entry>
<entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
<entry>Type of index data, or zero if same as <structfield>opcintype</></entry>
<entry>Type of data stored in index, or zero if same as <structfield>opcintype</></entry>
</row>
</tbody>
......
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/xindex.sgml,v 1.34 2003/11/01 01:56:29 petere Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/xindex.sgml,v 1.35 2003/11/12 21:15:45 tgl Exp $
-->
<sect1 id="xindex">
......@@ -80,7 +80,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/xindex.sgml,v 1.34 2003/11/01 01:56:29 pete
The same operator class name
can be used for several different index methods (for example, both B-tree
and hash index methods have operator classes named
<literal>oid_ops</literal>), but each such class is an independent
<literal>int4_ops</literal>), but each such class is an independent
entity and must be defined separately.
</para>
</sect2>
......@@ -589,6 +589,71 @@ CREATE OPERATOR CLASS complex_abs_ops
</para>
</sect2>
<sect2 id="xindex-opclass-crosstype">
<title>Cross-Data-Type Operator Classes</title>
<para>
So far we have implicitly assumed that an operator class deals with
only one data type. While there certainly can be only one data type in
a particular index column, it is often useful to index operations that
compare an indexed column to a value of a different data type. This is
presently supported by the B-tree and GiST index methods.
</para>
<para>
B-trees require the left-hand operand of each operator to be the indexed
data type, but the right-hand operand can be of a different type. There
must be a support function having a matching signature. For example,
the built-in operator class for type <type>bigint</> (<type>int8</>)
allows cross-type comparisons to <type>int4</> and <type>int2</>. It
could be duplicated by this definition:
<programlisting>
CREATE OPERATOR CLASS int8_ops
DEFAULT FOR TYPE int8 USING btree AS
-- standard int8 comparisons
OPERATOR 1 &lt; ,
OPERATOR 2 &lt;= ,
OPERATOR 3 = ,
OPERATOR 4 &gt;= ,
OPERATOR 5 &gt; ,
FUNCTION 1 btint8cmp(int8, int8) ,
-- cross-type comparisons to int2 (smallint)
OPERATOR 1 &lt; (int8, int2) ,
OPERATOR 2 &lt;= (int8, int2) ,
OPERATOR 3 = (int8, int2) ,
OPERATOR 4 &gt;= (int8, int2) ,
OPERATOR 5 &gt; (int8, int2) ,
FUNCTION 1 btint82cmp(int8, int2) ,
-- cross-type comparisons to int4 (integer)
OPERATOR 1 &lt; (int8, int4) ,
OPERATOR 2 &lt;= (int8, int4) ,
OPERATOR 3 = (int8, int4) ,
OPERATOR 4 &gt;= (int8, int4) ,
OPERATOR 5 &gt; (int8, int4) ,
FUNCTION 1 btint84cmp(int8, int4) ;
</programlisting>
Notice that this definition <quote>overloads</> the operator strategy and
support function numbers. This is allowed (for B-tree operator classes
only) so long as each instance of a particular number has a different
right-hand data type. The instances that are not cross-type are the
default or primary operators of the operator class.
</para>
<para>
GiST indexes do not allow overloading of strategy or support function
numbers, but it is still possible to get the effect of supporting
multiple right-hand data types, by assigning a distinct strategy number
to each operator that needs to be supported. The <literal>consistent</>
support function must determine what it needs to do based on the strategy
number, and must be prepared to accept comparison values of the appropriate
data types.
</para>
</sect2>
<sect2 id="xindex-opclass-dependencies">
<title>System Dependencies on Operator Classes</title>
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/scankey.c,v 1.23 2003/11/09 21:30:35 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/common/scankey.c,v 1.24 2003/11/12 21:15:46 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -31,15 +31,43 @@ ScanKeyEntryInitialize(ScanKey entry,
int flags,
AttrNumber attributeNumber,
StrategyNumber strategy,
Oid subtype,
RegProcedure procedure,
Datum argument,
Oid argtype)
Datum argument)
{
entry->sk_flags = flags;
entry->sk_attno = attributeNumber;
entry->sk_strategy = strategy;
entry->sk_subtype = subtype;
entry->sk_argument = argument;
fmgr_info(procedure, &entry->sk_func);
}
/*
* ScanKeyInit
* Shorthand version of ScanKeyEntryInitialize: flags and subtype
* are assumed to be zero (the usual value).
*
* This is the recommended version for hardwired lookups in system catalogs.
* It cannot handle NULL arguments, unary operators, or nondefault operators,
* but we need none of those features for most hardwired lookups.
*
* Note: CurrentMemoryContext at call should be as long-lived as the ScanKey
* itself, because that's what will be used for any subsidiary info attached
* to the ScanKey's FmgrInfo record.
*/
void
ScanKeyInit(ScanKey entry,
AttrNumber attributeNumber,
StrategyNumber strategy,
RegProcedure procedure,
Datum argument)
{
entry->sk_flags = 0;
entry->sk_attno = attributeNumber;
entry->sk_strategy = strategy;
entry->sk_subtype = InvalidOid;
entry->sk_argument = argument;
entry->sk_argtype = argtype;
fmgr_info(procedure, &entry->sk_func);
}
......@@ -57,14 +85,14 @@ ScanKeyEntryInitializeWithInfo(ScanKey entry,
int flags,
AttrNumber attributeNumber,
StrategyNumber strategy,
Oid subtype,
FmgrInfo *finfo,
Datum argument,
Oid argtype)
Datum argument)
{
entry->sk_flags = flags;
entry->sk_attno = attributeNumber;
entry->sk_strategy = strategy;
entry->sk_subtype = subtype;
entry->sk_argument = argument;
entry->sk_argtype = argtype;
fmgr_info_copy(&entry->sk_func, finfo, CurrentMemoryContext);
}
......@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/gist/gistget.c,v 1.37 2003/11/09 21:30:35 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/gist/gistget.c,v 1.38 2003/11/12 21:15:46 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -221,40 +221,50 @@ gistindex_keytest(IndexTuple tuple,
Page p,
OffsetNumber offset)
{
bool isNull;
Datum datum;
Datum test;
GISTENTRY de;
IncrIndexProcessed();
while (scanKeySize > 0)
{
Datum datum;
bool isNull;
Datum test;
GISTENTRY de;
datum = index_getattr(tuple,
key[0].sk_attno,
key->sk_attno,
giststate->tupdesc,
&isNull);
/* is the index entry NULL? */
if (isNull)
{
/* XXX eventually should check if SK_ISNULL */
return false;
}
/* this code from backend/access/common/indexvalid.c. But why and what???
if (key[0].sk_flags & SK_ISNULL)
/* is the compared-to datum NULL? */
if (key->sk_flags & SK_ISNULL)
return false;
*/
gistdentryinit(giststate, key[0].sk_attno - 1, &de,
gistdentryinit(giststate, key->sk_attno - 1, &de,
datum, r, p, offset,
IndexTupleSize(tuple) - sizeof(IndexTupleData),
FALSE, isNull);
test = FunctionCall3(&key[0].sk_func,
/*
* Call the Consistent function to evaluate the test. The arguments
* are the index datum (as a GISTENTRY*), the comparison datum, and
* the comparison operator's strategy number and subtype from pg_amop.
*
* (Presently there's no need to pass the subtype since it'll always
* be zero, but might as well pass it for possible future use.)
*/
test = FunctionCall4(&key->sk_func,
PointerGetDatum(&de),
key[0].sk_argument,
Int32GetDatum(key[0].sk_strategy));
key->sk_argument,
Int32GetDatum(key->sk_strategy),
ObjectIdGetDatum(key->sk_subtype));
if (de.key != datum && !isAttByVal(giststate, key[0].sk_attno - 1))
/* if index datum had to be decompressed, free it */
if (de.key != datum && !isAttByVal(giststate, key->sk_attno - 1))
if (DatumGetPointer(de.key) != NULL)
pfree(DatumGetPointer(de.key));
......@@ -264,6 +274,7 @@ gistindex_keytest(IndexTuple tuple,
scanKeySize--;
key++;
}
return true;
}
......
......@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/gist/gistscan.c,v 1.48 2003/11/09 21:30:35 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/gist/gistscan.c,v 1.49 2003/11/12 21:15:46 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -109,7 +109,8 @@ gistrescan(PG_FUNCTION_ARGS)
* Modify the scan key so that the Consistent function is called
* for all comparisons. The original operator is passed to the
* Consistent function in the form of its strategy number, which
* is available from the sk_strategy field.
* is available from the sk_strategy field, and its subtype from
* the sk_subtype field.
*/
for (i = 0; i < s->numberOfKeys; i++)
{
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.39 2003/11/09 21:30:35 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.40 2003/11/12 21:15:46 tgl Exp $
*
*
* INTERFACE ROUTINES
......@@ -31,7 +31,6 @@
#include "access/genam.h"
#include "access/tuptoaster.h"
#include "catalog/catalog.h"
#include "catalog/pg_type.h"
#include "utils/rel.h"
#include "utils/builtins.h"
#include "utils/fmgroids.h"
......@@ -968,11 +967,10 @@ toast_delete_datum(Relation rel, Datum value)
* Setup a scan key to fetch from the index by va_valueid (we don't
* particularly care whether we see them in sequence or not)
*/
ScanKeyEntryInitialize(&toastkey, 0,
(AttrNumber) 1,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(attr->va_content.va_external.va_valueid),
OIDOID);
ScanKeyInit(&toastkey,
(AttrNumber) 1,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(attr->va_content.va_external.va_valueid));
/*
* Find the chunks by index
......@@ -1040,11 +1038,10 @@ toast_fetch_datum(varattrib *attr)
/*
* Setup a scan key to fetch from the index by va_valueid
*/
ScanKeyEntryInitialize(&toastkey, 0,
(AttrNumber) 1,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(attr->va_content.va_external.va_valueid),
OIDOID);
ScanKeyInit(&toastkey,
(AttrNumber) 1,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(attr->va_content.va_external.va_valueid));
/*
* Read the chunks by index
......@@ -1195,33 +1192,32 @@ toast_fetch_datum_slice(varattrib *attr, int32 sliceoffset, int32 length)
* Setup a scan key to fetch from the index. This is either two keys
* or three depending on the number of chunks.
*/
ScanKeyEntryInitialize(&toastkey[0], 0,
(AttrNumber) 1,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(attr->va_content.va_external.va_valueid),
OIDOID);
ScanKeyInit(&toastkey[0],
(AttrNumber) 1,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(attr->va_content.va_external.va_valueid));
/*
* Use equality condition for one chunk, a range condition otherwise:
*/
if (numchunks == 1)
{
ScanKeyEntryInitialize(&toastkey[1], 0,
(AttrNumber) 2,
BTEqualStrategyNumber, F_INT4EQ,
Int32GetDatum(startchunk), INT4OID);
ScanKeyInit(&toastkey[1],
(AttrNumber) 2,
BTEqualStrategyNumber, F_INT4EQ,
Int32GetDatum(startchunk));
nscankeys = 2;
}
else
{
ScanKeyEntryInitialize(&toastkey[1], 0,
(AttrNumber) 2,
BTGreaterEqualStrategyNumber, F_INT4GE,
Int32GetDatum(startchunk), INT4OID);
ScanKeyEntryInitialize(&toastkey[2], 0,
(AttrNumber) 2,
BTLessEqualStrategyNumber, F_INT4LE,
Int32GetDatum(endchunk), INT4OID);
ScanKeyInit(&toastkey[1],
(AttrNumber) 2,
BTGreaterEqualStrategyNumber, F_INT4GE,
Int32GetDatum(startchunk));
ScanKeyInit(&toastkey[2],
(AttrNumber) 2,
BTLessEqualStrategyNumber, F_INT4LE,
Int32GetDatum(endchunk));
nscankeys = 3;
}
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.46 2003/08/04 02:39:57 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.47 2003/11/12 21:15:46 tgl Exp $
*
* NOTES
*
......@@ -97,6 +97,90 @@ btint8cmp(PG_FUNCTION_ARGS)
PG_RETURN_INT32(-1);
}
Datum
btint48cmp(PG_FUNCTION_ARGS)
{
int32 a = PG_GETARG_INT32(0);
int64 b = PG_GETARG_INT64(1);
if (a > b)
PG_RETURN_INT32(1);
else if (a == b)
PG_RETURN_INT32(0);
else
PG_RETURN_INT32(-1);
}
Datum
btint84cmp(PG_FUNCTION_ARGS)
{
int64 a = PG_GETARG_INT64(0);
int32 b = PG_GETARG_INT32(1);
if (a > b)
PG_RETURN_INT32(1);
else if (a == b)
PG_RETURN_INT32(0);
else
PG_RETURN_INT32(-1);
}
Datum
btint24cmp(PG_FUNCTION_ARGS)
{
int16 a = PG_GETARG_INT16(0);
int32 b = PG_GETARG_INT32(1);
if (a > b)
PG_RETURN_INT32(1);
else if (a == b)
PG_RETURN_INT32(0);
else
PG_RETURN_INT32(-1);
}
Datum
btint42cmp(PG_FUNCTION_ARGS)
{
int32 a = PG_GETARG_INT32(0);
int16 b = PG_GETARG_INT16(1);
if (a > b)
PG_RETURN_INT32(1);
else if (a == b)
PG_RETURN_INT32(0);
else
PG_RETURN_INT32(-1);
}
Datum
btint28cmp(PG_FUNCTION_ARGS)
{
int16 a = PG_GETARG_INT16(0);
int64 b = PG_GETARG_INT64(1);
if (a > b)
PG_RETURN_INT32(1);
else if (a == b)
PG_RETURN_INT32(0);
else
PG_RETURN_INT32(-1);
}
Datum
btint82cmp(PG_FUNCTION_ARGS)
{
int64 a = PG_GETARG_INT64(0);
int16 b = PG_GETARG_INT16(1);
if (a > b)
PG_RETURN_INT32(1);
else if (a == b)
PG_RETURN_INT32(0);
else
PG_RETURN_INT32(-1);
}
Datum
btoidcmp(PG_FUNCTION_ARGS)
{
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.107 2003/11/09 21:30:35 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.108 2003/11/12 21:15:46 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -1577,26 +1577,27 @@ _bt_isequal(TupleDesc itupdesc, Page page, OffsetNumber offnum,
for (i = 1; i <= keysz; i++)
{
ScanKey entry = &scankey[i - 1];
AttrNumber attno;
Datum datum;
bool isNull;
int32 result;
attno = entry->sk_attno;
attno = scankey->sk_attno;
Assert(attno == i);
datum = index_getattr(itup, attno, itupdesc, &isNull);
/* NULLs are never equal to anything */
if ((entry->sk_flags & SK_ISNULL) || isNull)
if (isNull || (scankey->sk_flags & SK_ISNULL))
return false;
result = DatumGetInt32(FunctionCall2(&entry->sk_func,
entry->sk_argument,
datum));
result = DatumGetInt32(FunctionCall2(&scankey->sk_func,
datum,
scankey->sk_argument));
if (result != 0)
return false;
scankey++;
}
/* if we get here, the keys are equal */
......
......@@ -12,7 +12,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.106 2003/09/29 23:40:26 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.107 2003/11/12 21:15:46 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -397,7 +397,6 @@ btrescan(PG_FUNCTION_ARGS)
so->keyData = (ScanKey) palloc(scan->numberOfKeys * sizeof(ScanKeyData));
else
so->keyData = (ScanKey) NULL;
so->numberOfKeys = scan->numberOfKeys;
scan->opaque = so;
}
......@@ -423,38 +422,14 @@ btrescan(PG_FUNCTION_ARGS)
* _bt_first. - vadim 05/05/97
*/
if (scankey && scan->numberOfKeys > 0)
{
memmove(scan->keyData,
scankey,
scan->numberOfKeys * sizeof(ScanKeyData));
so->numberOfKeys = scan->numberOfKeys;
memmove(so->keyData,
scankey,
so->numberOfKeys * sizeof(ScanKeyData));
}
so->numberOfKeys = 0; /* until _bt_preprocess_keys sets it */
PG_RETURN_VOID();
}
void
btmovescan(IndexScanDesc scan, Datum v)
{
ItemPointer iptr;
BTScanOpaque so;
so = (BTScanOpaque) scan->opaque;
/* we aren't holding any read locks, but gotta drop the pin */
if (ItemPointerIsValid(iptr = &(scan->currentItemData)))
{
ReleaseBuffer(so->btso_curbuf);
so->btso_curbuf = InvalidBuffer;
ItemPointerSetInvalid(iptr);
}
so->keyData[0].sk_argument = v;
}
/*
* btendscan() -- close down a scan
*/
......
This diff is collapsed.
......@@ -36,7 +36,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsort.c,v 1.77 2003/09/29 23:40:26 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsort.c,v 1.78 2003/11/12 21:15:47 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -594,33 +594,37 @@ _bt_load(Relation index, BTSpool *btspool, BTSpool *btspool2)
* Another BTSpool for dead tuples exists. Now we have to merge
* btspool and btspool2.
*/
ScanKey entry;
Datum attrDatum1,
attrDatum2;
bool isFirstNull,
isSecondNull;
int32 compare;
/* the preparation of merge */
bti = (BTItem) tuplesort_getindextuple(btspool->sortstate, true, &should_free);
bti2 = (BTItem) tuplesort_getindextuple(btspool2->sortstate, true, &should_free2);
bti = (BTItem) tuplesort_getindextuple(btspool->sortstate,
true, &should_free);
bti2 = (BTItem) tuplesort_getindextuple(btspool2->sortstate,
true, &should_free2);
indexScanKey = _bt_mkscankey_nodata(index);
for (;;)
{
load1 = true; /* load BTSpool next ? */
if (NULL == bti2)
if (bti2 == NULL)
{
if (NULL == bti)
if (bti == NULL)
break;
}
else if (NULL != bti)
else if (bti != NULL)
{
for (i = 1; i <= keysz; i++)
{
ScanKey entry;
Datum attrDatum1,
attrDatum2;
bool isFirstNull,
isSecondNull;
entry = indexScanKey + i - 1;
attrDatum1 = index_getattr((IndexTuple) bti, i, tupdes, &isFirstNull);
attrDatum2 = index_getattr((IndexTuple) bti2, i, tupdes, &isSecondNull);
attrDatum1 = index_getattr((IndexTuple) bti, i, tupdes,
&isFirstNull);
attrDatum2 = index_getattr((IndexTuple) bti2, i, tupdes,
&isSecondNull);
if (isFirstNull)
{
if (!isSecondNull)
......@@ -633,7 +637,11 @@ _bt_load(Relation index, BTSpool *btspool, BTSpool *btspool2)
break;
else
{
compare = DatumGetInt32(FunctionCall2(&entry->sk_func, attrDatum1, attrDatum2));
int32 compare;
compare = DatumGetInt32(FunctionCall2(&entry->sk_func,
attrDatum1,
attrDatum2));
if (compare > 0)
{
load1 = false;
......@@ -656,14 +664,16 @@ _bt_load(Relation index, BTSpool *btspool, BTSpool *btspool2)
_bt_buildadd(index, state, bti);
if (should_free)
pfree((void *) bti);
bti = (BTItem) tuplesort_getindextuple(btspool->sortstate, true, &should_free);
bti = (BTItem) tuplesort_getindextuple(btspool->sortstate,
true, &should_free);
}
else
{
_bt_buildadd(index, state, bti2);
if (should_free2)
pfree((void *) bti2);
bti2 = (BTItem) tuplesort_getindextuple(btspool2->sortstate, true, &should_free2);
bti2 = (BTItem) tuplesort_getindextuple(btspool2->sortstate,
true, &should_free2);
}
}
_bt_freeskey(indexScanKey);
......@@ -671,7 +681,8 @@ _bt_load(Relation index, BTSpool *btspool, BTSpool *btspool2)
else
{
/* merge is unnecessary */
while (bti = (BTItem) tuplesort_getindextuple(btspool->sortstate, true, &should_free), bti != (BTItem) NULL)
while ((bti = (BTItem) tuplesort_getindextuple(btspool->sortstate,
true, &should_free)) != NULL)
{
/* When we see first tuple, create first index page */
if (state == NULL)
......
This diff is collapsed.
......@@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtproc.c,v 1.37 2003/08/04 02:39:57 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtproc.c,v 1.38 2003/11/12 21:15:48 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -82,20 +82,6 @@ rt_box_size(PG_FUNCTION_ARGS)
PG_RETURN_VOID();
}
/*
* rt_bigbox_size() -- Compute a size for big boxes.
*
* In an earlier release of the system, this routine did something
* different from rt_box_size. We now use floats, rather than ints,
* as the return type for the size routine, so we no longer need to
* have a special return type for big boxes.
*/
Datum
rt_bigbox_size(PG_FUNCTION_ARGS)
{
return rt_box_size(fcinfo);
}
Datum
rt_poly_union(PG_FUNCTION_ARGS)
{
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.48 2003/11/09 21:30:35 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.49 2003/11/12 21:15:48 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -123,15 +123,17 @@ rtrescan(PG_FUNCTION_ARGS)
opclass = s->indexRelation->rd_index->indclass[attno-1];
int_strategy = RTMapToInternalOperator(s->keyData[i].sk_strategy);
int_oper = get_opclass_member(opclass, int_strategy);
int_oper = get_opclass_member(opclass,
s->keyData[i].sk_subtype,
int_strategy);
int_proc = get_opcode(int_oper);
ScanKeyEntryInitialize(&(p->s_internalKey[i]),
s->keyData[i].sk_flags,
attno,
int_strategy,
s->keyData[i].sk_subtype,
int_proc,
s->keyData[i].sk_argument,
s->keyData[i].sk_argtype);
s->keyData[i].sk_argument);
}
}
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.92 2003/11/09 21:30:35 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.93 2003/11/12 21:15:48 tgl Exp $
*
* NOTES
* See acl.h.
......@@ -366,10 +366,10 @@ ExecuteGrantStmt_Database(GrantStmt *stmt)
char replaces[Natts_pg_database];
relation = heap_openr(DatabaseRelationName, RowExclusiveLock);
ScanKeyEntryInitialize(&entry[0], 0,
Anum_pg_database_datname,
BTEqualStrategyNumber, F_NAMEEQ,
CStringGetDatum(dbname), NAMEOID);
ScanKeyInit(&entry[0],
Anum_pg_database_datname,
BTEqualStrategyNumber, F_NAMEEQ,
CStringGetDatum(dbname));
scan = heap_beginscan(relation, SnapshotNow, 1, entry);
tuple = heap_getnext(scan, ForwardScanDirection);
if (!HeapTupleIsValid(tuple))
......@@ -1131,10 +1131,10 @@ pg_database_aclcheck(Oid db_oid, AclId userid, AclMode mode)
* There's no syscache for pg_database, so must look the hard way
*/
pg_database = heap_openr(DatabaseRelationName, AccessShareLock);
ScanKeyEntryInitialize(&entry[0], 0,
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(db_oid), OIDOID);
ScanKeyInit(&entry[0],
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(db_oid));
scan = heap_beginscan(pg_database, SnapshotNow, 1, entry);
tuple = heap_getnext(scan, ForwardScanDirection);
if (!HeapTupleIsValid(tuple))
......@@ -1531,10 +1531,10 @@ pg_database_ownercheck(Oid db_oid, AclId userid)
/* There's no syscache for pg_database, so must look the hard way */
pg_database = heap_openr(DatabaseRelationName, AccessShareLock);
ScanKeyEntryInitialize(&entry[0], 0,
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(db_oid), OIDOID);
ScanKeyInit(&entry[0],
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(db_oid));
scan = heap_beginscan(pg_database, SnapshotNow, 1, entry);
dbtuple = heap_getnext(scan, ForwardScanDirection);
......
......@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/dependency.c,v 1.32 2003/11/09 21:30:35 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/dependency.c,v 1.33 2003/11/12 21:15:48 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -31,7 +31,6 @@
#include "catalog/pg_opclass.h"
#include "catalog/pg_rewrite.h"
#include "catalog/pg_trigger.h"
#include "catalog/pg_type.h"
#include "commands/comment.h"
#include "commands/defrem.h"
#include "commands/proclang.h"
......@@ -283,20 +282,20 @@ findAutoDeletableObjects(const ObjectAddress *object,
* When dropping a whole object (subId = 0), find pg_depend records for
* its sub-objects too.
*/
ScanKeyEntryInitialize(&key[0], 0,
Anum_pg_depend_refclassid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->classId), OIDOID);
ScanKeyEntryInitialize(&key[1], 0,
Anum_pg_depend_refobjid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->objectId), OIDOID);
ScanKeyInit(&key[0],
Anum_pg_depend_refclassid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->classId));
ScanKeyInit(&key[1],
Anum_pg_depend_refobjid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->objectId));
if (object->objectSubId != 0)
{
ScanKeyEntryInitialize(&key[2], 0,
Anum_pg_depend_refobjsubid,
BTEqualStrategyNumber, F_INT4EQ,
Int32GetDatum(object->objectSubId), INT4OID);
ScanKeyInit(&key[2],
Anum_pg_depend_refobjsubid,
BTEqualStrategyNumber, F_INT4EQ,
Int32GetDatum(object->objectSubId));
nkeys = 3;
}
else
......@@ -418,20 +417,20 @@ recursiveDeletion(const ObjectAddress *object,
* When dropping a whole object (subId = 0), remove all pg_depend records
* for its sub-objects too.
*/
ScanKeyEntryInitialize(&key[0], 0,
Anum_pg_depend_classid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->classId), OIDOID);
ScanKeyEntryInitialize(&key[1], 0,
Anum_pg_depend_objid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->objectId), OIDOID);
ScanKeyInit(&key[0],
Anum_pg_depend_classid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->classId));
ScanKeyInit(&key[1],
Anum_pg_depend_objid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->objectId));
if (object->objectSubId != 0)
{
ScanKeyEntryInitialize(&key[2], 0,
Anum_pg_depend_objsubid,
BTEqualStrategyNumber, F_INT4EQ,
Int32GetDatum(object->objectSubId), INT4OID);
ScanKeyInit(&key[2],
Anum_pg_depend_objsubid,
BTEqualStrategyNumber, F_INT4EQ,
Int32GetDatum(object->objectSubId));
nkeys = 3;
}
else
......@@ -651,20 +650,20 @@ deleteDependentObjects(const ObjectAddress *object,
HeapTuple tup;
ObjectAddress otherObject;
ScanKeyEntryInitialize(&key[0], 0,
Anum_pg_depend_refclassid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->classId), OIDOID);
ScanKeyEntryInitialize(&key[1], 0,
Anum_pg_depend_refobjid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->objectId), OIDOID);
ScanKeyInit(&key[0],
Anum_pg_depend_refclassid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->classId));
ScanKeyInit(&key[1],
Anum_pg_depend_refobjid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->objectId));
if (object->objectSubId != 0)
{
ScanKeyEntryInitialize(&key[2], 0,
Anum_pg_depend_refobjsubid,
BTEqualStrategyNumber, F_INT4EQ,
Int32GetDatum(object->objectSubId), INT4OID);
ScanKeyInit(&key[2],
Anum_pg_depend_refobjsubid,
BTEqualStrategyNumber, F_INT4EQ,
Int32GetDatum(object->objectSubId));
nkeys = 3;
}
else
......@@ -1473,11 +1472,10 @@ getObjectDescription(const ObjectAddress *object)
castDesc = heap_openr(CastRelationName, AccessShareLock);
ScanKeyEntryInitialize(&skey[0], 0,
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->objectId),
OIDOID);
ScanKeyInit(&skey[0],
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->objectId));
rcscan = systable_beginscan(castDesc, CastOidIndex, true,
SnapshotNow, 1, skey);
......@@ -1509,11 +1507,10 @@ getObjectDescription(const ObjectAddress *object)
conDesc = heap_openr(ConstraintRelationName, AccessShareLock);
ScanKeyEntryInitialize(&skey[0], 0,
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->objectId),
OIDOID);
ScanKeyInit(&skey[0],
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->objectId));
rcscan = systable_beginscan(conDesc, ConstraintOidIndex, true,
SnapshotNow, 1, skey);
......@@ -1570,11 +1567,10 @@ getObjectDescription(const ObjectAddress *object)
attrdefDesc = heap_openr(AttrDefaultRelationName, AccessShareLock);
ScanKeyEntryInitialize(&skey[0], 0,
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->objectId),
OIDOID);
ScanKeyInit(&skey[0],
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->objectId));
adscan = systable_beginscan(attrdefDesc, AttrDefaultOidIndex,
true, SnapshotNow, 1, skey);
......@@ -1672,11 +1668,10 @@ getObjectDescription(const ObjectAddress *object)
ruleDesc = heap_openr(RewriteRelationName, AccessShareLock);
ScanKeyEntryInitialize(&skey[0], 0,
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->objectId),
OIDOID);
ScanKeyInit(&skey[0],
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->objectId));
rcscan = systable_beginscan(ruleDesc, RewriteOidIndex, true,
SnapshotNow, 1, skey);
......@@ -1708,11 +1703,10 @@ getObjectDescription(const ObjectAddress *object)
trigDesc = heap_openr(TriggerRelationName, AccessShareLock);
ScanKeyEntryInitialize(&skey[0], 0,
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->objectId),
OIDOID);
ScanKeyInit(&skey[0],
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->objectId));
tgscan = systable_beginscan(trigDesc, TriggerOidIndex, true,
SnapshotNow, 1, skey);
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.254 2003/11/09 21:30:36 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.255 2003/11/12 21:15:48 tgl Exp $
*
*
* INTERFACE ROUTINES
......@@ -853,11 +853,10 @@ RelationRemoveInheritance(Relation relation)
catalogRelation = heap_openr(InheritsRelationName, RowExclusiveLock);
ScanKeyEntryInitialize(&key, 0,
Anum_pg_inherits_inhrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(relation)),
OIDOID);
ScanKeyInit(&key,
Anum_pg_inherits_inhrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(relation)));
scan = systable_beginscan(catalogRelation, InheritsRelidSeqnoIndex, true,
SnapshotNow, 1, &key);
......@@ -920,10 +919,10 @@ DeleteAttributeTuples(Oid relid)
attrel = heap_openr(AttributeRelationName, RowExclusiveLock);
/* Use the index to scan only attributes of the target relation */
ScanKeyEntryInitialize(&key[0], 0,
Anum_pg_attribute_attrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(relid), OIDOID);
ScanKeyInit(&key[0],
Anum_pg_attribute_attrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(relid));
scan = systable_beginscan(attrel, AttributeRelidNumIndex, true,
SnapshotNow, 1, key);
......@@ -1035,14 +1034,14 @@ RemoveAttrDefault(Oid relid, AttrNumber attnum,
attrdef_rel = heap_openr(AttrDefaultRelationName, RowExclusiveLock);
ScanKeyEntryInitialize(&scankeys[0], 0,
Anum_pg_attrdef_adrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(relid), OIDOID);
ScanKeyEntryInitialize(&scankeys[1], 0,
Anum_pg_attrdef_adnum,
BTEqualStrategyNumber, F_INT2EQ,
Int16GetDatum(attnum), INT2OID);
ScanKeyInit(&scankeys[0],
Anum_pg_attrdef_adrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(relid));
ScanKeyInit(&scankeys[1],
Anum_pg_attrdef_adnum,
BTEqualStrategyNumber, F_INT2EQ,
Int16GetDatum(attnum));
scan = systable_beginscan(attrdef_rel, AttrDefaultIndex, true,
SnapshotNow, 2, scankeys);
......@@ -1092,10 +1091,10 @@ RemoveAttrDefaultById(Oid attrdefId)
attrdef_rel = heap_openr(AttrDefaultRelationName, RowExclusiveLock);
/* Find the pg_attrdef tuple */
ScanKeyEntryInitialize(&scankeys[0], 0,
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(attrdefId), OIDOID);
ScanKeyInit(&scankeys[0],
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(attrdefId));
scan = systable_beginscan(attrdef_rel, AttrDefaultOidIndex, true,
SnapshotNow, 1, scankeys);
......@@ -1829,10 +1828,10 @@ RemoveRelConstraints(Relation rel, const char *constrName,
conrel = heap_openr(ConstraintRelationName, RowExclusiveLock);
/* Use the index to scan only constraints of the target relation */
ScanKeyEntryInitialize(&key[0], 0,
Anum_pg_constraint_conrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(rel)), OIDOID);
ScanKeyInit(&key[0],
Anum_pg_constraint_conrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(rel)));
conscan = systable_beginscan(conrel, ConstraintRelidIndex, true,
SnapshotNow, 1, key);
......@@ -1883,19 +1882,19 @@ RemoveStatistics(Relation rel, AttrNumber attnum)
pgstatistic = heap_openr(StatisticRelationName, RowExclusiveLock);
ScanKeyEntryInitialize(&key[0], 0,
Anum_pg_statistic_starelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(rel)), OIDOID);
ScanKeyInit(&key[0],
Anum_pg_statistic_starelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(rel)));
if (attnum == 0)
nkeys = 1;
else
{
ScanKeyEntryInitialize(&key[1], 0,
Anum_pg_statistic_staattnum,
BTEqualStrategyNumber, F_INT2EQ,
Int16GetDatum(attnum), INT2OID);
ScanKeyInit(&key[1],
Anum_pg_statistic_staattnum,
BTEqualStrategyNumber, F_INT2EQ,
Int16GetDatum(attnum));
nkeys = 2;
}
......@@ -2050,10 +2049,10 @@ heap_truncate_check_FKs(Relation rel)
*/
fkeyRel = heap_openr(ConstraintRelationName, AccessShareLock);
ScanKeyEntryInitialize(&key, 0,
Anum_pg_constraint_confrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(relid), OIDOID);
ScanKeyInit(&key,
Anum_pg_constraint_confrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(relid));
fkeyScan = systable_beginscan(fkeyRel, NULL, false,
SnapshotNow, 1, &key);
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.220 2003/11/09 21:30:36 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.221 2003/11/12 21:15:48 tgl Exp $
*
*
* INTERFACE ROUTINES
......@@ -992,10 +992,10 @@ setRelhasindex(Oid relid, bool hasindex, bool isprimary, Oid reltoastidxid)
{
ScanKeyData key[1];
ScanKeyEntryInitialize(&key[0], 0,
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(relid), OIDOID);
ScanKeyInit(&key[0],
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(relid));
pg_class_scan = heap_beginscan(pg_class, SnapshotNow, 1, key);
tuple = heap_getnext(pg_class_scan, ForwardScanDirection);
......@@ -1195,10 +1195,10 @@ UpdateStats(Oid relid, double reltuples)
{
ScanKeyData key[1];
ScanKeyEntryInitialize(&key[0], 0,
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(relid), OIDOID);
ScanKeyInit(&key[0],
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(relid));
pg_class_scan = heap_beginscan(pg_class, SnapshotNow, 1, key);
tuple = heap_getnext(pg_class_scan, ForwardScanDirection);
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_constraint.c,v 1.17 2003/11/09 21:30:36 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_constraint.c,v 1.18 2003/11/12 21:15:48 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -281,15 +281,15 @@ ConstraintNameIsUsed(CONSTRAINTCATEGORY conCat, Oid objId, Oid objNamespace, con
found = false;
ScanKeyEntryInitialize(&skey[0], 0,
Anum_pg_constraint_conname,
BTEqualStrategyNumber, F_NAMEEQ,
CStringGetDatum(cname), NAMEOID);
ScanKeyInit(&skey[0],
Anum_pg_constraint_conname,
BTEqualStrategyNumber, F_NAMEEQ,
CStringGetDatum(cname));
ScanKeyEntryInitialize(&skey[1], 0,
Anum_pg_constraint_connamespace,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(objNamespace), OIDOID);
ScanKeyInit(&skey[1],
Anum_pg_constraint_connamespace,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(objNamespace));
conscan = systable_beginscan(conDesc, ConstraintNameNspIndex, true,
SnapshotNow, 2, skey);
......@@ -355,15 +355,15 @@ GenerateConstraintName(CONSTRAINTCATEGORY conCat, Oid objId, Oid objNamespace, i
*/
found = false;
ScanKeyEntryInitialize(&skey[0], 0,
Anum_pg_constraint_conname,
BTEqualStrategyNumber, F_NAMEEQ,
CStringGetDatum(cname), NAMEOID);
ScanKeyInit(&skey[0],
Anum_pg_constraint_conname,
BTEqualStrategyNumber, F_NAMEEQ,
CStringGetDatum(cname));
ScanKeyEntryInitialize(&skey[1], 0,
Anum_pg_constraint_connamespace,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(objNamespace), OIDOID);
ScanKeyInit(&skey[1],
Anum_pg_constraint_connamespace,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(objNamespace));
conscan = systable_beginscan(conDesc, ConstraintNameNspIndex, true,
SnapshotNow, 2, skey);
......@@ -422,10 +422,10 @@ RemoveConstraintById(Oid conId)
conDesc = heap_openr(ConstraintRelationName, RowExclusiveLock);
ScanKeyEntryInitialize(&skey[0], 0,
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(conId), OIDOID);
ScanKeyInit(&skey[0],
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(conId));
conscan = systable_beginscan(conDesc, ConstraintOidIndex, true,
SnapshotNow, 1, skey);
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_conversion.c,v 1.16 2003/11/09 21:30:36 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_conversion.c,v 1.17 2003/11/12 21:15:48 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -21,7 +21,6 @@
#include "catalog/pg_class.h"
#include "catalog/pg_conversion.h"
#include "catalog/namespace.h"
#include "catalog/pg_type.h"
#include "utils/builtins.h"
#include "utils/lsyscache.h"
#include "utils/syscache.h"
......@@ -177,10 +176,10 @@ RemoveConversionById(Oid conversionOid)
HeapScanDesc scan;
ScanKeyData scanKeyData;
ScanKeyEntryInitialize(&scanKeyData, 0,
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(conversionOid), OIDOID);
ScanKeyInit(&scanKeyData,
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(conversionOid));
/* open pg_conversion */
rel = heap_openr(ConversionRelationName, RowExclusiveLock);
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_depend.c,v 1.8 2003/11/09 21:30:36 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_depend.c,v 1.9 2003/11/12 21:15:48 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -20,7 +20,6 @@
#include "catalog/indexing.h"
#include "catalog/dependency.h"
#include "catalog/pg_depend.h"
#include "catalog/pg_type.h"
#include "miscadmin.h"
#include "utils/fmgroids.h"
......@@ -139,14 +138,14 @@ deleteDependencyRecordsFor(Oid classId, Oid objectId)
depRel = heap_openr(DependRelationName, RowExclusiveLock);
ScanKeyEntryInitialize(&key[0], 0,
Anum_pg_depend_classid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(classId), OIDOID);
ScanKeyEntryInitialize(&key[1], 0,
Anum_pg_depend_objid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(objectId), OIDOID);
ScanKeyInit(&key[0],
Anum_pg_depend_classid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(classId));
ScanKeyInit(&key[1],
Anum_pg_depend_objid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(objectId));
scan = systable_beginscan(depRel, DependDependerIndex, true,
SnapshotNow, 2, key);
......@@ -181,15 +180,15 @@ isObjectPinned(const ObjectAddress *object, Relation rel)
HeapTuple tup;
ScanKeyData key[2];
ScanKeyEntryInitialize(&key[0], 0,
Anum_pg_depend_refclassid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->classId), OIDOID);
ScanKeyInit(&key[0],
Anum_pg_depend_refclassid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->classId));
ScanKeyEntryInitialize(&key[1], 0,
Anum_pg_depend_refobjid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->objectId), OIDOID);
ScanKeyInit(&key[1],
Anum_pg_depend_refobjid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->objectId));
scan = systable_beginscan(rel, DependReferenceIndex, true,
SnapshotNow, 2, key);
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_largeobject.c,v 1.18 2003/11/09 21:30:36 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_largeobject.c,v 1.19 2003/11/12 21:15:48 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -19,7 +19,6 @@
#include "catalog/catname.h"
#include "catalog/indexing.h"
#include "catalog/pg_largeobject.h"
#include "catalog/pg_type.h"
#include "miscadmin.h"
#include "utils/builtins.h"
#include "utils/fmgroids.h"
......@@ -82,10 +81,10 @@ LargeObjectDrop(Oid loid)
SysScanDesc sd;
HeapTuple tuple;
ScanKeyEntryInitialize(&skey[0], 0,
Anum_pg_largeobject_loid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(loid), OIDOID);
ScanKeyInit(&skey[0],
Anum_pg_largeobject_loid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(loid));
pg_largeobject = heap_openr(LargeObjectRelationName, RowExclusiveLock);
......@@ -120,10 +119,10 @@ LargeObjectExists(Oid loid)
/*
* See if we can find any tuples belonging to the specified LO
*/
ScanKeyEntryInitialize(&skey[0], 0,
Anum_pg_largeobject_loid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(loid), OIDOID);
ScanKeyInit(&skey[0],
Anum_pg_largeobject_loid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(loid));
pg_largeobject = heap_openr(LargeObjectRelationName, AccessShareLock);
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.103 2003/11/09 21:30:36 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.104 2003/11/12 21:15:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -80,7 +80,6 @@
#include "access/heapam.h"
#include "catalog/catname.h"
#include "catalog/pg_listener.h"
#include "catalog/pg_type.h"
#include "commands/async.h"
#include "libpq/libpq.h"
#include "libpq/pqformat.h"
......@@ -353,10 +352,10 @@ Async_UnlistenAll(void)
tdesc = RelationGetDescr(lRel);
/* Find and delete all entries with my listenerPID */
ScanKeyEntryInitialize(&key[0], 0,
Anum_pg_listener_pid,
BTEqualStrategyNumber, F_INT4EQ,
Int32GetDatum(MyProcPid), INT4OID);
ScanKeyInit(&key[0],
Anum_pg_listener_pid,
BTEqualStrategyNumber, F_INT4EQ,
Int32GetDatum(MyProcPid));
scan = heap_beginscan(lRel, SnapshotNow, 1, key);
while ((lTuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
......@@ -817,10 +816,10 @@ ProcessIncomingNotify(void)
tdesc = RelationGetDescr(lRel);
/* Scan only entries with my listenerPID */
ScanKeyEntryInitialize(&key[0], 0,
Anum_pg_listener_pid,
BTEqualStrategyNumber, F_INT4EQ,
Int32GetDatum(MyProcPid), INT4OID);
ScanKeyInit(&key[0],
Anum_pg_listener_pid,
BTEqualStrategyNumber, F_INT4EQ,
Int32GetDatum(MyProcPid));
scan = heap_beginscan(lRel, SnapshotNow, 1, key);
/* Prepare data for rewriting 0 into notification field */
......
......@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.117 2003/11/09 21:30:36 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.118 2003/11/12 21:15:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -26,7 +26,6 @@
#include "catalog/index.h"
#include "catalog/indexing.h"
#include "catalog/namespace.h"
#include "catalog/pg_type.h"
#include "commands/cluster.h"
#include "commands/tablecmds.h"
#include "miscadmin.h"
......@@ -879,10 +878,10 @@ get_tables_to_cluster(MemoryContext cluster_context)
* when called with one of them as argument.
*/
indRelation = relation_openr(IndexRelationName, AccessShareLock);
ScanKeyEntryInitialize(&entry, 0,
Anum_pg_index_indisclustered,
BTEqualStrategyNumber, F_BOOLEQ,
BoolGetDatum(true), BOOLOID);
ScanKeyInit(&entry,
Anum_pg_index_indisclustered,
BTEqualStrategyNumber, F_BOOLEQ,
BoolGetDatum(true));
scan = heap_beginscan(indRelation, SnapshotNow, 1, &entry);
while ((indexTuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
......
......@@ -7,7 +7,7 @@
* Copyright (c) 1996-2003, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/comment.c,v 1.72 2003/11/09 21:30:36 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/comment.c,v 1.73 2003/11/12 21:15:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -156,18 +156,18 @@ CreateComments(Oid oid, Oid classoid, int32 subid, char *comment)
/* Use the index to search for a matching old tuple */
ScanKeyEntryInitialize(&skey[0], 0,
Anum_pg_description_objoid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(oid), OIDOID);
ScanKeyEntryInitialize(&skey[1], 0,
Anum_pg_description_classoid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(classoid), OIDOID);
ScanKeyEntryInitialize(&skey[2], 0,
Anum_pg_description_objsubid,
BTEqualStrategyNumber, F_INT4EQ,
Int32GetDatum(subid), INT4OID);
ScanKeyInit(&skey[0],
Anum_pg_description_objoid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(oid));
ScanKeyInit(&skey[1],
Anum_pg_description_classoid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(classoid));
ScanKeyInit(&skey[2],
Anum_pg_description_objsubid,
BTEqualStrategyNumber, F_INT4EQ,
Int32GetDatum(subid));
description = heap_openr(DescriptionRelationName, RowExclusiveLock);
......@@ -231,21 +231,21 @@ DeleteComments(Oid oid, Oid classoid, int32 subid)
/* Use the index to search for all matching old tuples */
ScanKeyEntryInitialize(&skey[0], 0,
Anum_pg_description_objoid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(oid), OIDOID);
ScanKeyEntryInitialize(&skey[1], 0,
Anum_pg_description_classoid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(classoid), OIDOID);
ScanKeyInit(&skey[0],
Anum_pg_description_objoid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(oid));
ScanKeyInit(&skey[1],
Anum_pg_description_classoid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(classoid));
if (subid != 0)
{
ScanKeyEntryInitialize(&skey[2], 0,
Anum_pg_description_objsubid,
BTEqualStrategyNumber, F_INT4EQ,
Int32GetDatum(subid), INT4OID);
ScanKeyInit(&skey[2],
Anum_pg_description_objsubid,
BTEqualStrategyNumber, F_INT4EQ,
Int32GetDatum(subid));
nkeys = 3;
}
else
......@@ -538,10 +538,10 @@ CommentRule(List *qualname, char *comment)
rulename = strVal(lfirst(qualname));
/* Search pg_rewrite for such a rule */
ScanKeyEntryInitialize(&scanKeyData, 0,
Anum_pg_rewrite_rulename,
BTEqualStrategyNumber, F_NAMEEQ,
PointerGetDatum(rulename), NAMEOID);
ScanKeyInit(&scanKeyData,
Anum_pg_rewrite_rulename,
BTEqualStrategyNumber, F_NAMEEQ,
PointerGetDatum(rulename));
RewriteRelation = heap_openr(RewriteRelationName, AccessShareLock);
scanDesc = heap_beginscan(RewriteRelation, SnapshotNow,
......@@ -791,15 +791,14 @@ CommentTrigger(List *qualname, char *comment)
* because of the unique index.
*/
pg_trigger = heap_openr(TriggerRelationName, AccessShareLock);
ScanKeyEntryInitialize(&entry[0], 0,
Anum_pg_trigger_tgrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(relation)),
OIDOID);
ScanKeyEntryInitialize(&entry[1], 0,
Anum_pg_trigger_tgname,
BTEqualStrategyNumber, F_NAMEEQ,
CStringGetDatum(trigname), NAMEOID);
ScanKeyInit(&entry[0],
Anum_pg_trigger_tgrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(relation)));
ScanKeyInit(&entry[1],
Anum_pg_trigger_tgname,
BTEqualStrategyNumber, F_NAMEEQ,
CStringGetDatum(trigname));
scan = systable_beginscan(pg_trigger, TriggerRelidNameIndex, true,
SnapshotNow, 2, entry);
triggertuple = systable_getnext(scan);
......@@ -872,11 +871,10 @@ CommentConstraint(List *qualname, char *comment)
*/
pg_constraint = heap_openr(ConstraintRelationName, AccessShareLock);
ScanKeyEntryInitialize(&skey[0], 0,
Anum_pg_constraint_conrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(relation)),
OIDOID);
ScanKeyInit(&skey[0],
Anum_pg_constraint_conrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(relation)));
scan = systable_beginscan(pg_constraint, ConstraintRelidIndex, true,
SnapshotNow, 1, skey);
......
......@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.125 2003/11/09 21:30:36 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.126 2003/11/12 21:15:50 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -27,7 +27,6 @@
#include "catalog/pg_database.h"
#include "catalog/pg_shadow.h"
#include "catalog/indexing.h"
#include "catalog/pg_type.h"
#include "commands/comment.h"
#include "commands/dbcommands.h"
#include "miscadmin.h"
......@@ -531,10 +530,10 @@ dropdb(const char *dbname)
/*
* Find the database's tuple by OID (should be unique).
*/
ScanKeyEntryInitialize(&key, 0,
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(db_id), OIDOID);
ScanKeyInit(&key,
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(db_id));
pgdbscan = systable_beginscan(pgdbrel, DatabaseOidIndex, true,
SnapshotNow, 1, &key);
......@@ -616,10 +615,10 @@ RenameDatabase(const char *oldname, const char *newname)
*/
rel = heap_openr(DatabaseRelationName, AccessExclusiveLock);
ScanKeyEntryInitialize(&key, 0,
Anum_pg_database_datname,
BTEqualStrategyNumber, F_NAMEEQ,
NameGetDatum(oldname), NAMEOID);
ScanKeyInit(&key,
Anum_pg_database_datname,
BTEqualStrategyNumber, F_NAMEEQ,
NameGetDatum(oldname));
scan = systable_beginscan(rel, DatabaseNameIndex, true,
SnapshotNow, 1, &key);
......@@ -651,10 +650,10 @@ RenameDatabase(const char *oldname, const char *newname)
oldname)));
/* make sure the new name doesn't exist */
ScanKeyEntryInitialize(&key2, 0,
Anum_pg_database_datname,
BTEqualStrategyNumber, F_NAMEEQ,
NameGetDatum(newname), NAMEOID);
ScanKeyInit(&key2,
Anum_pg_database_datname,
BTEqualStrategyNumber, F_NAMEEQ,
NameGetDatum(newname));
scan2 = systable_beginscan(rel, DatabaseNameIndex, true,
SnapshotNow, 1, &key2);
if (HeapTupleIsValid(systable_getnext(scan2)))
......@@ -712,10 +711,10 @@ AlterDatabaseSet(AlterDatabaseSetStmt *stmt)
valuestr = flatten_set_variable_args(stmt->variable, stmt->value);
rel = heap_openr(DatabaseRelationName, RowExclusiveLock);
ScanKeyEntryInitialize(&scankey, 0,
Anum_pg_database_datname,
BTEqualStrategyNumber, F_NAMEEQ,
NameGetDatum(stmt->dbname), NAMEOID);
ScanKeyInit(&scankey,
Anum_pg_database_datname,
BTEqualStrategyNumber, F_NAMEEQ,
NameGetDatum(stmt->dbname));
scan = systable_beginscan(rel, DatabaseNameIndex, true,
SnapshotNow, 1, &scankey);
tuple = systable_getnext(scan);
......@@ -795,10 +794,10 @@ get_db_info(const char *name, Oid *dbIdP, int4 *ownerIdP,
/* Caller may wish to grab a better lock on pg_database beforehand... */
relation = heap_openr(DatabaseRelationName, AccessShareLock);
ScanKeyEntryInitialize(&scanKey, 0,
Anum_pg_database_datname,
BTEqualStrategyNumber, F_NAMEEQ,
NameGetDatum(name), NAMEOID);
ScanKeyInit(&scanKey,
Anum_pg_database_datname,
BTEqualStrategyNumber, F_NAMEEQ,
NameGetDatum(name));
scan = systable_beginscan(relation, DatabaseNameIndex, true,
SnapshotNow, 1, &scanKey);
......@@ -1001,10 +1000,10 @@ get_database_oid(const char *dbname)
/* There's no syscache for pg_database, so must look the hard way */
pg_database = heap_openr(DatabaseRelationName, AccessShareLock);
ScanKeyEntryInitialize(&entry[0], 0,
Anum_pg_database_datname,
BTEqualStrategyNumber, F_NAMEEQ,
CStringGetDatum(dbname), NAMEOID);
ScanKeyInit(&entry[0],
Anum_pg_database_datname,
BTEqualStrategyNumber, F_NAMEEQ,
CStringGetDatum(dbname));
scan = systable_beginscan(pg_database, DatabaseNameIndex, true,
SnapshotNow, 1, entry);
......@@ -1041,10 +1040,10 @@ get_database_name(Oid dbid)
/* There's no syscache for pg_database, so must look the hard way */
pg_database = heap_openr(DatabaseRelationName, AccessShareLock);
ScanKeyEntryInitialize(&entry[0], 0,
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(dbid), OIDOID);
ScanKeyInit(&entry[0],
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(dbid));
scan = systable_beginscan(pg_database, DatabaseOidIndex, true,
SnapshotNow, 1, entry);
......
......@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/functioncmds.c,v 1.39 2003/11/09 21:30:36 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/functioncmds.c,v 1.40 2003/11/12 21:15:50 tgl Exp $
*
* DESCRIPTION
* These routines take the parse tree and pick out the
......@@ -1097,10 +1097,10 @@ DropCastById(Oid castOid)
relation = heap_openr(CastRelationName, RowExclusiveLock);
ScanKeyEntryInitialize(&scankey, 0,
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(castOid), OIDOID);
ScanKeyInit(&scankey,
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(castOid));
scan = systable_beginscan(relation, CastOidIndex, true,
SnapshotNow, 1, &scankey);
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.114 2003/10/02 06:34:03 petere Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.115 2003/11/12 21:15:50 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -416,6 +416,9 @@ GetIndexOpClass(List *opclass, Oid attrType,
* Release 7.2 renames timestamp_ops to timestamptz_ops, so suppress that
* too for awhile. I'm starting to think we need a better approach.
* tgl 2000/10/01
*
* Release 7.5 removes bigbox_ops (which was dead code for a long while
* anyway). tgl 2003/11/11
*/
if (length(opclass) == 1)
{
......@@ -425,7 +428,8 @@ GetIndexOpClass(List *opclass, Oid attrType,
strcmp(claname, "timespan_ops") == 0 ||
strcmp(claname, "datetime_ops") == 0 ||
strcmp(claname, "lztext_ops") == 0 ||
strcmp(claname, "timestamp_ops") == 0)
strcmp(claname, "timestamp_ops") == 0 ||
strcmp(claname, "bigbox_ops") == 0)
opclass = NIL;
}
......
This diff is collapsed.
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.92 2003/11/09 21:30:36 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.93 2003/11/12 21:15:51 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -1393,20 +1393,20 @@ update_ri_trigger_args(Oid relid,
tgrel = heap_openr(TriggerRelationName, RowExclusiveLock);
if (fk_scan)
{
ScanKeyEntryInitialize(&skey[0], 0,
Anum_pg_trigger_tgconstrrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(relid), OIDOID);
ScanKeyInit(&skey[0],
Anum_pg_trigger_tgconstrrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(relid));
trigscan = systable_beginscan(tgrel, TriggerConstrRelidIndex,
true, SnapshotNow,
1, skey);
}
else
{
ScanKeyEntryInitialize(&skey[0], 0,
Anum_pg_trigger_tgrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(relid), OIDOID);
ScanKeyInit(&skey[0],
Anum_pg_trigger_tgrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(relid));
trigscan = systable_beginscan(tgrel, TriggerRelidNameIndex,
true, SnapshotNow,
1, skey);
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.161 2003/11/09 21:30:36 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.162 2003/11/12 21:15:51 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -253,10 +253,10 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint)
* relation, so the trigger set won't be changing underneath us.
*/
tgrel = heap_openr(TriggerRelationName, RowExclusiveLock);
ScanKeyEntryInitialize(&key, 0,
Anum_pg_trigger_tgrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(rel)), OIDOID);
ScanKeyInit(&key,
Anum_pg_trigger_tgrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(rel)));
tgscan = systable_beginscan(tgrel, TriggerRelidNameIndex, true,
SnapshotNow, 1, &key);
while (HeapTupleIsValid(tuple = systable_getnext(tgscan)))
......@@ -465,15 +465,15 @@ DropTrigger(Oid relid, const char *trigname, DropBehavior behavior)
*/
tgrel = heap_openr(TriggerRelationName, AccessShareLock);
ScanKeyEntryInitialize(&skey[0], 0,
Anum_pg_trigger_tgrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(relid), OIDOID);
ScanKeyInit(&skey[0],
Anum_pg_trigger_tgrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(relid));
ScanKeyEntryInitialize(&skey[1], 0,
Anum_pg_trigger_tgname,
BTEqualStrategyNumber, F_NAMEEQ,
CStringGetDatum(trigname), NAMEOID);
ScanKeyInit(&skey[1],
Anum_pg_trigger_tgname,
BTEqualStrategyNumber, F_NAMEEQ,
CStringGetDatum(trigname));
tgscan = systable_beginscan(tgrel, TriggerRelidNameIndex, true,
SnapshotNow, 2, skey);
......@@ -524,10 +524,10 @@ RemoveTriggerById(Oid trigOid)
/*
* Find the trigger to delete.
*/
ScanKeyEntryInitialize(&skey[0], 0,
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(trigOid), OIDOID);
ScanKeyInit(&skey[0],
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(trigOid));
tgscan = systable_beginscan(tgrel, TriggerOidIndex, true,
SnapshotNow, 1, skey);
......@@ -641,14 +641,14 @@ renametrig(Oid relid,
/*
* First pass -- look for name conflict
*/
ScanKeyEntryInitialize(&key[0], 0,
Anum_pg_trigger_tgrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(relid), OIDOID);
ScanKeyEntryInitialize(&key[1], 0,
Anum_pg_trigger_tgname,
BTEqualStrategyNumber, F_NAMEEQ,
PointerGetDatum(newname), NAMEOID);
ScanKeyInit(&key[0],
Anum_pg_trigger_tgrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(relid));
ScanKeyInit(&key[1],
Anum_pg_trigger_tgname,
BTEqualStrategyNumber, F_NAMEEQ,
PointerGetDatum(newname));
tgscan = systable_beginscan(tgrel, TriggerRelidNameIndex, true,
SnapshotNow, 2, key);
if (HeapTupleIsValid(tuple = systable_getnext(tgscan)))
......@@ -661,14 +661,14 @@ renametrig(Oid relid,
/*
* Second pass -- look for trigger existing with oldname and update
*/
ScanKeyEntryInitialize(&key[0], 0,
Anum_pg_trigger_tgrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(relid), OIDOID);
ScanKeyEntryInitialize(&key[1], 0,
Anum_pg_trigger_tgname,
BTEqualStrategyNumber, F_NAMEEQ,
PointerGetDatum(oldname), NAMEOID);
ScanKeyInit(&key[0],
Anum_pg_trigger_tgrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(relid));
ScanKeyInit(&key[1],
Anum_pg_trigger_tgname,
BTEqualStrategyNumber, F_NAMEEQ,
PointerGetDatum(oldname));
tgscan = systable_beginscan(tgrel, TriggerRelidNameIndex, true,
SnapshotNow, 2, key);
if (HeapTupleIsValid(tuple = systable_getnext(tgscan)))
......@@ -744,11 +744,10 @@ RelationBuildTriggers(Relation relation)
* emergency-recovery operations (ie, IsIgnoringSystemIndexes). This
* in turn ensures that triggers will be fired in name order.
*/
ScanKeyEntryInitialize(&skey, 0,
Anum_pg_trigger_tgrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(relation)),
OIDOID);
ScanKeyInit(&skey,
Anum_pg_trigger_tgrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(relation)));
tgrel = heap_openr(TriggerRelationName, AccessShareLock);
tgscan = systable_beginscan(tgrel, TriggerRelidNameIndex, true,
......@@ -2262,10 +2261,10 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
/*
* Setup to scan pg_trigger by tgconstrname ...
*/
ScanKeyEntryInitialize(&skey, 0,
Anum_pg_trigger_tgconstrname,
BTEqualStrategyNumber, F_NAMEEQ,
PointerGetDatum(cname), NAMEOID);
ScanKeyInit(&skey,
Anum_pg_trigger_tgconstrname,
BTEqualStrategyNumber, F_NAMEEQ,
PointerGetDatum(cname));
tgscan = systable_beginscan(tgrel, TriggerConstrNameIndex, true,
SnapshotNow, 1, &skey);
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/typecmds.c,v 1.49 2003/11/09 21:30:36 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/typecmds.c,v 1.50 2003/11/12 21:15:51 tgl Exp $
*
* DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the
......@@ -1362,10 +1362,10 @@ AlterDomainDropConstraint(List *names, const char *constrName, DropBehavior beha
conrel = heap_openr(ConstraintRelationName, RowExclusiveLock);
/* Use the index to scan only constraints of the target relation */
ScanKeyEntryInitialize(&key[0], 0,
Anum_pg_constraint_contypid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(HeapTupleGetOid(tup)), OIDOID);
ScanKeyInit(&key[0],
Anum_pg_constraint_contypid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(HeapTupleGetOid(tup)));
conscan = systable_beginscan(conrel, ConstraintTypidIndex, true,
SnapshotNow, 1, key);
......@@ -1615,14 +1615,14 @@ get_rels_with_domain(Oid domainOid, LOCKMODE lockmode)
*/
depRel = relation_openr(DependRelationName, AccessShareLock);
ScanKeyEntryInitialize(&key[0], 0,
Anum_pg_depend_refclassid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelOid_pg_type), OIDOID);
ScanKeyEntryInitialize(&key[1], 0,
Anum_pg_depend_refobjid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(domainOid), OIDOID);
ScanKeyInit(&key[0],
Anum_pg_depend_refclassid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelOid_pg_type));
ScanKeyInit(&key[1],
Anum_pg_depend_refobjid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(domainOid));
depScan = systable_beginscan(depRel, DependReferenceIndex, true,
SnapshotNow, 2, key);
......@@ -1901,10 +1901,10 @@ GetDomainConstraints(Oid typeOid)
notNull = true;
/* Look for CHECK Constraints on this domain */
ScanKeyEntryInitialize(&key[0], 0,
Anum_pg_constraint_contypid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(typeOid), OIDOID);
ScanKeyInit(&key[0],
Anum_pg_constraint_contypid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(typeOid));
scan = systable_beginscan(conRel, ConstraintTypidIndex, true,
SnapshotNow, 1, key);
......
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.129 2003/11/09 21:30:36 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.130 2003/11/12 21:15:51 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -1074,10 +1074,10 @@ DropUser(DropUserStmt *stmt)
pg_rel = heap_openr(DatabaseRelationName, AccessShareLock);
pg_dsc = RelationGetDescr(pg_rel);
ScanKeyEntryInitialize(&scankey, 0,
Anum_pg_database_datdba,
BTEqualStrategyNumber, F_INT4EQ,
Int32GetDatum(usesysid), INT4OID);
ScanKeyInit(&scankey,
Anum_pg_database_datdba,
BTEqualStrategyNumber, F_INT4EQ,
Int32GetDatum(usesysid));
scan = heap_beginscan(pg_rel, SnapshotNow, 1, &scankey);
......
......@@ -13,7 +13,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.264 2003/11/09 21:30:36 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.265 2003/11/12 21:15:51 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -30,7 +30,6 @@
#include "catalog/namespace.h"
#include "catalog/pg_database.h"
#include "catalog/pg_index.h"
#include "catalog/pg_type.h"
#include "commands/vacuum.h"
#include "executor/executor.h"
#include "miscadmin.h"
......@@ -400,10 +399,10 @@ getrels(const RangeVar *vacrel, const char *stmttype)
HeapTuple tuple;
ScanKeyData key;
ScanKeyEntryInitialize(&key, 0,
Anum_pg_class_relkind,
BTEqualStrategyNumber, F_CHAREQ,
CharGetDatum(RELKIND_RELATION), CHAROID);
ScanKeyInit(&key,
Anum_pg_class_relkind,
BTEqualStrategyNumber, F_CHAREQ,
CharGetDatum(RELKIND_RELATION));
pgclass = heap_openr(RelationRelationName, AccessShareLock);
......@@ -583,10 +582,10 @@ vac_update_dbstats(Oid dbid,
relation = heap_openr(DatabaseRelationName, RowExclusiveLock);
/* Must use a heap scan, since there's no syscache for pg_database */
ScanKeyEntryInitialize(&entry[0], 0,
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(dbid), OIDOID);
ScanKeyInit(&entry[0],
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(dbid));
scan = heap_beginscan(relation, SnapshotNow, 1, entry);
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.85 2003/11/09 21:30:36 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.86 2003/11/12 21:15:52 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -31,7 +31,6 @@
#include "miscadmin.h"
#include "nodes/nodeFuncs.h"
#include "optimizer/clauses.h"
#include "parser/parse_expr.h"
#include "parser/parsetree.h"
......@@ -615,6 +614,7 @@ ExecInitIndexScan(IndexScan *node, EState *estate)
IndexScanState *indexstate;
List *indxqual;
List *indxstrategy;
List *indxsubtype;
List *indxid;
int i;
int numIndices;
......@@ -711,10 +711,12 @@ ExecInitIndexScan(IndexScan *node, EState *estate)
*/
indxqual = node->indxqual;
indxstrategy = node->indxstrategy;
indxsubtype = node->indxsubtype;
for (i = 0; i < numIndices; i++)
{
List *quals;
List *strategies;
List *subtypes;
int n_keys;
ScanKey scan_keys;
ExprState **run_keys;
......@@ -724,6 +726,8 @@ ExecInitIndexScan(IndexScan *node, EState *estate)
indxqual = lnext(indxqual);
strategies = lfirst(indxstrategy);
indxstrategy = lnext(indxstrategy);
subtypes = lfirst(indxsubtype);
indxsubtype = lnext(indxsubtype);
n_keys = length(quals);
scan_keys = (n_keys <= 0) ? (ScanKey) NULL :
(ScanKey) palloc(n_keys * sizeof(ScanKeyData));
......@@ -742,9 +746,9 @@ ExecInitIndexScan(IndexScan *node, EState *estate)
int flags = 0;
AttrNumber varattno; /* att number used in scan */
StrategyNumber strategy; /* op's strategy number */
Oid subtype; /* op's strategy subtype */
RegProcedure opfuncid; /* operator proc id used in scan */
Datum scanvalue; /* value used in scan (if const) */
Oid rhstype; /* datatype of comparison value */
/*
* extract clause information from the qualification
......@@ -753,6 +757,8 @@ ExecInitIndexScan(IndexScan *node, EState *estate)
quals = lnext(quals);
strategy = lfirsti(strategies);
strategies = lnext(strategies);
subtype = lfirsto(subtypes);
subtypes = lnext(subtypes);
if (!IsA(clause, OpExpr))
elog(ERROR, "indxqual is not an OpExpr");
......@@ -795,8 +801,6 @@ ExecInitIndexScan(IndexScan *node, EState *estate)
*/
rightop = (Expr *) get_rightop((Expr *) clause);
rhstype = exprType((Node *) rightop);
if (rightop && IsA(rightop, RelabelType))
rightop = ((RelabelType *) rightop)->arg;
......@@ -832,9 +836,9 @@ ExecInitIndexScan(IndexScan *node, EState *estate)
varattno, /* attribute number to
* scan */
strategy, /* op's strategy */
subtype, /* strategy subtype */
opfuncid, /* reg proc to use */
scanvalue, /* constant */
rhstype); /* constant's type */
scanvalue); /* constant */
}
/*
......
......@@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.266 2003/11/09 21:30:36 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.267 2003/11/12 21:15:52 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -273,6 +273,17 @@ _copyIndexScan(IndexScan *from)
}
newnode->indxstrategy = newstrat;
}
/* this can become COPY_NODE_FIELD when OID lists are normal objects: */
{
List *newsubtype = NIL;
List *tmp;
foreach(tmp, from->indxsubtype)
{
newsubtype = lappend(newsubtype, listCopy(lfirst(tmp)));
}
newnode->indxsubtype = newsubtype;
}
COPY_SCALAR_FIELD(indxorderdir);
return newnode;
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.219 2003/11/09 21:30:36 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.220 2003/11/12 21:15:52 tgl Exp $
*
* NOTES
* Every node type that can appear in stored rules' parsetrees *must*
......@@ -346,6 +346,16 @@ _outIndexScan(StringInfo str, IndexScan *node)
_outIntList(str, lfirst(tmp));
}
}
/* this can become WRITE_NODE_FIELD when OID lists are normal objects: */
{
List *tmp;
appendStringInfo(str, " :indxsubtype ");
foreach(tmp, node->indxsubtype)
{
_outOidList(str, lfirst(tmp));
}
}
WRITE_ENUM_FIELD(indxorderdir, ScanDirection);
}
......
......@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.147 2003/08/04 02:40:00 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.148 2003/11/12 21:15:52 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -1072,7 +1072,7 @@ pred_test_recurse_pred(Expr *predicate, Node *clause)
*
* If you know, for some ATTR, that "ATTR given_op CONST1" is true, and you
* want to determine whether "ATTR target_op CONST2" must also be true, then
* you can use "CONST1 test_op CONST2" as a test. If this test returns true,
* you can use "CONST2 test_op CONST1" as a test. If this test returns true,
* then the target expression must be true; if the test returns false, then
* the target expression may be false.
*
......@@ -1082,11 +1082,11 @@ pred_test_recurse_pred(Expr *predicate, Node *clause)
static const StrategyNumber
BT_implic_table[BTMaxStrategyNumber][BTMaxStrategyNumber] = {
{2, 2, 0, 0, 0},
{1, 2, 0, 0, 0},
{1, 2, 3, 4, 5},
{0, 0, 0, 4, 5},
{0, 0, 0, 4, 4}
{4, 4, 0, 0, 0},
{5, 4, 0, 0, 0},
{5, 4, 3, 2, 1},
{0, 0, 0, 2, 1},
{0, 0, 0, 2, 2}
};
......@@ -1118,12 +1118,13 @@ pred_test_simple_clause(Expr *predicate, Node *clause)
*clause_const;
Oid pred_op,
clause_op,
test_op;
Oid opclass_id = InvalidOid;
test_op = InvalidOid;
Oid opclass_id;
bool found = false;
StrategyNumber pred_strategy = 0,
clause_strategy = 0,
StrategyNumber pred_strategy,
clause_strategy,
test_strategy;
Oid clause_subtype;
Expr *test_expr;
ExprState *test_exprstate;
Datum test_result;
......@@ -1140,7 +1141,9 @@ pred_test_simple_clause(Expr *predicate, Node *clause)
/*
* Can't do anything more unless they are both binary opclauses with a
* Var on the left and a Const on the right. (XXX someday try to
* commute Const/Var cases?)
* commute Const/Var cases?) Note we don't have to think about binary
* relabeling of the Const node, since that would have been folded right
* into the Const.
*/
if (!is_opclause(predicate))
return false;
......@@ -1173,14 +1176,20 @@ pred_test_simple_clause(Expr *predicate, Node *clause)
clause_op = ((OpExpr *) clause)->opno;
/*
* 1. Find "btree" strategy numbers for the pred_op and clause_op.
* Try to find a btree opclass containing the needed operators.
*
* We must find a btree opclass that contains both operators, else the
* implication can't be determined. If there are multiple such
* opclasses, assume we can use any one to determine the logical
* relationship of the two operators and the correct corresponding
* test operator. This should work for any logically consistent
* opclasses.
* implication can't be determined. Also, the pred_op has to be of
* default subtype (implying left and right input datatypes are the same);
* otherwise it's unsafe to put the pred_const on the left side of the
* test. Also, the opclass must contain a suitable test operator
* matching the clause_const's type (which we take to mean that it has
* the same subtype as the original clause_operator).
*
* If there are multiple matching opclasses, assume we can use any one to
* determine the logical relationship of the two operators and the correct
* corresponding test operator. This should work for any logically
* consistent opclasses.
*/
catlist = SearchSysCacheList(AMOPOPID, 1,
ObjectIdGetDatum(pred_op),
......@@ -1192,7 +1201,13 @@ pred_test_simple_clause(Expr *predicate, Node *clause)
Form_pg_amop pred_form = (Form_pg_amop) GETSTRUCT(pred_tuple);
HeapTuple clause_tuple;
if (!opclass_is_btree(pred_form->amopclaid))
opclass_id = pred_form->amopclaid;
/* must be btree */
if (!opclass_is_btree(opclass_id))
continue;
/* predicate operator must be default within this opclass */
if (pred_form->amopsubtype != InvalidOid)
continue;
/* Get the predicate operator's btree strategy number */
......@@ -1200,12 +1215,7 @@ pred_test_simple_clause(Expr *predicate, Node *clause)
Assert(pred_strategy >= 1 && pred_strategy <= 5);
/*
* Remember which operator class this strategy number came from
*/
opclass_id = pred_form->amopclaid;
/*
* From the same opclass, find a strategy num for the clause_op,
* From the same opclass, find a strategy number for the clause_op,
* if possible
*/
clause_tuple = SearchSysCache(AMOPOPID,
......@@ -1216,13 +1226,35 @@ pred_test_simple_clause(Expr *predicate, Node *clause)
{
Form_pg_amop clause_form = (Form_pg_amop) GETSTRUCT(clause_tuple);
/* Get the restriction clause operator's strategy number */
/* Get the restriction clause operator's strategy/subtype */
clause_strategy = (StrategyNumber) clause_form->amopstrategy;
Assert(clause_strategy >= 1 && clause_strategy <= 5);
clause_subtype = clause_form->amopsubtype;
/* done with clause_tuple */
ReleaseSysCache(clause_tuple);
found = true;
break;
/*
* Look up the "test" strategy number in the implication table
*/
test_strategy = BT_implic_table[clause_strategy - 1][pred_strategy - 1];
if (test_strategy == 0)
{
/* Can't determine implication using this interpretation */
continue;
}
/*
* See if opclass has an operator for the test strategy and the
* clause datatype.
*/
test_op = get_opclass_member(opclass_id, clause_subtype,
test_strategy);
if (OidIsValid(test_op))
{
found = true;
break;
}
}
}
......@@ -1235,25 +1267,7 @@ pred_test_simple_clause(Expr *predicate, Node *clause)
}
/*
* 2. Look up the "test" strategy number in the implication table
*/
test_strategy = BT_implic_table[clause_strategy - 1][pred_strategy - 1];
if (test_strategy == 0)
return false; /* the implication cannot be determined */
/*
* 3. From the same opclass, find the operator for the test strategy
*/
test_op = get_opclass_member(opclass_id, test_strategy);
if (!OidIsValid(test_op))
{
/* This should not fail, else pg_amop entry is missing */
elog(ERROR, "missing pg_amop entry for opclass %u strategy %d",
opclass_id, test_strategy);
}
/*
* 4. Evaluate the test. For this we need an EState.
* Evaluate the test. For this we need an EState.
*/
estate = CreateExecutorState();
......@@ -1264,8 +1278,8 @@ pred_test_simple_clause(Expr *predicate, Node *clause)
test_expr = make_opclause(test_op,
BOOLOID,
false,
(Expr *) clause_const,
(Expr *) pred_const);
(Expr *) pred_const,
(Expr *) clause_const);
/* Prepare it for execution */
test_exprstate = ExecPrepareExpr(test_expr, estate);
......@@ -1907,7 +1921,7 @@ match_special_index_operator(Expr *clause, Oid opclass,
* (The latter is not depended on by any part of the planner, so far as I can
* tell; but some parts of the executor do assume that the indxqual list
* ultimately delivered to the executor is so ordered. One such place is
* _bt_orderkeys() in the btree support. Perhaps that ought to be fixed
* _bt_preprocess_keys() in the btree support. Perhaps that ought to be fixed
* someday --- tgl 7/00)
*/
List *
......@@ -2103,7 +2117,8 @@ prefix_quals(Node *leftop, Oid opclass,
*/
if (pstatus == Pattern_Prefix_Exact)
{
oproid = get_opclass_member(opclass, BTEqualStrategyNumber);
oproid = get_opclass_member(opclass, InvalidOid,
BTEqualStrategyNumber);
if (oproid == InvalidOid)
elog(ERROR, "no = operator for opclass %u", opclass);
expr = make_opclause(oproid, BOOLOID, false,
......@@ -2117,7 +2132,8 @@ prefix_quals(Node *leftop, Oid opclass,
*
* We can always say "x >= prefix".
*/
oproid = get_opclass_member(opclass, BTGreaterEqualStrategyNumber);
oproid = get_opclass_member(opclass, InvalidOid,
BTGreaterEqualStrategyNumber);
if (oproid == InvalidOid)
elog(ERROR, "no >= operator for opclass %u", opclass);
expr = make_opclause(oproid, BOOLOID, false,
......@@ -2132,7 +2148,8 @@ prefix_quals(Node *leftop, Oid opclass,
greaterstr = make_greater_string(prefix_const);
if (greaterstr)
{
oproid = get_opclass_member(opclass, BTLessStrategyNumber);
oproid = get_opclass_member(opclass, InvalidOid,
BTLessStrategyNumber);
if (oproid == InvalidOid)
elog(ERROR, "no < operator for opclass %u", opclass);
expr = make_opclause(oproid, BOOLOID, false,
......@@ -2189,13 +2206,15 @@ network_prefix_quals(Node *leftop, Oid expr_op, Oid opclass, Datum rightop)
*/
if (is_eq)
{
opr1oid = get_opclass_member(opclass, BTGreaterEqualStrategyNumber);
opr1oid = get_opclass_member(opclass, InvalidOid,
BTGreaterEqualStrategyNumber);
if (opr1oid == InvalidOid)
elog(ERROR, "no >= operator for opclass %u", opclass);
}
else
{
opr1oid = get_opclass_member(opclass, BTGreaterStrategyNumber);
opr1oid = get_opclass_member(opclass, InvalidOid,
BTGreaterStrategyNumber);
if (opr1oid == InvalidOid)
elog(ERROR, "no > operator for opclass %u", opclass);
}
......@@ -2210,7 +2229,8 @@ network_prefix_quals(Node *leftop, Oid expr_op, Oid opclass, Datum rightop)
/* create clause "key <= network_scan_last( rightop )" */
opr2oid = get_opclass_member(opclass, BTLessEqualStrategyNumber);
opr2oid = get_opclass_member(opclass, InvalidOid,
BTLessEqualStrategyNumber);
if (opr2oid == InvalidOid)
elog(ERROR, "no <= operator for opclass %u", opclass);
......
......@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.158 2003/11/09 21:30:36 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.159 2003/11/12 21:15:53 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -63,13 +63,15 @@ static HashJoin *create_hashjoin_plan(Query *root, HashPath *best_path,
static void fix_indxqual_references(List *indexquals, IndexPath *index_path,
List **fixed_indexquals,
List **recheck_indexquals,
List **indxstrategy);
List **indxstrategy,
List **indxsubtype);
static void fix_indxqual_sublist(List *indexqual,
Relids baserelids, int baserelid,
IndexOptInfo *index,
List **fixed_quals,
List **recheck_quals,
List **strategy);
List **strategy,
List **subtype);
static Node *fix_indxqual_operand(Node *node, int baserelid,
IndexOptInfo *index,
Oid *opclass);
......@@ -79,8 +81,8 @@ static void copy_path_costsize(Plan *dest, Path *src);
static void copy_plan_costsize(Plan *dest, Plan *src);
static SeqScan *make_seqscan(List *qptlist, List *qpqual, Index scanrelid);
static IndexScan *make_indexscan(List *qptlist, List *qpqual, Index scanrelid,
List *indxid, List *indxqual,
List *indxqualorig, List *indxstrategy,
List *indxid, List *indxqual, List *indxqualorig,
List *indxstrategy, List *indxsubtype,
ScanDirection indexscandir);
static TidScan *make_tidscan(List *qptlist, List *qpqual, Index scanrelid,
List *tideval);
......@@ -704,6 +706,7 @@ create_indexscan_plan(Query *root,
List *fixed_indxqual;
List *recheck_indxqual;
List *indxstrategy;
List *indxsubtype;
FastList indexids;
List *ixinfo;
IndexScan *scan_plan;
......@@ -771,7 +774,7 @@ create_indexscan_plan(Query *root,
*/
fix_indxqual_references(indxqual, best_path,
&fixed_indxqual, &recheck_indxqual,
&indxstrategy);
&indxstrategy, &indxsubtype);
/*
* If there were any "lossy" operators, need to add back the
......@@ -804,6 +807,7 @@ create_indexscan_plan(Query *root,
fixed_indxqual,
indxqual,
indxstrategy,
indxsubtype,
best_path->indexscandir);
copy_path_costsize(&scan_plan->scan.plan, &best_path->path);
......@@ -1151,8 +1155,8 @@ create_hashjoin_plan(Query *root,
* must add (the original form of) the indexqual clause to the "qpquals"
* of the indexscan node, where the operator will be re-evaluated to
* ensure it passes.
* * We must construct a list of operator strategy numbers corresponding
* to the top-level operators of each index clause.
* * We must construct lists of operator strategy numbers and subtypes for
* the top-level operators of each index clause.
*
* Both the input list and the output lists have the form of lists of sublists
* of qual clauses --- the top-level list has one entry for each indexscan
......@@ -1167,11 +1171,12 @@ create_hashjoin_plan(Query *root,
* need rechecking.
*
* indxstrategy receives a list of integer sublists of strategy numbers.
* indxsubtype receives a list of OID sublists of strategy subtypes.
*/
static void
fix_indxqual_references(List *indexquals, IndexPath *index_path,
List **fixed_indexquals, List **recheck_indexquals,
List **indxstrategy)
List **indxstrategy, List **indxsubtype)
{
FastList fixed_quals;
FastList recheck_quals;
......@@ -1183,6 +1188,7 @@ fix_indxqual_references(List *indexquals, IndexPath *index_path,
FastListInit(&fixed_quals);
FastListInit(&recheck_quals);
*indxstrategy = NIL;
*indxsubtype = NIL;
foreach(i, indexquals)
{
List *indexqual = lfirst(i);
......@@ -1190,13 +1196,16 @@ fix_indxqual_references(List *indexquals, IndexPath *index_path,
List *fixed_qual;
List *recheck_qual;
List *strategy;
List *subtype;
fix_indxqual_sublist(indexqual, baserelids, baserelid, index,
&fixed_qual, &recheck_qual, &strategy);
&fixed_qual, &recheck_qual,
&strategy, &subtype);
FastAppend(&fixed_quals, fixed_qual);
if (recheck_qual != NIL)
FastAppend(&recheck_quals, recheck_qual);
*indxstrategy = lappend(*indxstrategy, strategy);
*indxsubtype = lappend(*indxsubtype, subtype);
ixinfo = lnext(ixinfo);
}
......@@ -1211,12 +1220,15 @@ fix_indxqual_references(List *indexquals, IndexPath *index_path,
* For each qual clause, commute if needed to put the indexkey operand on the
* left, and then fix its varattno. (We do not need to change the other side
* of the clause.) Also change the operator if necessary, check for
* lossy index behavior, and determine the operator's strategy number.
* lossy index behavior, and determine the operator's strategy number and
* subtype number.
*
* Returns three lists: the list of fixed indexquals, the list (usually
* empty) of original clauses that must be rechecked as qpquals because
* the index is lossy for this operator type, and the integer list of
* strategy numbers.
* Returns four lists:
* the list of fixed indexquals
* the list (usually empty) of original clauses that must be rechecked
* as qpquals because the index is lossy for this operator type
* the integer list of strategy numbers
* the OID list of strategy subtypes
*/
static void
fix_indxqual_sublist(List *indexqual,
......@@ -1224,7 +1236,8 @@ fix_indxqual_sublist(List *indexqual,
IndexOptInfo *index,
List **fixed_quals,
List **recheck_quals,
List **strategy)
List **strategy,
List **subtype)
{
FastList fixed_qual;
FastList recheck_qual;
......@@ -1233,6 +1246,7 @@ fix_indxqual_sublist(List *indexqual,
FastListInit(&fixed_qual);
FastListInit(&recheck_qual);
*strategy = NIL;
*subtype = NIL;
foreach(i, indexqual)
{
OpExpr *clause = (OpExpr *) lfirst(i);
......@@ -1240,6 +1254,7 @@ fix_indxqual_sublist(List *indexqual,
Relids leftvarnos;
Oid opclass;
int stratno;
Oid stratsubtype;
bool recheck;
if (!IsA(clause, OpExpr) ||
......@@ -1278,13 +1293,14 @@ fix_indxqual_sublist(List *indexqual,
/*
* Look up the operator in the operator class to get its strategy
* number and the recheck indicator. This also double-checks that
* numbers and the recheck indicator. This also double-checks that
* we found an operator matching the index.
*/
get_op_opclass_properties(newclause->opno, opclass,
&stratno, &recheck);
&stratno, &stratsubtype, &recheck);
*strategy = lappendi(*strategy, stratno);
*subtype = lappendo(*subtype, stratsubtype);
/*
* If index is lossy for this operator, add (a copy of) original form
......@@ -1540,6 +1556,7 @@ make_indexscan(List *qptlist,
List *indxqual,
List *indxqualorig,
List *indxstrategy,
List *indxsubtype,
ScanDirection indexscandir)
{
IndexScan *node = makeNode(IndexScan);
......@@ -1555,6 +1572,7 @@ make_indexscan(List *qptlist,
node->indxqual = indxqual;
node->indxqualorig = indxqualorig;
node->indxstrategy = indxstrategy;
node->indxsubtype = indxsubtype;
node->indxorderdir = indexscandir;
return node;
......
......@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.88 2003/11/09 21:30:37 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.89 2003/11/12 21:15:54 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -23,7 +23,6 @@
#include "catalog/pg_amop.h"
#include "catalog/pg_inherits.h"
#include "catalog/pg_index.h"
#include "catalog/pg_type.h"
#include "nodes/makefuncs.h"
#include "optimizer/clauses.h"
#include "optimizer/plancat.h"
......@@ -329,10 +328,10 @@ find_inheritance_children(Oid inhparent)
if (!has_subclass(inhparent))
return NIL;
ScanKeyEntryInitialize(&key[0], 0,
Anum_pg_inherits_inhparent,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(inhparent), OIDOID);
ScanKeyInit(&key[0],
Anum_pg_inherits_inhparent,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(inhparent));
relation = heap_openr(InheritsRelationName, AccessShareLock);
scan = heap_beginscan(relation, SnapshotNow, 1, key);
while ((inheritsTuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.162 2003/11/09 21:30:37 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.163 2003/11/12 21:15:54 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -1039,10 +1039,10 @@ find_inheritors(Oid relid, Oid **supervec)
{
/* find all types this relid inherits from, and add them to queue */
ScanKeyEntryInitialize(&skey, 0,
Anum_pg_inherits_inhrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(relid), OIDOID);
ScanKeyInit(&skey,
Anum_pg_inherits_inhrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(relid));
inhscan = heap_beginscan(inhrel, SnapshotNow, 1, &skey);
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteRemove.c,v 1.57 2003/11/09 21:30:37 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteRemove.c,v 1.58 2003/11/12 21:15:54 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -20,7 +20,6 @@
#include "catalog/dependency.h"
#include "catalog/indexing.h"
#include "catalog/pg_rewrite.h"
#include "catalog/pg_type.h"
#include "miscadmin.h"
#include "rewrite/rewriteRemove.h"
#include "rewrite/rewriteSupport.h"
......@@ -105,10 +104,10 @@ RemoveRewriteRuleById(Oid ruleOid)
/*
* Find the tuple for the target rule.
*/
ScanKeyEntryInitialize(&skey[0], 0,
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(ruleOid), OIDOID);
ScanKeyInit(&skey[0],
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(ruleOid));
rcscan = systable_beginscan(RewriteRelation, RewriteOidIndex, true,
SnapshotNow, 1, skey);
......
......@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.99 2003/11/09 21:30:37 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.100 2003/11/12 21:15:54 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -202,10 +202,10 @@ inv_getsize(LargeObjectDesc *obj_desc)
Assert(PointerIsValid(obj_desc));
ScanKeyEntryInitialize(&skey[0], 0,
Anum_pg_largeobject_loid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(obj_desc->id), OIDOID);
ScanKeyInit(&skey[0],
Anum_pg_largeobject_loid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(obj_desc->id));
sd = index_beginscan(obj_desc->heap_r, obj_desc->index_r,
SnapshotNow, 1, skey);
......@@ -306,15 +306,15 @@ inv_read(LargeObjectDesc *obj_desc, char *buf, int nbytes)
if (nbytes <= 0)
return 0;
ScanKeyEntryInitialize(&skey[0], 0,
Anum_pg_largeobject_loid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(obj_desc->id), OIDOID);
ScanKeyInit(&skey[0],
Anum_pg_largeobject_loid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(obj_desc->id));
ScanKeyEntryInitialize(&skey[1], 0,
Anum_pg_largeobject_pageno,
BTGreaterEqualStrategyNumber, F_INT4GE,
Int32GetDatum(pageno), INT4OID);
ScanKeyInit(&skey[1],
Anum_pg_largeobject_pageno,
BTGreaterEqualStrategyNumber, F_INT4GE,
Int32GetDatum(pageno));
sd = index_beginscan(obj_desc->heap_r, obj_desc->index_r,
SnapshotNow, 2, skey);
......@@ -413,15 +413,15 @@ inv_write(LargeObjectDesc *obj_desc, char *buf, int nbytes)
indstate = CatalogOpenIndexes(obj_desc->heap_r);
ScanKeyEntryInitialize(&skey[0], 0,
Anum_pg_largeobject_loid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(obj_desc->id), OIDOID);
ScanKeyInit(&skey[0],
Anum_pg_largeobject_loid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(obj_desc->id));
ScanKeyEntryInitialize(&skey[1], 0,
Anum_pg_largeobject_pageno,
BTGreaterEqualStrategyNumber, F_INT4GE,
Int32GetDatum(pageno), INT4OID);
ScanKeyInit(&skey[1],
Anum_pg_largeobject_pageno,
BTGreaterEqualStrategyNumber, F_INT4GE,
Int32GetDatum(pageno));
sd = index_beginscan(obj_desc->heap_r, obj_desc->index_r,
SnapshotNow, 2, skey);
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.94 2003/09/25 06:58:03 petere Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.95 2003/11/12 21:15:54 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -839,6 +839,26 @@ btfloat8cmp(PG_FUNCTION_ARGS)
PG_RETURN_INT32(float8_cmp_internal(arg1, arg2));
}
Datum
btfloat48cmp(PG_FUNCTION_ARGS)
{
float4 arg1 = PG_GETARG_FLOAT4(0);
float8 arg2 = PG_GETARG_FLOAT8(1);
/* widen float4 to float8 and then compare */
PG_RETURN_INT32(float8_cmp_internal(arg1, arg2));
}
Datum
btfloat84cmp(PG_FUNCTION_ARGS)
{
float8 arg1 = PG_GETARG_FLOAT8(0);
float4 arg2 = PG_GETARG_FLOAT4(1);
/* widen float4 to float8 and then compare */
PG_RETURN_INT32(float8_cmp_internal(arg1, arg2));
}
/*
* ===================
......
......@@ -13,7 +13,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.83 2003/11/09 21:30:37 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.84 2003/11/12 21:15:54 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -92,10 +92,10 @@ regprocin(PG_FUNCTION_ARGS)
SysScanDesc sysscan;
HeapTuple tuple;
ScanKeyEntryInitialize(&skey[0], 0,
Anum_pg_proc_proname,
BTEqualStrategyNumber, F_NAMEEQ,
CStringGetDatum(pro_name_or_oid), NAMEOID);
ScanKeyInit(&skey[0],
Anum_pg_proc_proname,
BTEqualStrategyNumber, F_NAMEEQ,
CStringGetDatum(pro_name_or_oid));
hdesc = heap_openr(ProcedureRelationName, AccessShareLock);
sysscan = systable_beginscan(hdesc, ProcedureNameNspIndex, true,
......@@ -442,10 +442,10 @@ regoperin(PG_FUNCTION_ARGS)
SysScanDesc sysscan;
HeapTuple tuple;
ScanKeyEntryInitialize(&skey[0], 0,
Anum_pg_operator_oprname,
BTEqualStrategyNumber, F_NAMEEQ,
CStringGetDatum(opr_name_or_oid), NAMEOID);
ScanKeyInit(&skey[0],
Anum_pg_operator_oprname,
BTEqualStrategyNumber, F_NAMEEQ,
CStringGetDatum(opr_name_or_oid));
hdesc = heap_openr(OperatorRelationName, AccessShareLock);
sysscan = systable_beginscan(hdesc, OperatorNameNspIndex, true,
......@@ -820,10 +820,10 @@ regclassin(PG_FUNCTION_ARGS)
SysScanDesc sysscan;
HeapTuple tuple;
ScanKeyEntryInitialize(&skey[0], 0,
Anum_pg_class_relname,
BTEqualStrategyNumber, F_NAMEEQ,
CStringGetDatum(class_name_or_oid), NAMEOID);
ScanKeyInit(&skey[0],
Anum_pg_class_relname,
BTEqualStrategyNumber, F_NAMEEQ,
CStringGetDatum(class_name_or_oid));
hdesc = heap_openr(RelationRelationName, AccessShareLock);
sysscan = systable_beginscan(hdesc, ClassNameNspIndex, true,
......@@ -986,10 +986,10 @@ regtypein(PG_FUNCTION_ARGS)
SysScanDesc sysscan;
HeapTuple tuple;
ScanKeyEntryInitialize(&skey[0], 0,
Anum_pg_type_typname,
BTEqualStrategyNumber, F_NAMEEQ,
CStringGetDatum(typ_name_or_oid), NAMEOID);
ScanKeyInit(&skey[0],
Anum_pg_type_typname,
BTEqualStrategyNumber, F_NAMEEQ,
CStringGetDatum(typ_name_or_oid));
hdesc = heap_openr(TypeRelationName, AccessShareLock);
sysscan = systable_beginscan(hdesc, TypeNameNspIndex, true,
......
......@@ -3,7 +3,7 @@
* back to source text
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.158 2003/11/09 21:30:37 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.159 2003/11/12 21:15:55 tgl Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
......@@ -488,10 +488,10 @@ pg_get_triggerdef(PG_FUNCTION_ARGS)
*/
tgrel = heap_openr(TriggerRelationName, AccessShareLock);
ScanKeyEntryInitialize(&skey[0], 0,
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(trigid), OIDOID);
ScanKeyInit(&skey[0],
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(trigid));
tgscan = systable_beginscan(tgrel, TriggerOidIndex, true,
SnapshotNow, 1, skey);
......@@ -886,10 +886,10 @@ pg_get_constraintdef_worker(Oid constraintId, int prettyFlags)
*/
conDesc = heap_openr(ConstraintRelationName, AccessShareLock);
ScanKeyEntryInitialize(&skey[0], 0,
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(constraintId), OIDOID);
ScanKeyInit(&skey[0],
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(constraintId));
conscan = systable_beginscan(conDesc, ConstraintOidIndex, true,
SnapshotNow, 1, skey);
......
......@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.147 2003/10/16 21:37:54 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.148 2003/11/12 21:15:55 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -952,7 +952,8 @@ patternsel(PG_FUNCTION_ARGS, Pattern_Type ptype)
/*
* Pattern specifies an exact match, so pretend operator is '='
*/
Oid eqopr = get_opclass_member(opclass, BTEqualStrategyNumber);
Oid eqopr = get_opclass_member(opclass, InvalidOid,
BTEqualStrategyNumber);
List *eqargs;
if (eqopr == InvalidOid)
......@@ -3382,7 +3383,8 @@ prefix_selectivity(Query *root, Var *var, Oid opclass, Const *prefixcon)
List *cmpargs;
Const *greaterstrcon;
cmpopr = get_opclass_member(opclass, BTGreaterEqualStrategyNumber);
cmpopr = get_opclass_member(opclass, InvalidOid,
BTGreaterEqualStrategyNumber);
if (cmpopr == InvalidOid)
elog(ERROR, "no >= operator for opclass %u", opclass);
cmpargs = makeList2(var, prefixcon);
......@@ -3403,7 +3405,8 @@ prefix_selectivity(Query *root, Var *var, Oid opclass, Const *prefixcon)
{
Selectivity topsel;
cmpopr = get_opclass_member(opclass, BTLessStrategyNumber);
cmpopr = get_opclass_member(opclass, InvalidOid,
BTLessStrategyNumber);
if (cmpopr == InvalidOid)
elog(ERROR, "no < operator for opclass %u", opclass);
cmpargs = makeList2(var, greaterstrcon);
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.109 2003/11/09 21:30:37 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.110 2003/11/12 21:15:55 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -967,9 +967,9 @@ CatalogCacheInitializeCache(CatCache *cache)
/* Initialize sk_attno suitably for HeapKeyTest() and heap scans */
cache->cc_skey[i].sk_attno = cache->cc_key[i];
/* Fill in sk_strategy and sk_argtype correctly as well */
/* Fill in sk_strategy as well --- always standard equality */
cache->cc_skey[i].sk_strategy = BTEqualStrategyNumber;
cache->cc_skey[i].sk_argtype = keytype;
cache->cc_skey[i].sk_subtype = InvalidOid;
CACHE4_elog(DEBUG2, "CatalogCacheInit %s %d %p",
cache->cc_relname,
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.109 2003/11/09 21:30:37 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.110 2003/11/12 21:15:55 tgl Exp $
*
* NOTES
* Eventually, the index information should go through here, too.
......@@ -55,7 +55,7 @@ op_in_opclass(Oid opno, Oid opclass)
/*
* get_op_opclass_properties
*
* Get the operator's strategy number and recheck (lossy) flag
* Get the operator's strategy number, subtype, and recheck (lossy) flag
* within the specified opclass.
*
* Caller should already have verified that opno is a member of opclass,
......@@ -63,7 +63,7 @@ op_in_opclass(Oid opno, Oid opclass)
*/
void
get_op_opclass_properties(Oid opno, Oid opclass,
int *strategy, bool *recheck)
int *strategy, Oid *subtype, bool *recheck)
{
HeapTuple tp;
Form_pg_amop amop_tup;
......@@ -77,6 +77,7 @@ get_op_opclass_properties(Oid opno, Oid opclass,
opno, opclass);
amop_tup = (Form_pg_amop) GETSTRUCT(tp);
*strategy = amop_tup->amopstrategy;
*subtype = amop_tup->amopsubtype;
*recheck = amop_tup->amopreqcheck;
ReleaseSysCache(tp);
}
......@@ -84,12 +85,12 @@ get_op_opclass_properties(Oid opno, Oid opclass,
/*
* get_opclass_member
* Get the OID of the operator that implements the specified strategy
* for the specified opclass.
* with the specified subtype for the specified opclass.
*
* Returns InvalidOid if there is no pg_amop entry for the given keys.
*/
Oid
get_opclass_member(Oid opclass, int16 strategy)
get_opclass_member(Oid opclass, Oid subtype, int16 strategy)
{
HeapTuple tp;
Form_pg_amop amop_tup;
......@@ -97,8 +98,9 @@ get_opclass_member(Oid opclass, int16 strategy)
tp = SearchSysCache(AMOPSTRATEGY,
ObjectIdGetDatum(opclass),
ObjectIdGetDatum(subtype),
Int16GetDatum(strategy),
0, 0);
0);
if (!HeapTupleIsValid(tp))
return InvalidOid;
amop_tup = (Form_pg_amop) GETSTRUCT(tp);
......@@ -149,8 +151,8 @@ get_op_hash_function(Oid opno)
if (OidIsValid(opclass))
{
/* Found a suitable opclass, get its hash support function */
return get_opclass_proc(opclass, HASHPROC);
/* Found a suitable opclass, get its default hash support function */
return get_opclass_proc(opclass, InvalidOid, HASHPROC);
}
/* Didn't find a match... */
......@@ -163,12 +165,12 @@ get_op_hash_function(Oid opno)
/*
* get_opclass_proc
* Get the OID of the specified support function
* for the specified opclass.
* for the specified opclass and subtype.
*
* Returns InvalidOid if there is no pg_amproc entry for the given keys.
*/
Oid
get_opclass_proc(Oid opclass, int16 procnum)
get_opclass_proc(Oid opclass, Oid subtype, int16 procnum)
{
HeapTuple tp;
Form_pg_amproc amproc_tup;
......@@ -176,8 +178,9 @@ get_opclass_proc(Oid opclass, int16 procnum)
tp = SearchSysCache(AMPROCNUM,
ObjectIdGetDatum(opclass),
ObjectIdGetDatum(subtype),
Int16GetDatum(procnum),
0, 0);
0);
if (!HeapTupleIsValid(tp))
return InvalidOid;
amproc_tup = (Form_pg_amproc) GETSTRUCT(tp);
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.191 2003/11/09 21:30:37 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.192 2003/11/12 21:15:56 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -262,7 +262,7 @@ do { \
/*
* Special cache for opclass-related information
*
* Note: only non-cross-type operators and support procs get cached
* Note: only default-subtype operators and support procs get cached
*/
typedef struct opclasscacheent
{
......@@ -336,26 +336,23 @@ ScanPgRelation(RelationBuildDescInfo buildinfo, bool indexOK)
switch (buildinfo.infotype)
{
case INFO_RELID:
ScanKeyEntryInitialize(&key[0], 0,
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(buildinfo.i.info_id),
OIDOID);
ScanKeyInit(&key[0],
ObjectIdAttributeNumber,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(buildinfo.i.info_id));
nkeys = 1;
indexRelname = ClassOidIndex;
break;
case INFO_RELNAME:
ScanKeyEntryInitialize(&key[0], 0,
Anum_pg_class_relname,
BTEqualStrategyNumber, F_NAMEEQ,
NameGetDatum(buildinfo.i.info_name),
NAMEOID);
ScanKeyEntryInitialize(&key[1], 0,
Anum_pg_class_relnamespace,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(PG_CATALOG_NAMESPACE),
OIDOID);
ScanKeyInit(&key[0],
Anum_pg_class_relname,
BTEqualStrategyNumber, F_NAMEEQ,
NameGetDatum(buildinfo.i.info_name));
ScanKeyInit(&key[1],
Anum_pg_class_relnamespace,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(PG_CATALOG_NAMESPACE));
nkeys = 2;
indexRelname = ClassNameNspIndex;
break;
......@@ -483,15 +480,14 @@ RelationBuildTupleDesc(RelationBuildDescInfo buildinfo,
* (Eliminating system attribute rows at the index level is lots
* faster than fetching them.)
*/
ScanKeyEntryInitialize(&skey[0], 0,
Anum_pg_attribute_attrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(relation)),
OIDOID);
ScanKeyEntryInitialize(&skey[1], 0,
Anum_pg_attribute_attnum,
BTGreaterStrategyNumber, F_INT2GT,
Int16GetDatum(0), INT2OID);
ScanKeyInit(&skey[0],
Anum_pg_attribute_attrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(relation)));
ScanKeyInit(&skey[1],
Anum_pg_attribute_attnum,
BTGreaterStrategyNumber, F_INT2GT,
Int16GetDatum(0));
/*
* Open pg_attribute and begin a scan. Force heap scan if we haven't
......@@ -673,11 +669,10 @@ RelationBuildRuleLock(Relation relation)
/*
* form a scan key
*/
ScanKeyEntryInitialize(&key, 0,
Anum_pg_rewrite_ev_class,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(relation)),
OIDOID);
ScanKeyInit(&key,
Anum_pg_rewrite_ev_class,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(relation)));
/*
* open pg_rewrite and begin a scan
......@@ -1058,7 +1053,7 @@ RelationInitIndexAccessInfo(Relation relation)
/*
* IndexSupportInitialize
* Initializes an index's cached lists of operators and support procs,
* Initializes an index's cached opclass information,
* given the index's pg_index tuple.
*
* Data is returned into *indexOperator and *indexSupport, which are arrays
......@@ -1131,11 +1126,9 @@ LookupOpclassInfo(Oid operatorClassOid,
{
OpClassCacheEnt *opcentry;
bool found;
Relation pg_amop_desc;
Relation pg_amproc_desc;
SysScanDesc pg_amop_scan;
SysScanDesc pg_amproc_scan;
ScanKeyData key;
Relation rel;
SysScanDesc scan;
ScanKeyData skey[2];
HeapTuple htup;
bool indexOK;
......@@ -1191,7 +1184,7 @@ LookupOpclassInfo(Oid operatorClassOid,
opcentry->supportProcs = NULL;
/*
* To avoid infinite recursion during startup, force a heap scan if
* To avoid infinite recursion during startup, force heap scans if
* we're looking up info for the opclasses used by the indexes we
* would like to reference here.
*/
......@@ -1200,24 +1193,25 @@ LookupOpclassInfo(Oid operatorClassOid,
operatorClassOid != INT2_BTREE_OPS_OID);
/*
* Scan pg_amop to obtain operators for the opclass
* Scan pg_amop to obtain operators for the opclass. We only fetch
* the default ones (those with subtype zero).
*/
if (numStrats > 0)
{
ScanKeyEntryInitialize(&key, 0,
Anum_pg_amop_amopclaid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(operatorClassOid),
OIDOID);
pg_amop_desc = heap_openr(AccessMethodOperatorRelationName,
AccessShareLock);
pg_amop_scan = systable_beginscan(pg_amop_desc,
AccessMethodStrategyIndex,
indexOK,
SnapshotNow,
1, &key);
while (HeapTupleIsValid(htup = systable_getnext(pg_amop_scan)))
ScanKeyInit(&skey[0],
Anum_pg_amop_amopclaid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(operatorClassOid));
ScanKeyInit(&skey[1],
Anum_pg_amop_amopsubtype,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(InvalidOid));
rel = heap_openr(AccessMethodOperatorRelationName,
AccessShareLock);
scan = systable_beginscan(rel, AccessMethodStrategyIndex, indexOK,
SnapshotNow, 2, skey);
while (HeapTupleIsValid(htup = systable_getnext(scan)))
{
Form_pg_amop amopform = (Form_pg_amop) GETSTRUCT(htup);
......@@ -1229,29 +1223,30 @@ LookupOpclassInfo(Oid operatorClassOid,
amopform->amopopr;
}
systable_endscan(pg_amop_scan);
heap_close(pg_amop_desc, AccessShareLock);
systable_endscan(scan);
heap_close(rel, AccessShareLock);
}
/*
* Scan pg_amproc to obtain support procs for the opclass
* Scan pg_amproc to obtain support procs for the opclass. We only fetch
* the default ones (those with subtype zero).
*/
if (numSupport > 0)
{
ScanKeyEntryInitialize(&key, 0,
Anum_pg_amproc_amopclaid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(operatorClassOid),
OIDOID);
pg_amproc_desc = heap_openr(AccessMethodProcedureRelationName,
AccessShareLock);
pg_amproc_scan = systable_beginscan(pg_amproc_desc,
AccessMethodProcedureIndex,
indexOK,
SnapshotNow,
1, &key);
while (HeapTupleIsValid(htup = systable_getnext(pg_amproc_scan)))
ScanKeyInit(&skey[0],
Anum_pg_amproc_amopclaid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(operatorClassOid));
ScanKeyInit(&skey[1],
Anum_pg_amproc_amprocsubtype,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(InvalidOid));
rel = heap_openr(AccessMethodProcedureRelationName,
AccessShareLock);
scan = systable_beginscan(rel, AccessMethodProcedureIndex, indexOK,
SnapshotNow, 2, skey);
while (HeapTupleIsValid(htup = systable_getnext(scan)))
{
Form_pg_amproc amprocform = (Form_pg_amproc) GETSTRUCT(htup);
......@@ -1264,8 +1259,8 @@ LookupOpclassInfo(Oid operatorClassOid,
amprocform->amproc;
}
systable_endscan(pg_amproc_scan);
heap_close(pg_amproc_desc, AccessShareLock);
systable_endscan(scan);
heap_close(rel, AccessShareLock);
}
opcentry->valid = true;
......@@ -2483,16 +2478,14 @@ AttrDefaultFetch(Relation relation)
int found;
int i;
ScanKeyEntryInitialize(&skey, 0,
Anum_pg_attrdef_adrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(relation)),
OIDOID);
ScanKeyInit(&skey,
Anum_pg_attrdef_adrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(relation)));
adrel = heap_openr(AttrDefaultRelationName, AccessShareLock);
adscan = systable_beginscan(adrel, AttrDefaultIndex, true,
SnapshotNow,
1, &skey);
SnapshotNow, 1, &skey);
found = 0;
while (HeapTupleIsValid(htup = systable_getnext(adscan)))
......@@ -2550,11 +2543,10 @@ CheckConstraintFetch(Relation relation)
bool isnull;
int found = 0;
ScanKeyEntryInitialize(&skey[0], 0,
Anum_pg_constraint_conrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(relation)),
OIDOID);
ScanKeyInit(&skey[0],
Anum_pg_constraint_conrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(relation)));
conrel = heap_openr(ConstraintRelationName, AccessShareLock);
conscan = systable_beginscan(conrel, ConstraintRelidIndex, true,
......@@ -2642,16 +2634,14 @@ RelationGetIndexList(Relation relation)
result = NIL;
/* Prepare to scan pg_index for entries having indrelid = this rel. */
ScanKeyEntryInitialize(&skey, 0,
Anum_pg_index_indrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(relation)),
OIDOID);
ScanKeyInit(&skey,
Anum_pg_index_indrelid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(relation)));
indrel = heap_openr(IndexRelationName, AccessShareLock);
indscan = systable_beginscan(indrel, IndexIndrelidIndex, true,
SnapshotNow,
1, &skey);
SnapshotNow, 1, &skey);
while (HeapTupleIsValid(htup = systable_getnext(indscan)))
{
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.91 2003/09/24 18:54:01 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.92 2003/11/12 21:15:56 tgl Exp $
*
* NOTES
* These routines allow the parser/planner/executor to perform
......@@ -136,21 +136,21 @@ static const struct cachedesc cacheinfo[] = {
{AccessMethodOperatorRelationName, /* AMOPSTRATEGY */
AccessMethodStrategyIndex,
0,
2,
3,
{
Anum_pg_amop_amopclaid,
Anum_pg_amop_amopsubtype,
Anum_pg_amop_amopstrategy,
0,
0
}},
{AccessMethodProcedureRelationName, /* AMPROCNUM */
AccessMethodProcedureIndex,
0,
2,
3,
{
Anum_pg_amproc_amopclaid,
Anum_pg_amproc_amprocsubtype,
Anum_pg_amproc_amprocnum,
0,
0
}},
{AttributeRelationName, /* ATTNAME */
......
......@@ -33,7 +33,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/typcache.c,v 1.2 2003/11/09 21:30:37 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/typcache.c,v 1.3 2003/11/12 21:15:56 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -158,22 +158,26 @@ lookup_type_cache(Oid type_id, int flags)
{
if (typentry->btree_opc != InvalidOid)
typentry->eq_opr = get_opclass_member(typentry->btree_opc,
InvalidOid,
BTEqualStrategyNumber);
if (typentry->eq_opr == InvalidOid &&
typentry->hash_opc != InvalidOid)
typentry->eq_opr = get_opclass_member(typentry->hash_opc,
InvalidOid,
HTEqualStrategyNumber);
}
if ((flags & TYPECACHE_LT_OPR) && typentry->lt_opr == InvalidOid)
{
if (typentry->btree_opc != InvalidOid)
typentry->lt_opr = get_opclass_member(typentry->btree_opc,
InvalidOid,
BTLessStrategyNumber);
}
if ((flags & TYPECACHE_GT_OPR) && typentry->gt_opr == InvalidOid)
{
if (typentry->btree_opc != InvalidOid)
typentry->gt_opr = get_opclass_member(typentry->btree_opc,
InvalidOid,
BTGreaterStrategyNumber);
}
if ((flags & (TYPECACHE_CMP_PROC | TYPECACHE_CMP_PROC_FINFO)) &&
......@@ -181,6 +185,7 @@ lookup_type_cache(Oid type_id, int flags)
{
if (typentry->btree_opc != InvalidOid)
typentry->cmp_proc = get_opclass_proc(typentry->btree_opc,
InvalidOid,
BTORDER_PROC);
}
......@@ -248,10 +253,10 @@ lookup_default_opclass(Oid type_id, Oid am_id)
*/
rel = heap_openr(OperatorClassRelationName, AccessShareLock);
ScanKeyEntryInitialize(&skey[0], 0,
Anum_pg_opclass_opcamid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(am_id), OIDOID);
ScanKeyInit(&skey[0],
Anum_pg_opclass_opcamid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(am_id));
scan = systable_beginscan(rel, OpclassAmNameNspIndex, true,
SnapshotNow, 1, skey);
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.128 2003/11/09 21:30:37 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.129 2003/11/12 21:15:56 tgl Exp $
*
*
*-------------------------------------------------------------------------
......@@ -26,7 +26,6 @@
#include "catalog/namespace.h"
#include "catalog/pg_database.h"
#include "catalog/pg_shadow.h"
#include "catalog/pg_type.h"
#include "commands/trigger.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
......@@ -92,10 +91,10 @@ ReverifyMyDatabase(const char *name)
*/
pgdbrel = heap_openr(DatabaseRelationName, AccessShareLock);
ScanKeyEntryInitialize(&key, 0,
Anum_pg_database_datname,
BTEqualStrategyNumber, F_NAMEEQ,
NameGetDatum(name), NAMEOID);
ScanKeyInit(&key,
Anum_pg_database_datname,
BTEqualStrategyNumber, F_NAMEEQ,
NameGetDatum(name));
pgdbscan = heap_beginscan(pgdbrel, SnapshotNow, 1, &key);
......
......@@ -78,7 +78,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplesort.c,v 1.38 2003/11/09 21:30:37 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplesort.c,v 1.39 2003/11/12 21:15:56 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -472,15 +472,14 @@ tuplesort_begin_heap(TupleDesc tupDesc,
&state->sortFnKinds[i]);
/*
* We needn't fill in sk_strategy or sk_argtype since these scankeys
* We needn't fill in sk_strategy or sk_subtype since these scankeys
* will never be passed to an index.
*/
ScanKeyEntryInitialize(&state->scanKeys[i], 0,
attNums[i],
InvalidStrategy,
sortFunction,
(Datum) 0,
InvalidOid);
ScanKeyInit(&state->scanKeys[i],
attNums[i],
InvalidStrategy,
sortFunction,
(Datum) 0);
}
return state;
......@@ -1739,6 +1738,10 @@ SelectSortFunction(Oid sortOperator,
if (!opclass_is_btree(aform->amopclaid))
continue;
/* must be of default subtype, too */
if (aform->amopsubtype != InvalidOid)
continue;
if (aform->amopstrategy == BTLessStrategyNumber)
{
opclass = aform->amopclaid;
......@@ -1757,8 +1760,8 @@ SelectSortFunction(Oid sortOperator,
if (OidIsValid(opclass))
{
/* Found a suitable opclass, get its comparator support function */
*sortFunction = get_opclass_proc(opclass, BTORDER_PROC);
/* Found a suitable opclass, get its default comparator function */
*sortFunction = get_opclass_proc(opclass, InvalidOid, BTORDER_PROC);
Assert(RegProcedureIsValid(*sortFunction));
return;
}
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: nbtree.h,v 1.72 2003/11/09 21:30:37 tgl Exp $
* $Id: nbtree.h,v 1.73 2003/11/12 21:15:57 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -341,7 +341,7 @@ typedef struct xl_btree_newpage
/*
* Operator strategy numbers for B-tree have been moved to access/skey.h,
* because many places need to use them in ScanKeyEntryInitialize() calls.
* because many places need to use them in ScanKeyInit() calls.
*/
/*
......@@ -404,12 +404,12 @@ typedef struct BTScanOpaqueData
Buffer btso_mrkbuf;
ItemPointerData curHeapIptr;
ItemPointerData mrkHeapIptr;
/* these fields are set by _bt_orderkeys(), which see for more info: */
/* these fields are set by _bt_preprocess_keys(): */
bool qual_ok; /* false if qual can never be satisfied */
int numberOfKeys; /* number of scan keys */
int numberOfKeys; /* number of preprocessed scan keys */
int numberOfRequiredKeys; /* number of keys that must be
* matched to continue the scan */
ScanKey keyData; /* array of scan keys */
ScanKey keyData; /* array of preprocessed scan keys */
} BTScanOpaqueData;
typedef BTScanOpaqueData *BTScanOpaque;
......@@ -424,7 +424,6 @@ extern Datum btinsert(PG_FUNCTION_ARGS);
extern Datum btgettuple(PG_FUNCTION_ARGS);
extern Datum btbeginscan(PG_FUNCTION_ARGS);
extern Datum btrescan(PG_FUNCTION_ARGS);
extern void btmovescan(IndexScanDesc scan, Datum v);
extern Datum btendscan(PG_FUNCTION_ARGS);
extern Datum btmarkpos(PG_FUNCTION_ARGS);
extern Datum btrestrpos(PG_FUNCTION_ARGS);
......@@ -480,7 +479,7 @@ extern ScanKey _bt_mkscankey(Relation rel, IndexTuple itup);
extern ScanKey _bt_mkscankey_nodata(Relation rel);
extern void _bt_freeskey(ScanKey skey);
extern void _bt_freestack(BTStack stack);
extern void _bt_orderkeys(IndexScanDesc scan);
extern void _bt_preprocess_keys(IndexScanDesc scan);
extern bool _bt_checkkeys(IndexScanDesc scan, IndexTuple tuple,
ScanDirection dir, bool *continuescan);
extern BTItem _bt_formitem(IndexTuple itup);
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: skey.h,v 1.23 2003/11/09 21:30:37 tgl Exp $
* $Id: skey.h,v 1.24 2003/11/12 21:15:57 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -20,7 +20,8 @@
/*
* Strategy numbers identify the semantics that particular operators have
* with respect to particular operator classes.
* with respect to particular operator classes. In some cases a strategy
* subtype (an OID) is used as further information.
*/
typedef uint16 StrategyNumber;
......@@ -47,23 +48,23 @@ typedef uint16 StrategyNumber;
* (The data structure can support unary indexable operators too; in that
* case sk_argument would go unused. This is not currently implemented.)
*
* For an index scan, sk_strategy must be set correctly for the operator.
* When using a ScanKey in a heap scan, sk_strategy is not used and may be
* set to InvalidStrategy.
* For an index scan, sk_strategy and sk_subtype must be set correctly for
* the operator. When using a ScanKey in a heap scan, these fields are not
* used and may be set to InvalidStrategy/InvalidOid.
*
* Note: in some places, ScanKeys are used as a convenient representation
* for the invocation of an access method support procedure. In this case
* sk_strategy is not meaningful, and sk_func may refer to a function that
* returns something other than boolean.
* sk_strategy/sk_subtype are not meaningful, and sk_func may refer to a
* function that returns something other than boolean.
*/
typedef struct ScanKeyData
{
int sk_flags; /* flags, see below */
AttrNumber sk_attno; /* table or index column number */
StrategyNumber sk_strategy; /* operator strategy number */
Oid sk_subtype; /* strategy subtype */
FmgrInfo sk_func; /* lookup info for function to call */
Datum sk_argument; /* data to compare */
Oid sk_argtype; /* datatype of sk_argument */
} ScanKeyData;
typedef ScanKeyData *ScanKey;
......@@ -76,19 +77,24 @@ typedef ScanKeyData *ScanKey;
/*
* prototypes for functions in access/common/scankey.c
*/
extern void ScanKeyInit(ScanKey entry,
AttrNumber attributeNumber,
StrategyNumber strategy,
RegProcedure procedure,
Datum argument);
extern void ScanKeyEntryInitialize(ScanKey entry,
int flags,
AttrNumber attributeNumber,
StrategyNumber strategy,
Oid subtype,
RegProcedure procedure,
Datum argument,
Oid argtype);
Datum argument);
extern void ScanKeyEntryInitializeWithInfo(ScanKey entry,
int flags,
AttrNumber attributeNumber,
StrategyNumber strategy,
Oid subtype,
FmgrInfo *finfo,
Datum argument,
Oid argtype);
Datum argument);
#endif /* SKEY_H */
......@@ -37,7 +37,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: catversion.h,v 1.210 2003/10/21 16:23:16 tgl Exp $
* $Id: catversion.h,v 1.211 2003/11/12 21:15:57 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
#define CATALOG_VERSION_NO 200310211
#define CATALOG_VERSION_NO 200311101
#endif
......@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: indexing.h,v 1.79 2003/08/04 02:40:10 momjian Exp $
* $Id: indexing.h,v 1.80 2003/11/12 21:15:57 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -24,8 +24,8 @@
* macros rather than hardwiring the actual index name.
*/
#define AccessMethodOperatorIndex "pg_amop_opr_opc_index"
#define AccessMethodStrategyIndex "pg_amop_opc_strategy_index"
#define AccessMethodProcedureIndex "pg_amproc_opc_procnum_index"
#define AccessMethodStrategyIndex "pg_amop_opc_strat_index"
#define AccessMethodProcedureIndex "pg_amproc_opc_proc_index"
#define AggregateFnoidIndex "pg_aggregate_fnoid_index"
#define AmNameIndex "pg_am_name_index"
#define AmOidIndex "pg_am_oid_index"
......@@ -115,9 +115,9 @@ extern void CatalogUpdateIndexes(Relation heapRel, HeapTuple heapTuple);
DECLARE_UNIQUE_INDEX(pg_aggregate_fnoid_index on pg_aggregate using btree(aggfnoid oid_ops));
DECLARE_UNIQUE_INDEX(pg_am_name_index on pg_am using btree(amname name_ops));
DECLARE_UNIQUE_INDEX(pg_am_oid_index on pg_am using btree(oid oid_ops));
DECLARE_UNIQUE_INDEX(pg_amop_opc_strat_index on pg_amop using btree(amopclaid oid_ops, amopsubtype oid_ops, amopstrategy int2_ops));
DECLARE_UNIQUE_INDEX(pg_amop_opr_opc_index on pg_amop using btree(amopopr oid_ops, amopclaid oid_ops));
DECLARE_UNIQUE_INDEX(pg_amop_opc_strategy_index on pg_amop using btree(amopclaid oid_ops, amopstrategy int2_ops));
DECLARE_UNIQUE_INDEX(pg_amproc_opc_procnum_index on pg_amproc using btree(amopclaid oid_ops, amprocnum int2_ops));
DECLARE_UNIQUE_INDEX(pg_amproc_opc_proc_index on pg_amproc using btree(amopclaid oid_ops, amprocsubtype oid_ops, amprocnum int2_ops));
DECLARE_UNIQUE_INDEX(pg_attrdef_adrelid_adnum_index on pg_attrdef using btree(adrelid oid_ops, adnum int2_ops));
DECLARE_UNIQUE_INDEX(pg_attrdef_oid_index on pg_attrdef using btree(oid oid_ops));
DECLARE_UNIQUE_INDEX(pg_attribute_relid_attnam_index on pg_attribute using btree(attrelid oid_ops, attname name_ops));
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: namespace.h,v 1.27 2003/08/04 02:40:10 momjian Exp $
* $Id: namespace.h,v 1.28 2003/11/12 21:15:57 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -42,9 +42,9 @@ typedef struct _OpclassCandidateList
char *opcname_tmp; /* for internal use of namespace lookup */
int pathpos; /* for internal use of namespace lookup */
Oid oid; /* the opclass's OID */
Oid opcintype; /* type of input data for opclass */
Oid opcintype; /* type of data indexed by opclass */
bool opcdefault; /* T if opclass is default for opcintype */
Oid opckeytype; /* type of index data, or InvalidOid */
Oid opckeytype; /* type of data in index, or InvalidOid */
} *OpclassCandidateList;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: plannodes.h,v 1.69 2003/11/09 21:30:37 tgl Exp $
* $Id: plannodes.h,v 1.70 2003/11/12 21:15:59 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -165,6 +165,7 @@ typedef struct IndexScan
List *indxqual; /* list of sublists of index quals */
List *indxqualorig; /* the same in original form */
List *indxstrategy; /* list of sublists of strategy numbers */
List *indxsubtype; /* list of sublists of strategy subtypes */
ScanDirection indxorderdir; /* forward or backward or don't care */
} IndexScan;
......
This diff is collapsed.
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: geo_decls.h,v 1.41 2003/08/04 02:40:15 momjian Exp $
* $Id: geo_decls.h,v 1.42 2003/11/12 21:15:59 tgl Exp $
*
* NOTE
* These routines do *not* use the float types from adt/.
......@@ -399,7 +399,6 @@ extern Datum circle_area(PG_FUNCTION_ARGS);
extern Datum rt_box_union(PG_FUNCTION_ARGS);
extern Datum rt_box_inter(PG_FUNCTION_ARGS);
extern Datum rt_box_size(PG_FUNCTION_ARGS);
extern Datum rt_bigbox_size(PG_FUNCTION_ARGS);
extern Datum rt_poly_size(PG_FUNCTION_ARGS);
extern Datum rt_poly_union(PG_FUNCTION_ARGS);
extern Datum rt_poly_inter(PG_FUNCTION_ARGS);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment