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

Commitc845b42

Browse files
committed
IsSystemRelationName() treats TOAST relations as system relations.
This seems the right thing for most usages, but I notice two placeswhere it is the wrong thing. One is that the default permissions onTOAST rels should be no-access, not world-readable; the other is thatPrepareForTupleInvalidation doesn't really need to spend time lookingat tuples of TOAST relations.
1 parentaea081b commitc845b42

File tree

4 files changed

+30
-11
lines changed

4 files changed

+30
-11
lines changed

‎src/backend/catalog/catalog.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.43 2001/08/10 18:57:33 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.44 2001/11/16 23:30:35 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -77,6 +77,10 @@ GetDatabasePath(Oid tblNode)
7777
* IsSystemRelationName
7878
*True iff name is the name of a system catalog relation.
7979
*
80+
*NB: TOAST relations are considered system relations by this test.
81+
*This is appropriate in many places but not all. Where it's not,
82+
*also check IsToastRelationName.
83+
*
8084
*We now make a new requirement where system catalog relns must begin
8185
*with pg_ while user relns are forbidden to do so. Make the test
8286
*trivial and instantaneous.
@@ -86,12 +90,20 @@ GetDatabasePath(Oid tblNode)
8690
bool
8791
IsSystemRelationName(constchar*relname)
8892
{
89-
if (relname[0]&&relname[1]&&relname[2])
90-
return (relname[0]=='p'&&
91-
relname[1]=='g'&&
92-
relname[2]=='_');
93-
else
94-
return FALSE;
93+
/* ugly coding for speed */
94+
return (relname[0]=='p'&&
95+
relname[1]=='g'&&
96+
relname[2]=='_');
97+
}
98+
99+
/*
100+
* IsToastRelationName
101+
*True iff name is the name of a TOAST support relation (or index).
102+
*/
103+
bool
104+
IsToastRelationName(constchar*relname)
105+
{
106+
returnstrncmp(relname,"pg_toast_",9)==0;
95107
}
96108

97109
/*

‎src/backend/utils/adt/acl.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.65 2001/10/25 05:49:43 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.66 2001/11/16 23:30:35 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -385,7 +385,9 @@ acldefault(const char *relname, AclId ownerid)
385385
aip=ACL_DAT(acl);
386386
aip[0].ai_idtype=ACL_IDTYPE_WORLD;
387387
aip[0].ai_id=ACL_ID_WORLD;
388-
aip[0].ai_mode=IsSystemRelationName(relname) ?ACL_SELECT :ACL_WORLD_DEFAULT;
388+
aip[0].ai_mode= (IsSystemRelationName(relname)&&
389+
!IsToastRelationName(relname)) ?ACL_SELECT
390+
:ACL_WORLD_DEFAULT;
389391
aip[1].ai_idtype=ACL_IDTYPE_UID;
390392
aip[1].ai_id=ownerid;
391393
aip[1].ai_mode=ACL_OWNER_DEFAULT;

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
* Portions Copyright (c) 1994, Regents of the University of California
5757
*
5858
* IDENTIFICATION
59-
* $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.46 2001/10/25 05:49:46 momjian Exp $
59+
* $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.47 2001/11/16 23:30:35 tgl Exp $
6060
*
6161
*-------------------------------------------------------------------------
6262
*/
@@ -437,9 +437,13 @@ PrepareForTupleInvalidation(Relation relation, HeapTuple tuple,
437437
* We only need to worry about invalidation for tuples that are in
438438
* system relations; user-relation tuples are never in catcaches and
439439
* can't affect the relcache either.
440+
*
441+
* TOAST tuples can likewise be ignored here.
440442
*/
441443
if (!IsSystemRelationName(NameStr(RelationGetForm(relation)->relname)))
442444
return;
445+
if (IsToastRelationName(NameStr(RelationGetForm(relation)->relname)))
446+
return;
443447

444448
/*
445449
* First let the catcache do its thing

‎src/include/catalog/catalog.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: catalog.h,v 1.20 2001/11/05 17:46:31 momjian Exp $
10+
* $Id: catalog.h,v 1.21 2001/11/16 23:30:35 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -22,6 +22,7 @@ extern char *relpath(RelFileNode rnode);
2222
externchar*GetDatabasePath(OidtblNode);
2323

2424
externboolIsSystemRelationName(constchar*relname);
25+
externboolIsToastRelationName(constchar*relname);
2526
externboolIsSharedSystemRelationName(constchar*relname);
2627

2728
externOidnewoid(void);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp