Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7d30194

Browse files
committed
Re-order pg_listener index so it can later be used in an index scan.
1 parent 75b950f commit 7d30194

File tree

5 files changed

+27
-42
lines changed

5 files changed

+27
-42
lines changed

src/backend/catalog/indexing.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.63 2000/06/07 02:44:35 momjian Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.64 2000/06/07 04:09:33 momjian Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -51,7 +51,7 @@ char *Name_pg_inherits_indices[Num_pg_inherits_indices] =
5151
char *Name_pg_language_indices[Num_pg_language_indices] =
5252
{LanguageOidIndex, LanguageNameIndex};
5353
char *Name_pg_listener_indices[Num_pg_listener_indices] =
54-
{ListenerRelnamePidIndex};
54+
{ListenerPidRelnameIndex};
5555
char *Name_pg_opclass_indices[Num_pg_opclass_indices] =
5656
{OpclassNameIndex, OpclassDeftypeIndex};
5757
char *Name_pg_operator_indices[Num_pg_operator_indices] =
@@ -653,7 +653,7 @@ LanguageOidIndexScan(Relation heapRelation, Oid lanId)
653653

654654

655655
HeapTuple
656-
ListenerRelnamePidIndexScan(Relation heapRelation, char *relName, int4 pid)
656+
ListenerPidRelnameIndexScan(Relation heapRelation, int4 pid, char *relName)
657657
{
658658
Relation idesc;
659659
ScanKeyData skey[2];
@@ -662,16 +662,16 @@ ListenerRelnamePidIndexScan(Relation heapRelation, char *relName, int4 pid)
662662
ScanKeyEntryInitialize(&skey[0],
663663
(bits16) 0x0,
664664
(AttrNumber) 1,
665-
(RegProcedure) F_NAMEEQ,
666-
PointerGetDatum(relName));
665+
(RegProcedure) F_INT4EQ,
666+
Int32GetDatum(pid));
667667

668668
ScanKeyEntryInitialize(&skey[1],
669669
(bits16) 0x0,
670670
(AttrNumber) 2,
671-
(RegProcedure) F_INT4EQ,
672-
Int32GetDatum(pid));
671+
(RegProcedure) F_NAMEEQ,
672+
PointerGetDatum(relName));
673673

674-
idesc = index_openr(ListenerRelnamePidIndex);
674+
idesc = index_openr(ListenerPidRelnameIndex);
675675
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 2);
676676

677677
index_close(idesc);

src/backend/commands/async.c

+9-24
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.63 2000/06/04 01:44:29 petere Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.64 2000/06/07 04:09:34 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -159,7 +159,6 @@ Async_Notify(char *relname)
159159
/* no point in making duplicate entries in the list ... */
160160
if (!AsyncExistsPendingNotify(relname))
161161
{
162-
163162
/*
164163
* We allocate list memory from the global malloc pool to ensure
165164
* that it will live until we want to use it. This is probably
@@ -202,7 +201,6 @@ Async_Listen(char *relname, int pid)
202201
Datum d;
203202
int i;
204203
bool isnull;
205-
int alreadyListener = 0;
206204
TupleDesc tupDesc;
207205

208206
if (Trace_notify)
@@ -212,25 +210,12 @@ Async_Listen(char *relname, int pid)
212210
tdesc = RelationGetDescr(lRel);
213211

214212
/* Detect whether we are already listening on this relname */
215-
scan = heap_beginscan(lRel, 0, SnapshotNow, 0, (ScanKey) NULL);
216-
while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
217-
{
218-
d = heap_getattr(tuple, Anum_pg_listener_relname, tdesc, &isnull);
219-
if (!strncmp((char *) DatumGetPointer(d), relname, NAMEDATALEN))
220-
{
221-
d = heap_getattr(tuple, Anum_pg_listener_pid, tdesc, &isnull);
222-
if (DatumGetInt32(d) == pid)
223-
{
224-
alreadyListener = 1;
225-
/* No need to scan the rest of the table */
226-
break;
227-
}
228-
}
229-
}
230-
heap_endscan(scan);
231-
232-
if (alreadyListener)
213+
tuple = SearchSysCacheTuple(LISTENREL, Int32GetDatum(pid),
214+
PointerGetDatum(relname),
215+
0, 0);
216+
if (tuple != NULL)
233217
{
218+
/* No need to scan the rest of the table */
234219
heap_close(lRel, AccessExclusiveLock);
235220
elog(NOTICE, "Async_Listen: We are already listening on %s", relname);
236221
return;
@@ -313,9 +298,9 @@ Async_Unlisten(char *relname, int pid)
313298

314299
lRel = heap_openr(ListenerRelationName, AccessExclusiveLock);
315300
/* Note we assume there can be only one matching tuple. */
316-
lTuple = SearchSysCacheTuple(LISTENREL, PointerGetDatum(relname),
317-
Int32GetDatum(pid),
318-
0, 0);
301+
lTuple = SearchSysCacheTuple(LISTENREL, Int32GetDatum(pid),
302+
PointerGetDatum(relname),
303+
0, 0);
319304
if (lTuple != NULL)
320305
heap_delete(lRel, &lTuple->t_self, NULL);
321306
heap_close(lRel, AccessExclusiveLock);

src/backend/utils/cache/syscache.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.52 2000/06/07 02:44:37 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.53 2000/06/07 04:09:36 momjian Exp $
1212
*
1313
* NOTES
1414
* These routines allow the parser/planner/executor to perform
@@ -241,14 +241,14 @@ static struct cachedesc cacheinfo[] = {
241241
{ListenerRelationName, /* LISTENREL */
242242
2,
243243
{
244-
Anum_pg_listener_relname,
245244
Anum_pg_listener_pid,
245+
Anum_pg_listener_relname,
246246
0,
247247
0
248248
},
249249
sizeof(FormData_pg_listener),
250-
ListenerRelnamePidIndex,
251-
ListenerRelnamePidIndexScan},
250+
ListenerPidRelnameIndex,
251+
ListenerPidRelnameIndexScan},
252252
{OperatorRelationName, /* OPERNAME */
253253
4,
254254
{

src/include/catalog/catversion.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
3838
* Portions Copyright (c) 1994, Regents of the University of California
3939
*
40-
* $Id: catversion.h,v 1.25 2000/06/07 03:02:08 momjian Exp $
40+
* $Id: catversion.h,v 1.26 2000/06/07 04:09:44 momjian Exp $
4141
*
4242
*-------------------------------------------------------------------------
4343
*/
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/* yyyymmddN */
56-
#define CATALOG_VERSION_NO 200006061
56+
#define CATALOG_VERSION_NO 200006071
5757

5858
#endif

src/include/catalog/indexing.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
99
* Portions Copyright (c) 1994, Regents of the University of California
1010
*
11-
* $Id: indexing.h,v 1.38 2000/06/07 02:44:40 momjian Exp $
11+
* $Id: indexing.h,v 1.39 2000/06/07 04:09:44 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -63,7 +63,7 @@
6363
#define InheritsRelidSeqnoIndex "pg_inherits_relid_seqno_index"
6464
#define LanguageNameIndex "pg_language_name_index"
6565
#define LanguageOidIndex "pg_language_oid_index"
66-
#define ListenerRelnamePidIndex "pg_listener_relname_pid_index"
66+
#define ListenerPidRelnameIndex "pg_listener_pid_relname_index"
6767
#define OpclassDeftypeIndex "pg_opclass_deftype_index"
6868
#define OpclassNameIndex "pg_opclass_name_index"
6969
#define OperatorNameIndex "pg_operator_oprname_l_r_k_index"
@@ -141,7 +141,7 @@ extern HeapTuple InheritsRelidSeqnoIndexScan(Relation heapRelation, Oid relid,
141141
int4 seqno);
142142
extern HeapTuple LanguageNameIndexScan(Relation heapRelation, char *lanName);
143143
extern HeapTuple LanguageOidIndexScan(Relation heapRelation, Oid lanId);
144-
extern HeapTuple ListenerRelnamePidIndexScan(Relation heapRelation, char *relName, int4 pid);
144+
extern HeapTuple ListenerPidRelnameIndexScan(Relation heapRelation, int4 pid, char *relName);
145145
extern HeapTuple OpclassDeftypeIndexScan(Relation heapRelation, Oid defType);
146146
extern HeapTuple OpclassNameIndexScan(Relation heapRelation, char *opcName);
147147
extern HeapTuple OperatorNameIndexScan(Relation heapRelation,
@@ -190,7 +190,7 @@ DECLARE_UNIQUE_INDEX(pg_index_indexrelid_index on pg_index using btree(indexreli
190190
DECLARE_UNIQUE_INDEX(pg_inherits_relid_seqno_index on pg_inherits using btree(inhrelid oid_ops, inhseqno int4_ops));
191191
DECLARE_UNIQUE_INDEX(pg_language_name_index on pg_language using btree(lanname name_ops));
192192
DECLARE_UNIQUE_INDEX(pg_language_oid_index on pg_language using btree(oid oid_ops));
193-
DECLARE_UNIQUE_INDEX(pg_listener_relname_pid_index on pg_listener using btree(relname name_ops, listenerpid int4_ops));
193+
DECLARE_UNIQUE_INDEX(pg_listener_pid_relname_index on pg_listener using btree(listenerpid int4_ops, relname name_ops));
194194
/* This column needs to allow multiple zero entries, but is in the cache */
195195
DECLARE_INDEX(pg_opclass_deftype_index on pg_opclass using btree(opcdeftype oid_ops));
196196
DECLARE_UNIQUE_INDEX(pg_opclass_name_index on pg_opclass using btree(opcname name_ops));

0 commit comments

Comments
 (0)