mirror of
https://github.com/postgres/postgres.git
synced 2025-11-09 06:21:09 +03:00
Add operator strategy and comparison-value datatype fields to ScanKey.
Remove the 'strategy map' code, which was a large amount of mechanism that no longer had any use except reverse-mapping from procedure OID to strategy number. Passing the strategy number to the index AM in the first place is simpler and faster. This is a preliminary step in planned support for cross-datatype index operations. I'm committing it now since the ScanKeyEntryInitialize() API change touches quite a lot of files, and I want to commit those changes before the tree drifts under me.
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.102 2003/10/16 16:50:41 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.103 2003/11/09 21:30:36 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -80,6 +80,7 @@
|
||||
#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"
|
||||
@@ -354,8 +355,8 @@ Async_UnlistenAll(void)
|
||||
/* Find and delete all entries with my listenerPID */
|
||||
ScanKeyEntryInitialize(&key[0], 0,
|
||||
Anum_pg_listener_pid,
|
||||
F_INT4EQ,
|
||||
Int32GetDatum(MyProcPid));
|
||||
BTEqualStrategyNumber, F_INT4EQ,
|
||||
Int32GetDatum(MyProcPid), INT4OID);
|
||||
scan = heap_beginscan(lRel, SnapshotNow, 1, key);
|
||||
|
||||
while ((lTuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
|
||||
@@ -818,8 +819,8 @@ ProcessIncomingNotify(void)
|
||||
/* Scan only entries with my listenerPID */
|
||||
ScanKeyEntryInitialize(&key[0], 0,
|
||||
Anum_pg_listener_pid,
|
||||
F_INT4EQ,
|
||||
Int32GetDatum(MyProcPid));
|
||||
BTEqualStrategyNumber, F_INT4EQ,
|
||||
Int32GetDatum(MyProcPid), INT4OID);
|
||||
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.116 2003/09/25 06:57:58 petere Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.117 2003/11/09 21:30:36 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -26,6 +26,7 @@
|
||||
#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"
|
||||
@@ -880,8 +881,8 @@ get_tables_to_cluster(MemoryContext cluster_context)
|
||||
indRelation = relation_openr(IndexRelationName, AccessShareLock);
|
||||
ScanKeyEntryInitialize(&entry, 0,
|
||||
Anum_pg_index_indisclustered,
|
||||
F_BOOLEQ,
|
||||
BoolGetDatum(true));
|
||||
BTEqualStrategyNumber, F_BOOLEQ,
|
||||
BoolGetDatum(true), BOOLOID);
|
||||
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.71 2003/09/25 06:57:58 petere Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/comment.c,v 1.72 2003/11/09 21:30:36 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -156,23 +156,18 @@ CreateComments(Oid oid, Oid classoid, int32 subid, char *comment)
|
||||
|
||||
/* Use the index to search for a matching old tuple */
|
||||
|
||||
ScanKeyEntryInitialize(&skey[0],
|
||||
(bits16) 0x0,
|
||||
(AttrNumber) 1,
|
||||
(RegProcedure) F_OIDEQ,
|
||||
ObjectIdGetDatum(oid));
|
||||
|
||||
ScanKeyEntryInitialize(&skey[1],
|
||||
(bits16) 0x0,
|
||||
(AttrNumber) 2,
|
||||
(RegProcedure) F_OIDEQ,
|
||||
ObjectIdGetDatum(classoid));
|
||||
|
||||
ScanKeyEntryInitialize(&skey[2],
|
||||
(bits16) 0x0,
|
||||
(AttrNumber) 3,
|
||||
(RegProcedure) F_INT4EQ,
|
||||
Int32GetDatum(subid));
|
||||
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);
|
||||
|
||||
description = heap_openr(DescriptionRelationName, RowExclusiveLock);
|
||||
|
||||
@@ -236,19 +231,21 @@ DeleteComments(Oid oid, Oid classoid, int32 subid)
|
||||
|
||||
/* Use the index to search for all matching old tuples */
|
||||
|
||||
ScanKeyEntryInitialize(&skey[0], 0x0,
|
||||
Anum_pg_description_objoid, F_OIDEQ,
|
||||
ObjectIdGetDatum(oid));
|
||||
|
||||
ScanKeyEntryInitialize(&skey[1], 0x0,
|
||||
Anum_pg_description_classoid, F_OIDEQ,
|
||||
ObjectIdGetDatum(classoid));
|
||||
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);
|
||||
|
||||
if (subid != 0)
|
||||
{
|
||||
ScanKeyEntryInitialize(&skey[2], 0x0,
|
||||
Anum_pg_description_objsubid, F_INT4EQ,
|
||||
Int32GetDatum(subid));
|
||||
ScanKeyEntryInitialize(&skey[2], 0,
|
||||
Anum_pg_description_objsubid,
|
||||
BTEqualStrategyNumber, F_INT4EQ,
|
||||
Int32GetDatum(subid), INT4OID);
|
||||
nkeys = 3;
|
||||
}
|
||||
else
|
||||
@@ -541,11 +538,10 @@ CommentRule(List *qualname, char *comment)
|
||||
rulename = strVal(lfirst(qualname));
|
||||
|
||||
/* Search pg_rewrite for such a rule */
|
||||
ScanKeyEntryInitialize(&scanKeyData,
|
||||
0,
|
||||
ScanKeyEntryInitialize(&scanKeyData, 0,
|
||||
Anum_pg_rewrite_rulename,
|
||||
F_NAMEEQ,
|
||||
PointerGetDatum(rulename));
|
||||
BTEqualStrategyNumber, F_NAMEEQ,
|
||||
PointerGetDatum(rulename), NAMEOID);
|
||||
|
||||
RewriteRelation = heap_openr(RewriteRelationName, AccessShareLock);
|
||||
scanDesc = heap_beginscan(RewriteRelation, SnapshotNow,
|
||||
@@ -795,14 +791,15 @@ CommentTrigger(List *qualname, char *comment)
|
||||
* because of the unique index.
|
||||
*/
|
||||
pg_trigger = heap_openr(TriggerRelationName, AccessShareLock);
|
||||
ScanKeyEntryInitialize(&entry[0], 0x0,
|
||||
ScanKeyEntryInitialize(&entry[0], 0,
|
||||
Anum_pg_trigger_tgrelid,
|
||||
F_OIDEQ,
|
||||
ObjectIdGetDatum(RelationGetRelid(relation)));
|
||||
ScanKeyEntryInitialize(&entry[1], 0x0,
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(RelationGetRelid(relation)),
|
||||
OIDOID);
|
||||
ScanKeyEntryInitialize(&entry[1], 0,
|
||||
Anum_pg_trigger_tgname,
|
||||
F_NAMEEQ,
|
||||
CStringGetDatum(trigname));
|
||||
BTEqualStrategyNumber, F_NAMEEQ,
|
||||
CStringGetDatum(trigname), NAMEOID);
|
||||
scan = systable_beginscan(pg_trigger, TriggerRelidNameIndex, true,
|
||||
SnapshotNow, 2, entry);
|
||||
triggertuple = systable_getnext(scan);
|
||||
@@ -875,9 +872,11 @@ CommentConstraint(List *qualname, char *comment)
|
||||
*/
|
||||
pg_constraint = heap_openr(ConstraintRelationName, AccessShareLock);
|
||||
|
||||
ScanKeyEntryInitialize(&skey[0], 0x0,
|
||||
Anum_pg_constraint_conrelid, F_OIDEQ,
|
||||
ObjectIdGetDatum(RelationGetRelid(relation)));
|
||||
ScanKeyEntryInitialize(&skey[0], 0,
|
||||
Anum_pg_constraint_conrelid,
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(RelationGetRelid(relation)),
|
||||
OIDOID);
|
||||
|
||||
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.124 2003/09/29 00:05:24 petere Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.125 2003/11/09 21:30:36 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -27,6 +27,7 @@
|
||||
#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"
|
||||
@@ -530,10 +531,13 @@ dropdb(const char *dbname)
|
||||
/*
|
||||
* Find the database's tuple by OID (should be unique).
|
||||
*/
|
||||
ScanKeyEntryInitialize(&key, 0, ObjectIdAttributeNumber,
|
||||
F_OIDEQ, ObjectIdGetDatum(db_id));
|
||||
ScanKeyEntryInitialize(&key, 0,
|
||||
ObjectIdAttributeNumber,
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(db_id), OIDOID);
|
||||
|
||||
pgdbscan = systable_beginscan(pgdbrel, DatabaseOidIndex, true, SnapshotNow, 1, &key);
|
||||
pgdbscan = systable_beginscan(pgdbrel, DatabaseOidIndex, true,
|
||||
SnapshotNow, 1, &key);
|
||||
|
||||
tup = systable_getnext(pgdbscan);
|
||||
if (!HeapTupleIsValid(tup))
|
||||
@@ -612,9 +616,12 @@ RenameDatabase(const char *oldname, const char *newname)
|
||||
*/
|
||||
rel = heap_openr(DatabaseRelationName, AccessExclusiveLock);
|
||||
|
||||
ScanKeyEntryInitialize(&key, 0, Anum_pg_database_datname,
|
||||
F_NAMEEQ, NameGetDatum(oldname));
|
||||
scan = systable_beginscan(rel, DatabaseNameIndex, true, SnapshotNow, 1, &key);
|
||||
ScanKeyEntryInitialize(&key, 0,
|
||||
Anum_pg_database_datname,
|
||||
BTEqualStrategyNumber, F_NAMEEQ,
|
||||
NameGetDatum(oldname), NAMEOID);
|
||||
scan = systable_beginscan(rel, DatabaseNameIndex, true,
|
||||
SnapshotNow, 1, &key);
|
||||
|
||||
tup = systable_getnext(scan);
|
||||
if (!HeapTupleIsValid(tup))
|
||||
@@ -644,9 +651,12 @@ RenameDatabase(const char *oldname, const char *newname)
|
||||
oldname)));
|
||||
|
||||
/* make sure the new name doesn't exist */
|
||||
ScanKeyEntryInitialize(&key2, 0, Anum_pg_database_datname,
|
||||
F_NAMEEQ, NameGetDatum(newname));
|
||||
scan2 = systable_beginscan(rel, DatabaseNameIndex, true, SnapshotNow, 1, &key2);
|
||||
ScanKeyEntryInitialize(&key2, 0,
|
||||
Anum_pg_database_datname,
|
||||
BTEqualStrategyNumber, F_NAMEEQ,
|
||||
NameGetDatum(newname), NAMEOID);
|
||||
scan2 = systable_beginscan(rel, DatabaseNameIndex, true,
|
||||
SnapshotNow, 1, &key2);
|
||||
if (HeapTupleIsValid(systable_getnext(scan2)))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DUPLICATE_DATABASE),
|
||||
@@ -702,9 +712,12 @@ AlterDatabaseSet(AlterDatabaseSetStmt *stmt)
|
||||
valuestr = flatten_set_variable_args(stmt->variable, stmt->value);
|
||||
|
||||
rel = heap_openr(DatabaseRelationName, RowExclusiveLock);
|
||||
ScanKeyEntryInitialize(&scankey, 0, Anum_pg_database_datname,
|
||||
F_NAMEEQ, NameGetDatum(stmt->dbname));
|
||||
scan = systable_beginscan(rel, DatabaseNameIndex, true, SnapshotNow, 1, &scankey);
|
||||
ScanKeyEntryInitialize(&scankey, 0,
|
||||
Anum_pg_database_datname,
|
||||
BTEqualStrategyNumber, F_NAMEEQ,
|
||||
NameGetDatum(stmt->dbname), NAMEOID);
|
||||
scan = systable_beginscan(rel, DatabaseNameIndex, true,
|
||||
SnapshotNow, 1, &scankey);
|
||||
tuple = systable_getnext(scan);
|
||||
if (!HeapTupleIsValid(tuple))
|
||||
ereport(ERROR,
|
||||
@@ -782,10 +795,13 @@ 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,
|
||||
F_NAMEEQ, NameGetDatum(name));
|
||||
ScanKeyEntryInitialize(&scanKey, 0,
|
||||
Anum_pg_database_datname,
|
||||
BTEqualStrategyNumber, F_NAMEEQ,
|
||||
NameGetDatum(name), NAMEOID);
|
||||
|
||||
scan = systable_beginscan(relation, DatabaseNameIndex, true, SnapshotNow, 1, &scanKey);
|
||||
scan = systable_beginscan(relation, DatabaseNameIndex, true,
|
||||
SnapshotNow, 1, &scanKey);
|
||||
|
||||
tuple = systable_getnext(scan);
|
||||
|
||||
@@ -985,10 +1001,12 @@ 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], 0x0,
|
||||
Anum_pg_database_datname, F_NAMEEQ,
|
||||
CStringGetDatum(dbname));
|
||||
scan = systable_beginscan(pg_database, DatabaseNameIndex, true, SnapshotNow, 1, entry);
|
||||
ScanKeyEntryInitialize(&entry[0], 0,
|
||||
Anum_pg_database_datname,
|
||||
BTEqualStrategyNumber, F_NAMEEQ,
|
||||
CStringGetDatum(dbname), NAMEOID);
|
||||
scan = systable_beginscan(pg_database, DatabaseNameIndex, true,
|
||||
SnapshotNow, 1, entry);
|
||||
|
||||
dbtuple = systable_getnext(scan);
|
||||
|
||||
@@ -1023,10 +1041,12 @@ 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], 0x0,
|
||||
ObjectIdAttributeNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(dbid));
|
||||
scan = systable_beginscan(pg_database, DatabaseOidIndex, true, SnapshotNow, 1, entry);
|
||||
ScanKeyEntryInitialize(&entry[0], 0,
|
||||
ObjectIdAttributeNumber,
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(dbid), OIDOID);
|
||||
scan = systable_beginscan(pg_database, DatabaseOidIndex, true,
|
||||
SnapshotNow, 1, entry);
|
||||
|
||||
dbtuple = systable_getnext(scan);
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/functioncmds.c,v 1.38 2003/10/02 06:34:03 petere Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/functioncmds.c,v 1.39 2003/11/09 21:30:36 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, 0x0,
|
||||
ScanKeyEntryInitialize(&scankey, 0,
|
||||
ObjectIdAttributeNumber,
|
||||
F_OIDEQ,
|
||||
ObjectIdGetDatum(castOid));
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(castOid), OIDOID);
|
||||
scan = systable_beginscan(relation, CastOidIndex, true,
|
||||
SnapshotNow, 1, &scankey);
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/opclasscmds.c,v 1.21 2003/09/26 15:27:31 petere Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/opclasscmds.c,v 1.22 2003/11/09 21:30:36 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "catalog/pg_amop.h"
|
||||
#include "catalog/pg_amproc.h"
|
||||
#include "catalog/pg_opclass.h"
|
||||
#include "catalog/pg_type.h"
|
||||
#include "commands/defrem.h"
|
||||
#include "miscadmin.h"
|
||||
#include "parser/parse_func.h"
|
||||
@@ -270,9 +271,10 @@ DefineOpClass(CreateOpClassStmt *stmt)
|
||||
ScanKeyData skey[1];
|
||||
SysScanDesc scan;
|
||||
|
||||
ScanKeyEntryInitialize(&skey[0], 0x0,
|
||||
Anum_pg_opclass_opcamid, F_OIDEQ,
|
||||
ObjectIdGetDatum(amoid));
|
||||
ScanKeyEntryInitialize(&skey[0], 0,
|
||||
Anum_pg_opclass_opcamid,
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(amoid), OIDOID);
|
||||
|
||||
scan = systable_beginscan(rel, OpclassAmNameNspIndex, true,
|
||||
SnapshotNow, 1, skey);
|
||||
@@ -589,8 +591,9 @@ RemoveOpClassById(Oid opclassOid)
|
||||
* Remove associated entries in pg_amop.
|
||||
*/
|
||||
ScanKeyEntryInitialize(&skey[0], 0,
|
||||
Anum_pg_amop_amopclaid, F_OIDEQ,
|
||||
ObjectIdGetDatum(opclassOid));
|
||||
Anum_pg_amop_amopclaid,
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(opclassOid), OIDOID);
|
||||
|
||||
rel = heap_openr(AccessMethodOperatorRelationName, RowExclusiveLock);
|
||||
|
||||
@@ -607,8 +610,9 @@ RemoveOpClassById(Oid opclassOid)
|
||||
* Remove associated entries in pg_amproc.
|
||||
*/
|
||||
ScanKeyEntryInitialize(&skey[0], 0,
|
||||
Anum_pg_amproc_amopclaid, F_OIDEQ,
|
||||
ObjectIdGetDatum(opclassOid));
|
||||
Anum_pg_amproc_amopclaid,
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(opclassOid), OIDOID);
|
||||
|
||||
rel = heap_openr(AccessMethodProcedureRelationName, RowExclusiveLock);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.91 2003/10/13 22:47:15 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.92 2003/11/09 21:30:36 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -1393,20 +1393,20 @@ update_ri_trigger_args(Oid relid,
|
||||
tgrel = heap_openr(TriggerRelationName, RowExclusiveLock);
|
||||
if (fk_scan)
|
||||
{
|
||||
ScanKeyEntryInitialize(&skey[0], 0x0,
|
||||
ScanKeyEntryInitialize(&skey[0], 0,
|
||||
Anum_pg_trigger_tgconstrrelid,
|
||||
F_OIDEQ,
|
||||
ObjectIdGetDatum(relid));
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(relid), OIDOID);
|
||||
trigscan = systable_beginscan(tgrel, TriggerConstrRelidIndex,
|
||||
true, SnapshotNow,
|
||||
1, skey);
|
||||
}
|
||||
else
|
||||
{
|
||||
ScanKeyEntryInitialize(&skey[0], 0x0,
|
||||
ScanKeyEntryInitialize(&skey[0], 0,
|
||||
Anum_pg_trigger_tgrelid,
|
||||
F_OIDEQ,
|
||||
ObjectIdGetDatum(relid));
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(relid), OIDOID);
|
||||
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.160 2003/11/06 22:08:14 petere Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.161 2003/11/09 21:30:36 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -255,8 +255,8 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint)
|
||||
tgrel = heap_openr(TriggerRelationName, RowExclusiveLock);
|
||||
ScanKeyEntryInitialize(&key, 0,
|
||||
Anum_pg_trigger_tgrelid,
|
||||
F_OIDEQ,
|
||||
ObjectIdGetDatum(RelationGetRelid(rel)));
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(RelationGetRelid(rel)), OIDOID);
|
||||
tgscan = systable_beginscan(tgrel, TriggerRelidNameIndex, true,
|
||||
SnapshotNow, 1, &key);
|
||||
while (HeapTupleIsValid(tuple = systable_getnext(tgscan)))
|
||||
@@ -465,13 +465,15 @@ DropTrigger(Oid relid, const char *trigname, DropBehavior behavior)
|
||||
*/
|
||||
tgrel = heap_openr(TriggerRelationName, AccessShareLock);
|
||||
|
||||
ScanKeyEntryInitialize(&skey[0], 0x0,
|
||||
Anum_pg_trigger_tgrelid, F_OIDEQ,
|
||||
ObjectIdGetDatum(relid));
|
||||
ScanKeyEntryInitialize(&skey[0], 0,
|
||||
Anum_pg_trigger_tgrelid,
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(relid), OIDOID);
|
||||
|
||||
ScanKeyEntryInitialize(&skey[1], 0x0,
|
||||
Anum_pg_trigger_tgname, F_NAMEEQ,
|
||||
CStringGetDatum(trigname));
|
||||
ScanKeyEntryInitialize(&skey[1], 0,
|
||||
Anum_pg_trigger_tgname,
|
||||
BTEqualStrategyNumber, F_NAMEEQ,
|
||||
CStringGetDatum(trigname), NAMEOID);
|
||||
|
||||
tgscan = systable_beginscan(tgrel, TriggerRelidNameIndex, true,
|
||||
SnapshotNow, 2, skey);
|
||||
@@ -522,9 +524,10 @@ RemoveTriggerById(Oid trigOid)
|
||||
/*
|
||||
* Find the trigger to delete.
|
||||
*/
|
||||
ScanKeyEntryInitialize(&skey[0], 0x0,
|
||||
ObjectIdAttributeNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(trigOid));
|
||||
ScanKeyEntryInitialize(&skey[0], 0,
|
||||
ObjectIdAttributeNumber,
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(trigOid), OIDOID);
|
||||
|
||||
tgscan = systable_beginscan(tgrel, TriggerOidIndex, true,
|
||||
SnapshotNow, 1, skey);
|
||||
@@ -640,12 +643,12 @@ renametrig(Oid relid,
|
||||
*/
|
||||
ScanKeyEntryInitialize(&key[0], 0,
|
||||
Anum_pg_trigger_tgrelid,
|
||||
F_OIDEQ,
|
||||
ObjectIdGetDatum(relid));
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(relid), OIDOID);
|
||||
ScanKeyEntryInitialize(&key[1], 0,
|
||||
Anum_pg_trigger_tgname,
|
||||
F_NAMEEQ,
|
||||
PointerGetDatum(newname));
|
||||
BTEqualStrategyNumber, F_NAMEEQ,
|
||||
PointerGetDatum(newname), NAMEOID);
|
||||
tgscan = systable_beginscan(tgrel, TriggerRelidNameIndex, true,
|
||||
SnapshotNow, 2, key);
|
||||
if (HeapTupleIsValid(tuple = systable_getnext(tgscan)))
|
||||
@@ -660,12 +663,12 @@ renametrig(Oid relid,
|
||||
*/
|
||||
ScanKeyEntryInitialize(&key[0], 0,
|
||||
Anum_pg_trigger_tgrelid,
|
||||
F_OIDEQ,
|
||||
ObjectIdGetDatum(relid));
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(relid), OIDOID);
|
||||
ScanKeyEntryInitialize(&key[1], 0,
|
||||
Anum_pg_trigger_tgname,
|
||||
F_NAMEEQ,
|
||||
PointerGetDatum(oldname));
|
||||
BTEqualStrategyNumber, F_NAMEEQ,
|
||||
PointerGetDatum(oldname), NAMEOID);
|
||||
tgscan = systable_beginscan(tgrel, TriggerRelidNameIndex, true,
|
||||
SnapshotNow, 2, key);
|
||||
if (HeapTupleIsValid(tuple = systable_getnext(tgscan)))
|
||||
@@ -741,11 +744,11 @@ RelationBuildTriggers(Relation relation)
|
||||
* emergency-recovery operations (ie, IsIgnoringSystemIndexes). This
|
||||
* in turn ensures that triggers will be fired in name order.
|
||||
*/
|
||||
ScanKeyEntryInitialize(&skey,
|
||||
(bits16) 0x0,
|
||||
(AttrNumber) Anum_pg_trigger_tgrelid,
|
||||
(RegProcedure) F_OIDEQ,
|
||||
ObjectIdGetDatum(RelationGetRelid(relation)));
|
||||
ScanKeyEntryInitialize(&skey, 0,
|
||||
Anum_pg_trigger_tgrelid,
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(RelationGetRelid(relation)),
|
||||
OIDOID);
|
||||
|
||||
tgrel = heap_openr(TriggerRelationName, AccessShareLock);
|
||||
tgscan = systable_beginscan(tgrel, TriggerRelidNameIndex, true,
|
||||
@@ -2259,10 +2262,10 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
|
||||
/*
|
||||
* Setup to scan pg_trigger by tgconstrname ...
|
||||
*/
|
||||
ScanKeyEntryInitialize(&skey, (bits16) 0x0,
|
||||
(AttrNumber) Anum_pg_trigger_tgconstrname,
|
||||
(RegProcedure) F_NAMEEQ,
|
||||
PointerGetDatum(cname));
|
||||
ScanKeyEntryInitialize(&skey, 0,
|
||||
Anum_pg_trigger_tgconstrname,
|
||||
BTEqualStrategyNumber, F_NAMEEQ,
|
||||
PointerGetDatum(cname), NAMEOID);
|
||||
|
||||
tgscan = systable_beginscan(tgrel, TriggerConstrNameIndex, true,
|
||||
SnapshotNow, 1, &skey);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/typecmds.c,v 1.48 2003/10/02 06:34:03 petere Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/typecmds.c,v 1.49 2003/11/09 21:30:36 tgl Exp $
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The "DefineFoo" routines take the parse tree and pick out the
|
||||
@@ -1362,9 +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], 0x0,
|
||||
Anum_pg_constraint_contypid, F_OIDEQ,
|
||||
ObjectIdGetDatum(HeapTupleGetOid(tup)));
|
||||
ScanKeyEntryInitialize(&key[0], 0,
|
||||
Anum_pg_constraint_contypid,
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(HeapTupleGetOid(tup)), OIDOID);
|
||||
|
||||
conscan = systable_beginscan(conrel, ConstraintTypidIndex, true,
|
||||
SnapshotNow, 1, key);
|
||||
@@ -1614,12 +1615,14 @@ get_rels_with_domain(Oid domainOid, LOCKMODE lockmode)
|
||||
*/
|
||||
depRel = relation_openr(DependRelationName, AccessShareLock);
|
||||
|
||||
ScanKeyEntryInitialize(&key[0], 0x0,
|
||||
Anum_pg_depend_refclassid, F_OIDEQ,
|
||||
ObjectIdGetDatum(RelOid_pg_type));
|
||||
ScanKeyEntryInitialize(&key[1], 0x0,
|
||||
Anum_pg_depend_refobjid, F_OIDEQ,
|
||||
ObjectIdGetDatum(domainOid));
|
||||
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);
|
||||
|
||||
depScan = systable_beginscan(depRel, DependReferenceIndex, true,
|
||||
SnapshotNow, 2, key);
|
||||
@@ -1898,9 +1901,10 @@ GetDomainConstraints(Oid typeOid)
|
||||
notNull = true;
|
||||
|
||||
/* Look for CHECK Constraints on this domain */
|
||||
ScanKeyEntryInitialize(&key[0], 0x0,
|
||||
Anum_pg_constraint_contypid, F_OIDEQ,
|
||||
ObjectIdGetDatum(typeOid));
|
||||
ScanKeyEntryInitialize(&key[0], 0,
|
||||
Anum_pg_constraint_contypid,
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(typeOid), OIDOID);
|
||||
|
||||
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.128 2003/10/02 06:36:37 petere Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.129 2003/11/09 21:30:36 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -1074,9 +1074,10 @@ DropUser(DropUserStmt *stmt)
|
||||
pg_rel = heap_openr(DatabaseRelationName, AccessShareLock);
|
||||
pg_dsc = RelationGetDescr(pg_rel);
|
||||
|
||||
ScanKeyEntryInitialize(&scankey, 0x0,
|
||||
Anum_pg_database_datdba, F_INT4EQ,
|
||||
Int32GetDatum(usesysid));
|
||||
ScanKeyEntryInitialize(&scankey, 0,
|
||||
Anum_pg_database_datdba,
|
||||
BTEqualStrategyNumber, F_INT4EQ,
|
||||
Int32GetDatum(usesysid), INT4OID);
|
||||
|
||||
scan = heap_beginscan(pg_rel, SnapshotNow, 1, &scankey);
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.263 2003/10/02 23:19:44 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.264 2003/11/09 21:30:36 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -30,6 +30,7 @@
|
||||
#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"
|
||||
@@ -399,10 +400,10 @@ getrels(const RangeVar *vacrel, const char *stmttype)
|
||||
HeapTuple tuple;
|
||||
ScanKeyData key;
|
||||
|
||||
ScanKeyEntryInitialize(&key, 0x0,
|
||||
ScanKeyEntryInitialize(&key, 0,
|
||||
Anum_pg_class_relkind,
|
||||
F_CHAREQ,
|
||||
CharGetDatum(RELKIND_RELATION));
|
||||
BTEqualStrategyNumber, F_CHAREQ,
|
||||
CharGetDatum(RELKIND_RELATION), CHAROID);
|
||||
|
||||
pgclass = heap_openr(RelationRelationName, AccessShareLock);
|
||||
|
||||
@@ -582,9 +583,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], 0x0,
|
||||
ObjectIdAttributeNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(dbid));
|
||||
ScanKeyEntryInitialize(&entry[0], 0,
|
||||
ObjectIdAttributeNumber,
|
||||
BTEqualStrategyNumber, F_OIDEQ,
|
||||
ObjectIdGetDatum(dbid), OIDOID);
|
||||
|
||||
scan = heap_beginscan(relation, SnapshotNow, 1, entry);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user