mirror of
https://github.com/postgres/postgres.git
synced 2025-11-09 06:21:09 +03:00
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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/opclasscmds.c,v 1.22 2003/11/09 21:30:36 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/opclasscmds.c,v 1.23 2003/11/12 21:15:50 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -25,6 +25,8 @@
|
||||
#include "catalog/pg_amop.h"
|
||||
#include "catalog/pg_amproc.h"
|
||||
#include "catalog/pg_opclass.h"
|
||||
#include "catalog/pg_operator.h"
|
||||
#include "catalog/pg_proc.h"
|
||||
#include "catalog/pg_type.h"
|
||||
#include "commands/defrem.h"
|
||||
#include "miscadmin.h"
|
||||
@@ -38,9 +40,24 @@
|
||||
#include "utils/syscache.h"
|
||||
|
||||
|
||||
static void storeOperators(Oid opclassoid, int numOperators,
|
||||
Oid *operators, bool *recheck);
|
||||
static void storeProcedures(Oid opclassoid, int numProcs, Oid *procedures);
|
||||
/*
|
||||
* We use lists of this struct type to keep track of both operators and
|
||||
* procedures during DefineOpClass.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
Oid object; /* operator or support proc's OID */
|
||||
int number; /* strategy or support proc number */
|
||||
Oid subtype; /* subtype */
|
||||
bool recheck; /* oper recheck flag (unused for proc) */
|
||||
} OpClassMember;
|
||||
|
||||
|
||||
static Oid assignOperSubtype(Oid amoid, Oid typeoid, Oid operOid);
|
||||
static Oid assignProcSubtype(Oid amoid, Oid typeoid, Oid procOid);
|
||||
static void addClassMember(List **list, OpClassMember *member, bool isProc);
|
||||
static void storeOperators(Oid opclassoid, List *operators);
|
||||
static void storeProcedures(Oid opclassoid, List *procedures);
|
||||
|
||||
|
||||
/*
|
||||
@@ -58,10 +75,9 @@ DefineOpClass(CreateOpClassStmt *stmt)
|
||||
opclassoid; /* oid of opclass we create */
|
||||
int numOperators, /* amstrategies value */
|
||||
numProcs; /* amsupport value */
|
||||
Oid *operators, /* oids of operators, by strategy num */
|
||||
*procedures; /* oids of support procs */
|
||||
bool *recheck; /* do operators need recheck */
|
||||
List *iteml;
|
||||
List *operators; /* OpClassMember list for operators */
|
||||
List *procedures; /* OpClassMember list for support procs */
|
||||
List *l;
|
||||
Relation rel;
|
||||
HeapTuple tup;
|
||||
Datum values[Natts_pg_opclass];
|
||||
@@ -123,26 +139,21 @@ DefineOpClass(CreateOpClassStmt *stmt)
|
||||
format_type_be(typeoid));
|
||||
#endif
|
||||
|
||||
operators = NIL;
|
||||
procedures = NIL;
|
||||
|
||||
/* Storage datatype is optional */
|
||||
storageoid = InvalidOid;
|
||||
|
||||
/*
|
||||
* Create work arrays to hold info about operators and procedures. We
|
||||
* do this mainly so that we can detect duplicate strategy numbers and
|
||||
* support-proc numbers.
|
||||
*/
|
||||
operators = (Oid *) palloc0(sizeof(Oid) * numOperators);
|
||||
procedures = (Oid *) palloc0(sizeof(Oid) * numProcs);
|
||||
recheck = (bool *) palloc0(sizeof(bool) * numOperators);
|
||||
|
||||
/*
|
||||
* Scan the "items" list to obtain additional info.
|
||||
*/
|
||||
foreach(iteml, stmt->items)
|
||||
foreach(l, stmt->items)
|
||||
{
|
||||
CreateOpClassItem *item = lfirst(iteml);
|
||||
CreateOpClassItem *item = lfirst(l);
|
||||
Oid operOid;
|
||||
Oid funcOid;
|
||||
OpClassMember *member;
|
||||
AclResult aclresult;
|
||||
|
||||
Assert(IsA(item, CreateOpClassItem));
|
||||
@@ -155,11 +166,6 @@ DefineOpClass(CreateOpClassStmt *stmt)
|
||||
errmsg("invalid operator number %d,"
|
||||
" must be between 1 and %d",
|
||||
item->number, numOperators)));
|
||||
if (operators[item->number - 1] != InvalidOid)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
errmsg("operator number %d appears more than once",
|
||||
item->number)));
|
||||
if (item->args != NIL)
|
||||
{
|
||||
TypeName *typeName1 = (TypeName *) lfirst(item->args);
|
||||
@@ -183,8 +189,13 @@ DefineOpClass(CreateOpClassStmt *stmt)
|
||||
if (aclresult != ACLCHECK_OK)
|
||||
aclcheck_error(aclresult, ACL_KIND_PROC,
|
||||
get_func_name(funcOid));
|
||||
operators[item->number - 1] = operOid;
|
||||
recheck[item->number - 1] = item->recheck;
|
||||
/* Save the info */
|
||||
member = (OpClassMember *) palloc0(sizeof(OpClassMember));
|
||||
member->object = operOid;
|
||||
member->number = item->number;
|
||||
member->subtype = assignOperSubtype(amoid, typeoid, operOid);
|
||||
member->recheck = item->recheck;
|
||||
addClassMember(&operators, member, false);
|
||||
break;
|
||||
case OPCLASS_ITEM_FUNCTION:
|
||||
if (item->number <= 0 || item->number > numProcs)
|
||||
@@ -193,11 +204,6 @@ DefineOpClass(CreateOpClassStmt *stmt)
|
||||
errmsg("invalid procedure number %d,"
|
||||
" must be between 1 and %d",
|
||||
item->number, numProcs)));
|
||||
if (procedures[item->number - 1] != InvalidOid)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
errmsg("procedure number %d appears more than once",
|
||||
item->number)));
|
||||
funcOid = LookupFuncNameTypeNames(item->name, item->args,
|
||||
false);
|
||||
/* Caller must have execute permission on functions */
|
||||
@@ -206,7 +212,12 @@ DefineOpClass(CreateOpClassStmt *stmt)
|
||||
if (aclresult != ACLCHECK_OK)
|
||||
aclcheck_error(aclresult, ACL_KIND_PROC,
|
||||
get_func_name(funcOid));
|
||||
procedures[item->number - 1] = funcOid;
|
||||
/* Save the info */
|
||||
member = (OpClassMember *) palloc0(sizeof(OpClassMember));
|
||||
member->object = funcOid;
|
||||
member->number = item->number;
|
||||
member->subtype = assignProcSubtype(amoid, typeoid, funcOid);
|
||||
addClassMember(&procedures, member, true);
|
||||
break;
|
||||
case OPCLASS_ITEM_STORAGETYPE:
|
||||
if (OidIsValid(storageoid))
|
||||
@@ -271,10 +282,10 @@ DefineOpClass(CreateOpClassStmt *stmt)
|
||||
ScanKeyData skey[1];
|
||||
SysScanDesc scan;
|
||||
|
||||
ScanKeyEntryInitialize(&skey[0], 0,
|
||||
Anum_pg_opclass_opcamid,
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(amoid), OIDOID);
|
||||
ScanKeyInit(&skey[0],
|
||||
Anum_pg_opclass_opcamid,
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(amoid));
|
||||
|
||||
scan = systable_beginscan(rel, OpclassAmNameNspIndex, true,
|
||||
SnapshotNow, 1, skey);
|
||||
@@ -327,8 +338,8 @@ DefineOpClass(CreateOpClassStmt *stmt)
|
||||
* Now add tuples to pg_amop and pg_amproc tying in the operators and
|
||||
* functions.
|
||||
*/
|
||||
storeOperators(opclassoid, numOperators, operators, recheck);
|
||||
storeProcedures(opclassoid, numProcs, procedures);
|
||||
storeOperators(opclassoid, operators);
|
||||
storeProcedures(opclassoid, procedures);
|
||||
|
||||
/*
|
||||
* Create dependencies. Note: we do not create a dependency link to
|
||||
@@ -361,22 +372,22 @@ DefineOpClass(CreateOpClassStmt *stmt)
|
||||
|
||||
/* dependencies on operators */
|
||||
referenced.classId = get_system_catalog_relid(OperatorRelationName);
|
||||
for (i = 0; i < numOperators; i++)
|
||||
foreach(l, operators)
|
||||
{
|
||||
if (operators[i] == InvalidOid)
|
||||
continue;
|
||||
referenced.objectId = operators[i];
|
||||
OpClassMember *op = (OpClassMember *) lfirst(l);
|
||||
|
||||
referenced.objectId = op->object;
|
||||
referenced.objectSubId = 0;
|
||||
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
|
||||
}
|
||||
|
||||
/* dependencies on procedures */
|
||||
for (i = 0; i < numProcs; i++)
|
||||
foreach(l, procedures)
|
||||
{
|
||||
if (procedures[i] == InvalidOid)
|
||||
continue;
|
||||
OpClassMember *proc = (OpClassMember *) lfirst(l);
|
||||
|
||||
referenced.classId = RelOid_pg_proc;
|
||||
referenced.objectId = procedures[i];
|
||||
referenced.objectId = proc->object;
|
||||
referenced.objectSubId = 0;
|
||||
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
|
||||
}
|
||||
@@ -384,26 +395,159 @@ DefineOpClass(CreateOpClassStmt *stmt)
|
||||
heap_close(rel, RowExclusiveLock);
|
||||
}
|
||||
|
||||
/*
|
||||
* Determine the subtype to assign to an operator, and do any validity
|
||||
* checking we can manage
|
||||
*
|
||||
* Currently this is done using hardwired rules; we don't let the user
|
||||
* specify it directly.
|
||||
*/
|
||||
static Oid
|
||||
assignOperSubtype(Oid amoid, Oid typeoid, Oid operOid)
|
||||
{
|
||||
Oid subtype;
|
||||
Operator optup;
|
||||
Form_pg_operator opform;
|
||||
|
||||
/* Subtypes are currently only supported by btree, others use 0 */
|
||||
if (amoid != BTREE_AM_OID)
|
||||
return InvalidOid;
|
||||
|
||||
optup = SearchSysCache(OPEROID,
|
||||
ObjectIdGetDatum(operOid),
|
||||
0, 0, 0);
|
||||
if (optup == NULL)
|
||||
elog(ERROR, "cache lookup failed for operator %u", operOid);
|
||||
opform = (Form_pg_operator) GETSTRUCT(optup);
|
||||
/*
|
||||
* btree operators must be binary ops returning boolean, and the
|
||||
* left-side input type must match the operator class' input type.
|
||||
*/
|
||||
if (opform->oprkind != 'b')
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
errmsg("btree operators must be binary")));
|
||||
if (opform->oprresult != BOOLOID)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
errmsg("btree operators must return boolean")));
|
||||
if (opform->oprleft != typeoid)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
errmsg("btree operators must have index type as left input")));
|
||||
/*
|
||||
* The subtype is "default" (0) if oprright matches the operator class,
|
||||
* otherwise it is oprright.
|
||||
*/
|
||||
if (opform->oprright == typeoid)
|
||||
subtype = InvalidOid;
|
||||
else
|
||||
subtype = opform->oprright;
|
||||
ReleaseSysCache(optup);
|
||||
return subtype;
|
||||
}
|
||||
|
||||
/*
|
||||
* Determine the subtype to assign to a support procedure, and do any validity
|
||||
* checking we can manage
|
||||
*
|
||||
* Currently this is done using hardwired rules; we don't let the user
|
||||
* specify it directly.
|
||||
*/
|
||||
static Oid
|
||||
assignProcSubtype(Oid amoid, Oid typeoid, Oid procOid)
|
||||
{
|
||||
Oid subtype;
|
||||
HeapTuple proctup;
|
||||
Form_pg_proc procform;
|
||||
|
||||
/* Subtypes are currently only supported by btree, others use 0 */
|
||||
if (amoid != BTREE_AM_OID)
|
||||
return InvalidOid;
|
||||
|
||||
proctup = SearchSysCache(PROCOID,
|
||||
ObjectIdGetDatum(procOid),
|
||||
0, 0, 0);
|
||||
if (proctup == NULL)
|
||||
elog(ERROR, "cache lookup failed for function %u", procOid);
|
||||
procform = (Form_pg_proc) GETSTRUCT(proctup);
|
||||
/*
|
||||
* btree support procs must be 2-arg procs returning int4, and the
|
||||
* first input type must match the operator class' input type.
|
||||
*/
|
||||
if (procform->pronargs != 2)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
errmsg("btree procedures must have two arguments")));
|
||||
if (procform->prorettype != INT4OID)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
errmsg("btree procedures must return integer")));
|
||||
if (procform->proargtypes[0] != typeoid)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
errmsg("btree procedures must have index type as first input")));
|
||||
/*
|
||||
* The subtype is "default" (0) if second input type matches the operator
|
||||
* class, otherwise it is the second input type.
|
||||
*/
|
||||
if (procform->proargtypes[1] == typeoid)
|
||||
subtype = InvalidOid;
|
||||
else
|
||||
subtype = procform->proargtypes[1];
|
||||
ReleaseSysCache(proctup);
|
||||
return subtype;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add a new class member to the appropriate list, after checking for
|
||||
* duplicated strategy or proc number.
|
||||
*/
|
||||
static void
|
||||
addClassMember(List **list, OpClassMember *member, bool isProc)
|
||||
{
|
||||
List *l;
|
||||
|
||||
foreach(l, *list)
|
||||
{
|
||||
OpClassMember *old = (OpClassMember *) lfirst(l);
|
||||
|
||||
if (old->number == member->number &&
|
||||
old->subtype == member->subtype)
|
||||
{
|
||||
if (isProc)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
errmsg("procedure number %d appears more than once",
|
||||
member->number)));
|
||||
else
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
errmsg("operator number %d appears more than once",
|
||||
member->number)));
|
||||
}
|
||||
}
|
||||
*list = lappend(*list, member);
|
||||
}
|
||||
|
||||
/*
|
||||
* Dump the operators to pg_amop
|
||||
*/
|
||||
static void
|
||||
storeOperators(Oid opclassoid, int numOperators,
|
||||
Oid *operators, bool *recheck)
|
||||
storeOperators(Oid opclassoid, List *operators)
|
||||
{
|
||||
Relation rel;
|
||||
Datum values[Natts_pg_amop];
|
||||
char nulls[Natts_pg_amop];
|
||||
HeapTuple tup;
|
||||
int i,
|
||||
j;
|
||||
List *l;
|
||||
int i;
|
||||
|
||||
rel = heap_openr(AccessMethodOperatorRelationName, RowExclusiveLock);
|
||||
|
||||
for (j = 0; j < numOperators; j++)
|
||||
foreach(l, operators)
|
||||
{
|
||||
if (operators[j] == InvalidOid)
|
||||
continue;
|
||||
OpClassMember *op = (OpClassMember *) lfirst(l);
|
||||
|
||||
for (i = 0; i < Natts_pg_amop; ++i)
|
||||
{
|
||||
@@ -413,9 +557,10 @@ storeOperators(Oid opclassoid, int numOperators,
|
||||
|
||||
i = 0;
|
||||
values[i++] = ObjectIdGetDatum(opclassoid); /* amopclaid */
|
||||
values[i++] = Int16GetDatum(j + 1); /* amopstrategy */
|
||||
values[i++] = BoolGetDatum(recheck[j]); /* amopreqcheck */
|
||||
values[i++] = ObjectIdGetDatum(operators[j]); /* amopopr */
|
||||
values[i++] = ObjectIdGetDatum(op->subtype); /* amopsubtype */
|
||||
values[i++] = Int16GetDatum(op->number); /* amopstrategy */
|
||||
values[i++] = BoolGetDatum(op->recheck); /* amopreqcheck */
|
||||
values[i++] = ObjectIdGetDatum(op->object); /* amopopr */
|
||||
|
||||
tup = heap_formtuple(rel->rd_att, values, nulls);
|
||||
|
||||
@@ -433,21 +578,20 @@ storeOperators(Oid opclassoid, int numOperators,
|
||||
* Dump the procedures (support routines) to pg_amproc
|
||||
*/
|
||||
static void
|
||||
storeProcedures(Oid opclassoid, int numProcs, Oid *procedures)
|
||||
storeProcedures(Oid opclassoid, List *procedures)
|
||||
{
|
||||
Relation rel;
|
||||
Datum values[Natts_pg_amproc];
|
||||
char nulls[Natts_pg_amproc];
|
||||
HeapTuple tup;
|
||||
int i,
|
||||
j;
|
||||
List *l;
|
||||
int i;
|
||||
|
||||
rel = heap_openr(AccessMethodProcedureRelationName, RowExclusiveLock);
|
||||
|
||||
for (j = 0; j < numProcs; j++)
|
||||
foreach(l, procedures)
|
||||
{
|
||||
if (procedures[j] == InvalidOid)
|
||||
continue;
|
||||
OpClassMember *proc = (OpClassMember *) lfirst(l);
|
||||
|
||||
for (i = 0; i < Natts_pg_amproc; ++i)
|
||||
{
|
||||
@@ -457,8 +601,9 @@ storeProcedures(Oid opclassoid, int numProcs, Oid *procedures)
|
||||
|
||||
i = 0;
|
||||
values[i++] = ObjectIdGetDatum(opclassoid); /* amopclaid */
|
||||
values[i++] = Int16GetDatum(j + 1); /* amprocnum */
|
||||
values[i++] = ObjectIdGetDatum(procedures[j]); /* amproc */
|
||||
values[i++] = ObjectIdGetDatum(proc->subtype); /* amprocsubtype */
|
||||
values[i++] = Int16GetDatum(proc->number); /* amprocnum */
|
||||
values[i++] = ObjectIdGetDatum(proc->object); /* amproc */
|
||||
|
||||
tup = heap_formtuple(rel->rd_att, values, nulls);
|
||||
|
||||
@@ -590,10 +735,10 @@ RemoveOpClassById(Oid opclassOid)
|
||||
/*
|
||||
* Remove associated entries in pg_amop.
|
||||
*/
|
||||
ScanKeyEntryInitialize(&skey[0], 0,
|
||||
Anum_pg_amop_amopclaid,
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(opclassOid), OIDOID);
|
||||
ScanKeyInit(&skey[0],
|
||||
Anum_pg_amop_amopclaid,
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(opclassOid));
|
||||
|
||||
rel = heap_openr(AccessMethodOperatorRelationName, RowExclusiveLock);
|
||||
|
||||
@@ -609,10 +754,10 @@ RemoveOpClassById(Oid opclassOid)
|
||||
/*
|
||||
* Remove associated entries in pg_amproc.
|
||||
*/
|
||||
ScanKeyEntryInitialize(&skey[0], 0,
|
||||
Anum_pg_amproc_amopclaid,
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(opclassOid), OIDOID);
|
||||
ScanKeyInit(&skey[0],
|
||||
Anum_pg_amproc_amopclaid,
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(opclassOid));
|
||||
|
||||
rel = heap_openr(AccessMethodProcedureRelationName, RowExclusiveLock);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user