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

Commitca70c3c

Browse files
committed
Revert my ill-considered change that made formrdesc not insert the correct
relation rowtype OID into the relcache entries it builds. This ensuresthat catcache copies of the relation tupdescs will be fully correct.While the deficiency doesn't seem to have any effect in the currentsources, we have been bitten by not-quite-right catcache tupdescs before,so it seems like a good idea to maintain the rule that they should be right.
1 parent4985635 commitca70c3c

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

‎src/backend/utils/cache/relcache.c

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.291 2009/09/2618:24:49 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.292 2009/09/2623:08:22 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -203,8 +203,9 @@ static bool load_relcache_init_file(bool shared);
203203
staticvoidwrite_relcache_init_file(boolshared);
204204
staticvoidwrite_item(constvoid*data,Sizelen,FILE*fp);
205205

206-
staticvoidformrdesc(constchar*relationName,boolisshared,
207-
boolhasoids,intnatts,constFormData_pg_attribute*attrs);
206+
staticvoidformrdesc(constchar*relationName,OidrelationReltype,
207+
boolisshared,boolhasoids,
208+
intnatts,constFormData_pg_attribute*attrs);
208209

209210
staticHeapTupleScanPgRelation(OidtargetRelId,boolindexOK);
210211
staticRelationAllocateRelationDesc(Relationrelation,Form_pg_classrelp);
@@ -1374,8 +1375,9 @@ LookupOpclassInfo(Oid operatorClassOid,
13741375
* NOTE: we assume we are already switched into CacheMemoryContext.
13751376
*/
13761377
staticvoid
1377-
formrdesc(constchar*relationName,boolisshared,
1378-
boolhasoids,intnatts,constFormData_pg_attribute*attrs)
1378+
formrdesc(constchar*relationName,OidrelationReltype,
1379+
boolisshared,boolhasoids,
1380+
intnatts,constFormData_pg_attribute*attrs)
13791381
{
13801382
Relationrelation;
13811383
inti;
@@ -1420,6 +1422,7 @@ formrdesc(const char *relationName, bool isshared,
14201422

14211423
namestrcpy(&relation->rd_rel->relname,relationName);
14221424
relation->rd_rel->relnamespace=PG_CATALOG_NAMESPACE;
1425+
relation->rd_rel->reltype=relationReltype;
14231426

14241427
/*
14251428
* It's important to distinguish between shared and non-shared relations,
@@ -1451,6 +1454,9 @@ formrdesc(const char *relationName, bool isshared,
14511454
relation->rd_att=CreateTemplateTupleDesc(natts,hasoids);
14521455
relation->rd_att->tdrefcount=1;/* mark as refcounted */
14531456

1457+
relation->rd_att->tdtypeid=relationReltype;
1458+
relation->rd_att->tdtypmod=-1;/* unnecessary, but... */
1459+
14541460
/*
14551461
* initialize tuple desc info
14561462
*/
@@ -2558,7 +2564,7 @@ RelationCacheInitializePhase2(void)
25582564
*/
25592565
if (!load_relcache_init_file(true))
25602566
{
2561-
formrdesc("pg_database", true,
2567+
formrdesc("pg_database",DatabaseRelation_Rowtype_Id,true,
25622568
true,Natts_pg_database,Desc_pg_database);
25632569

25642570
#defineNUM_CRITICAL_SHARED_RELS1/* fix if you change list above */
@@ -2604,13 +2610,13 @@ RelationCacheInitializePhase3(void)
26042610
{
26052611
needNewCacheFile= true;
26062612

2607-
formrdesc("pg_class", false,
2613+
formrdesc("pg_class",RelationRelation_Rowtype_Id,false,
26082614
true,Natts_pg_class,Desc_pg_class);
2609-
formrdesc("pg_attribute", false,
2615+
formrdesc("pg_attribute",AttributeRelation_Rowtype_Id,false,
26102616
false,Natts_pg_attribute,Desc_pg_attribute);
2611-
formrdesc("pg_proc", false,
2617+
formrdesc("pg_proc",ProcedureRelation_Rowtype_Id,false,
26122618
true,Natts_pg_proc,Desc_pg_proc);
2613-
formrdesc("pg_type", false,
2619+
formrdesc("pg_type",TypeRelation_Rowtype_Id,false,
26142620
true,Natts_pg_type,Desc_pg_type);
26152621

26162622
#defineNUM_CRITICAL_LOCAL_RELS4/* fix if you change list above */
@@ -2738,11 +2744,14 @@ RelationCacheInitializePhase3(void)
27382744
RelationParseRelOptions(relation,htup);
27392745

27402746
/*
2741-
* Also update the derived fields in rd_att.
2747+
* Check the values in rd_att were set up correctly. (We cannot
2748+
* just copy them over now: formrdesc must have set up the
2749+
* rd_att data correctly to start with, because it may already
2750+
* have been copied into one or more catcache entries.)
27422751
*/
2743-
relation->rd_att->tdtypeid=relp->reltype;
2744-
relation->rd_att->tdtypmod=-1;/* unnecessary, but... */
2745-
relation->rd_att->tdhasoid=relp->relhasoids;
2752+
Assert(relation->rd_att->tdtypeid==relp->reltype);
2753+
Assert(relation->rd_att->tdtypmod==-1);
2754+
Assert(relation->rd_att->tdhasoid==relp->relhasoids);
27462755

27472756
ReleaseSysCache(htup);
27482757

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp