Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7d30194

Browse files
committed
Re-order pg_listener index so it can later be used in an index scan.
1 parent75b950f commit7d30194

File tree

5 files changed

+27
-42
lines changed

5 files changed

+27
-42
lines changed

‎src/backend/catalog/indexing.c

Lines changed: 8 additions & 8 deletions
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/0702:44:35 momjian Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.64 2000/06/0704: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(RelationheapRelation,char*relName,int4pid)
656+
ListenerPidRelnameIndexScan(RelationheapRelation,int4pid,char*relName)
657657
{
658658
Relationidesc;
659659
ScanKeyDataskey[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

Lines changed: 9 additions & 24 deletions
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
Datumd;
203202
inti;
204203
boolisnull;
205-
intalreadyListener=0;
206204
TupleDesctupDesc;
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

Lines changed: 4 additions & 4 deletions
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/0702:44:37 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.53 2000/06/0704: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

Lines changed: 2 additions & 2 deletions
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/0703:02:08 momjian Exp $
40+
* $Id: catversion.h,v 1.26 2000/06/0704:09:44 momjian Exp $
4141
*
4242
*-------------------------------------------------------------------------
4343
*/
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/*yyyymmddN */
56-
#defineCATALOG_VERSION_NO200006061
56+
#defineCATALOG_VERSION_NO200006071
5757

5858
#endif

‎src/include/catalog/indexing.h

Lines changed: 4 additions & 4 deletions
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/0702:44:40 momjian Exp $
11+
* $Id: indexing.h,v 1.39 2000/06/0704:09:44 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -63,7 +63,7 @@
6363
#defineInheritsRelidSeqnoIndex"pg_inherits_relid_seqno_index"
6464
#defineLanguageNameIndex"pg_language_name_index"
6565
#defineLanguageOidIndex"pg_language_oid_index"
66-
#defineListenerRelnamePidIndex"pg_listener_relname_pid_index"
66+
#defineListenerPidRelnameIndex"pg_listener_pid_relname_index"
6767
#defineOpclassDeftypeIndex"pg_opclass_deftype_index"
6868
#defineOpclassNameIndex"pg_opclass_name_index"
6969
#defineOperatorNameIndex"pg_operator_oprname_l_r_k_index"
@@ -141,7 +141,7 @@ extern HeapTuple InheritsRelidSeqnoIndexScan(Relation heapRelation, Oid relid,
141141
int4seqno);
142142
externHeapTupleLanguageNameIndexScan(RelationheapRelation,char*lanName);
143143
externHeapTupleLanguageOidIndexScan(RelationheapRelation,OidlanId);
144-
externHeapTupleListenerRelnamePidIndexScan(RelationheapRelation,char*relName,int4pid);
144+
externHeapTupleListenerPidRelnameIndexScan(RelationheapRelation,int4pid,char*relName);
145145
externHeapTupleOpclassDeftypeIndexScan(RelationheapRelation,OiddefType);
146146
externHeapTupleOpclassNameIndexScan(RelationheapRelation,char*opcName);
147147
externHeapTupleOperatorNameIndexScan(RelationheapRelation,
@@ -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_indexonpg_inheritsusingbtree(inhrelidoid_ops,inhseqnoint4_ops));
191191
DECLARE_UNIQUE_INDEX(pg_language_name_indexonpg_languageusingbtree(lannamename_ops));
192192
DECLARE_UNIQUE_INDEX(pg_language_oid_indexonpg_languageusingbtree(oidoid_ops));
193-
DECLARE_UNIQUE_INDEX(pg_listener_relname_pid_indexonpg_listenerusingbtree(relnamename_ops,listenerpidint4_ops));
193+
DECLARE_UNIQUE_INDEX(pg_listener_pid_relname_indexonpg_listenerusingbtree(listenerpidint4_ops,relnamename_ops));
194194
/* This column needs to allow multiple zero entries, but is in the cache */
195195
DECLARE_INDEX(pg_opclass_deftype_indexonpg_opclassusingbtree(opcdeftypeoid_ops));
196196
DECLARE_UNIQUE_INDEX(pg_opclass_name_indexonpg_opclassusingbtree(opcnamename_ops));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp