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

Commit162bd08

Browse files
committed
Completion of project to use fixed OIDs for all system catalogs and
indexes. Replace all heap_openr and index_openr calls by heap_openand index_open. Remove runtime lookups of catalog OID numbers invarious places. Remove relcache's support for looking up systemcatalogs by name. Bulky but mostly very boring patch ...
1 parent9dc2e6d commit162bd08

File tree

71 files changed

+690
-1226
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+690
-1226
lines changed

‎contrib/dblink/dblink.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#include"funcapi.h"
3737
#include"access/tupdesc.h"
3838
#include"access/heapam.h"
39-
#include"catalog/catname.h"
4039
#include"catalog/namespace.h"
4140
#include"catalog/pg_index.h"
4241
#include"catalog/pg_type.h"
@@ -1538,7 +1537,7 @@ get_pkey_attnames(Oid relid, int16 *numatts)
15381537
*numatts=0;
15391538

15401539
/* use relid to get all related indexes */
1541-
indexRelation=heap_openr(IndexRelationName,AccessShareLock);
1540+
indexRelation=heap_open(IndexRelationId,AccessShareLock);
15421541
ScanKeyInit(&entry,
15431542
Anum_pg_index_indrelid,
15441543
BTEqualStrategyNumber,F_OIDEQ,

‎contrib/intagg/int_aggregate.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include<sys/types.h>
1919

2020
#include"access/heapam.h"
21-
#include"catalog/catname.h"
2221
#include"catalog/indexing.h"
2322
#include"catalog/pg_proc.h"
2423
#include"catalog/pg_type.h"

‎contrib/miscutil/misc_utils.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include"access/relscan.h"
2020
#include"access/skey.h"
2121
#include"access/tupdesc.h"
22-
#include"catalog/catname.h"
2322
#include"catalog/pg_listener.h"
2423
#include"commands/async.h"
2524
#include"fmgr.h"
@@ -75,7 +74,7 @@ active_listeners(text *relname)
7574
intourpid=getpid();
7675
charlisten_name[NAMEDATALEN];
7776

78-
lRel=heap_openr(ListenerRelationName,AccessShareLock);
77+
lRel=heap_open(ListenerRelationId,AccessShareLock);
7978
tdesc=RelationGetDescr(lRel);
8079

8180
if (relname&& (VARSIZE(relname)>VARHDRSZ))

‎src/backend/access/heap/heapam.c

Lines changed: 1 addition & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,15 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.186 2005/03/28 01:50:32 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.187 2005/04/14 20:03:22 tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
1515
*relation_open- open any relation by relation OID
1616
*relation_openrv - open any relation specified by a RangeVar
17-
*relation_openr- open a system relation by name
1817
*relation_close- close any relation
1918
*heap_open- open a heap relation by relation OID
2019
*heap_openrv- open a heap relation specified by a RangeVar
21-
*heap_openr- open a system heap relation by name
2220
*heap_close- (now just a macro for relation_close)
2321
*heap_beginscan- begin relation scan
2422
*heap_rescan- restart a relation scan
@@ -502,15 +500,6 @@ relation_openrv(const RangeVar *relation, LOCKMODE lockmode)
502500
{
503501
OidrelOid;
504502

505-
/*
506-
* In bootstrap mode, don't do any namespace processing.
507-
*/
508-
if (IsBootstrapProcessingMode())
509-
{
510-
Assert(relation->schemaname==NULL);
511-
returnrelation_openr(relation->relname,lockmode);
512-
}
513-
514503
/*
515504
* Check for shared-cache-inval messages before trying to open the
516505
* relation. This is needed to cover the case where the name
@@ -533,37 +522,6 @@ relation_openrv(const RangeVar *relation, LOCKMODE lockmode)
533522
returnrelation_open(relOid,lockmode);
534523
}
535524

536-
/* ----------------
537-
*relation_openr - open a system relation specified by name.
538-
*
539-
*As above, but the relation is specified by an unqualified name;
540-
*it is assumed to live in the system catalog namespace.
541-
* ----------------
542-
*/
543-
Relation
544-
relation_openr(constchar*sysRelationName,LOCKMODElockmode)
545-
{
546-
Relationr;
547-
548-
Assert(lockmode >=NoLock&&lockmode<MAX_LOCKMODES);
549-
550-
/*
551-
* We assume we should not need to worry about the rel's OID changing,
552-
* hence no need for AcceptInvalidationMessages here.
553-
*/
554-
555-
/* The relcache does all the real work... */
556-
r=RelationSysNameGetRelation(sysRelationName);
557-
558-
if (!RelationIsValid(r))
559-
elog(ERROR,"could not open relation \"%s\"",sysRelationName);
560-
561-
if (lockmode!=NoLock)
562-
LockRelation(r,lockmode);
563-
564-
returnr;
565-
}
566-
567525
/* ----------------
568526
*relation_close - close any relation
569527
*
@@ -657,41 +615,6 @@ heap_openrv(const RangeVar *relation, LOCKMODE lockmode)
657615
returnr;
658616
}
659617

660-
/* ----------------
661-
*heap_openr - open a system heap relation specified by name.
662-
*
663-
*As above, but the relation is specified by an unqualified name;
664-
*it is assumed to live in the system catalog namespace.
665-
* ----------------
666-
*/
667-
Relation
668-
heap_openr(constchar*sysRelationName,LOCKMODElockmode)
669-
{
670-
Relationr;
671-
672-
r=relation_openr(sysRelationName,lockmode);
673-
674-
if (r->rd_rel->relkind==RELKIND_INDEX)
675-
ereport(ERROR,
676-
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
677-
errmsg("\"%s\" is an index",
678-
RelationGetRelationName(r))));
679-
elseif (r->rd_rel->relkind==RELKIND_SPECIAL)
680-
ereport(ERROR,
681-
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
682-
errmsg("\"%s\" is a special relation",
683-
RelationGetRelationName(r))));
684-
elseif (r->rd_rel->relkind==RELKIND_COMPOSITE_TYPE)
685-
ereport(ERROR,
686-
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
687-
errmsg("\"%s\" is a composite type",
688-
RelationGetRelationName(r))));
689-
690-
pgstat_initstats(&r->pgstat_info,r);
691-
692-
returnr;
693-
}
694-
695618

696619
/* ----------------
697620
*heap_beginscan- begin relation scan

‎src/backend/access/index/genam.c

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/index/genam.c,v 1.46 2005/03/29 00:16:51 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/index/genam.c,v 1.47 2005/04/14 20:03:23 tgl Exp $
1212
*
1313
* NOTES
1414
* many of the old access method routines have been turned into
@@ -162,7 +162,7 @@ IndexScanEnd(IndexScanDesc scan)
162162
* systable_beginscan --- set up for heap-or-index scan
163163
*
164164
*rel: catalog to scan, already opened and suitably locked
165-
*indexRelname: name of index to conditionally use
165+
*indexId: OID of index to conditionally use
166166
*indexOK: if false, forces a heap scan (see notes below)
167167
*snapshot: time qual to use (usually should be SnapshotNow)
168168
*nkeys, key: scan keys
@@ -179,26 +179,18 @@ IndexScanEnd(IndexScanDesc scan)
179179
*/
180180
SysScanDesc
181181
systable_beginscan(RelationheapRelation,
182-
constchar*indexRelname,
182+
OidindexId,
183183
boolindexOK,
184184
Snapshotsnapshot,
185185
intnkeys,ScanKeykey)
186186
{
187187
SysScanDescsysscan;
188188
Relationirel;
189189

190-
if (indexOK&& !IsIgnoringSystemIndexes())
191-
{
192-
/* We assume it's a system index, so index_openr is OK */
193-
irel=index_openr(indexRelname);
194-
195-
if (ReindexIsProcessingIndex(RelationGetRelid(irel)))
196-
{
197-
/* oops, can't use index that's being rebuilt */
198-
index_close(irel);
199-
irel=NULL;
200-
}
201-
}
190+
if (indexOK&&
191+
!IsIgnoringSystemIndexes()&&
192+
!ReindexIsProcessingIndex(indexId))
193+
irel=index_open(indexId);
202194
else
203195
irel=NULL;
204196

‎src/backend/access/index/indexam.c

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/index/indexam.c,v 1.79 2005/03/27 23:52:59 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/index/indexam.c,v 1.80 2005/04/14 20:03:23 tgl Exp $
1212
*
1313
* INTERFACE ROUTINES
1414
*index_open- open an index relation by relation OID
1515
*index_openrv- open an index relation specified by a RangeVar
16-
*index_openr- open a system index relation by name
1716
*index_close- close an index relation
1817
*index_beginscan - start a scan of an index with amgettuple
1918
*index_beginscan_multi - start a scan of an index with amgetmulti
@@ -172,31 +171,6 @@ index_openrv(const RangeVar *relation)
172171
returnr;
173172
}
174173

175-
/* ----------------
176-
*index_openr - open a system index relation specified by name.
177-
*
178-
*As above, but the relation is specified by an unqualified name;
179-
*it is assumed to live in the system catalog namespace.
180-
* ----------------
181-
*/
182-
Relation
183-
index_openr(constchar*sysRelationName)
184-
{
185-
Relationr;
186-
187-
r=relation_openr(sysRelationName,NoLock);
188-
189-
if (r->rd_rel->relkind!=RELKIND_INDEX)
190-
ereport(ERROR,
191-
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
192-
errmsg("\"%s\" is not an index",
193-
RelationGetRelationName(r))));
194-
195-
pgstat_initstats(&r->pgstat_info,r);
196-
197-
returnr;
198-
}
199-
200174
/* ----------------
201175
*index_close - close a index relation
202176
*

‎src/backend/bootstrap/bootstrap.c

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.201 2005/03/29 19:44:22 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.202 2005/04/14 20:03:23 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -26,12 +26,12 @@
2626
#include"access/heapam.h"
2727
#include"access/xlog.h"
2828
#include"bootstrap/bootstrap.h"
29-
#include"catalog/catname.h"
3029
#include"catalog/index.h"
3130
#include"catalog/pg_type.h"
3231
#include"executor/executor.h"
3332
#include"libpq/pqsignal.h"
3433
#include"miscadmin.h"
34+
#include"nodes/makefuncs.h"
3535
#include"postmaster/bgwriter.h"
3636
#include"storage/freespace.h"
3737
#include"storage/ipc.h"
@@ -46,10 +46,14 @@
4646
#include"utils/ps_status.h"
4747
#include"utils/relcache.h"
4848

49+
externintoptind;
50+
externchar*optarg;
51+
4952

5053
#defineALLOC(t,c)((t *) calloc((unsigned)(c), sizeof(t)))
5154

5255
externintInt_yyparse(void);
56+
5357
staticvoidusage(void);
5458
staticvoidbootstrap_signals(void);
5559
statichashnode*AddStr(char*str,intstrlength,intmderef);
@@ -169,17 +173,12 @@ static struct typmap *Ap = NULL;
169173
staticintWarnings=0;
170174
staticcharBlanks[MAXATTR];
171175

172-
staticchar*relname;/* current relation name */
173-
174176
Form_pg_attributeattrtypes[MAXATTR];/* points to attribute info */
175177
staticDatumvalues[MAXATTR];/* corresponding attribute values */
176178
intnumattr;/* number of attributes for cur. rel */
177179

178180
staticMemoryContextnogc=NULL;/* special no-gc mem context */
179181

180-
externintoptind;
181-
externchar*optarg;
182-
183182
/*
184183
*At bootstrap time, we first declare all the indices to be built, and
185184
*then build them. The IndexList structure stores enough information
@@ -572,12 +571,12 @@ boot_openrel(char *relname)
572571
HeapScanDescscan;
573572
HeapTupletup;
574573

575-
if (strlen(relname) >=NAMEDATALEN-1)
574+
if (strlen(relname) >=NAMEDATALEN)
576575
relname[NAMEDATALEN-1]='\0';
577576

578577
if (Typ==NULL)
579578
{
580-
rel=heap_openr(TypeRelationName,NoLock);
579+
rel=heap_open(TypeRelationId,NoLock);
581580
scan=heap_beginscan(rel,SnapshotNow,0,NULL);
582581
i=0;
583582
while ((tup=heap_getnext(scan,ForwardScanDirection))!=NULL)
@@ -605,10 +604,9 @@ boot_openrel(char *relname)
605604
closerel(NULL);
606605

607606
elog(DEBUG4,"open relation %s, attrsize %d",
608-
relname ?relname :"(null)",
609-
(int)ATTRIBUTE_TUPLE_SIZE);
607+
relname, (int)ATTRIBUTE_TUPLE_SIZE);
610608

611-
boot_reldesc=heap_openr(relname,NoLock);
609+
boot_reldesc=heap_openrv(makeRangeVar(NULL,relname),NoLock);
612610
numattr=boot_reldesc->rd_rel->relnatts;
613611
for (i=0;i<numattr;i++)
614612
{
@@ -641,7 +639,7 @@ closerel(char *name)
641639
{
642640
if (strcmp(RelationGetRelationName(boot_reldesc),name)!=0)
643641
elog(ERROR,"close of %s when %s was expected",
644-
name,relname ?relname :"(null)");
642+
name,RelationGetRelationName(boot_reldesc));
645643
}
646644
else
647645
elog(ERROR,"close of %s before any relation was opened",
@@ -652,7 +650,8 @@ closerel(char *name)
652650
elog(ERROR,"no open relation to close");
653651
else
654652
{
655-
elog(DEBUG4,"close relation %s",relname ?relname :"(null)");
653+
elog(DEBUG4,"close relation %s",
654+
RelationGetRelationName(boot_reldesc));
656655
heap_close(boot_reldesc,NoLock);
657656
boot_reldesc=NULL;
658657
}
@@ -676,7 +675,7 @@ DefineAttr(char *name, char *type, int attnum)
676675
if (boot_reldesc!=NULL)
677676
{
678677
elog(WARNING,"no open relations allowed with CREATE command");
679-
closerel(relname);
678+
closerel(NULL);
680679
}
681680

682681
if (attrtypes[attnum]==NULL)
@@ -933,7 +932,7 @@ gettype(char *type)
933932
returni;
934933
}
935934
elog(DEBUG4,"external type: %s",type);
936-
rel=heap_openr(TypeRelationName,NoLock);
935+
rel=heap_open(TypeRelationId,NoLock);
937936
scan=heap_beginscan(rel,SnapshotNow,0,NULL);
938937
i=0;
939938
while ((tup=heap_getnext(scan,ForwardScanDirection))!=NULL)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp