mirror of
https://github.com/postgres/postgres.git
synced 2025-04-22 23:02:54 +03:00
IsSystemRelationName() treats TOAST relations as system relations.
This seems the right thing for most usages, but I notice two places where it is the wrong thing. One is that the default permissions on TOAST rels should be no-access, not world-readable; the other is that PrepareForTupleInvalidation doesn't really need to spend time looking at tuples of TOAST relations.
This commit is contained in:
parent
aea081bb27
commit
c845b4272c
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.43 2001/08/10 18:57:33 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.44 2001/11/16 23:30:35 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -77,6 +77,10 @@ GetDatabasePath(Oid tblNode)
|
|||||||
* IsSystemRelationName
|
* IsSystemRelationName
|
||||||
* True iff name is the name of a system catalog relation.
|
* True iff name is the name of a system catalog relation.
|
||||||
*
|
*
|
||||||
|
* NB: TOAST relations are considered system relations by this test.
|
||||||
|
* This is appropriate in many places but not all. Where it's not,
|
||||||
|
* also check IsToastRelationName.
|
||||||
|
*
|
||||||
* We now make a new requirement where system catalog relns must begin
|
* We now make a new requirement where system catalog relns must begin
|
||||||
* with pg_ while user relns are forbidden to do so. Make the test
|
* with pg_ while user relns are forbidden to do so. Make the test
|
||||||
* trivial and instantaneous.
|
* trivial and instantaneous.
|
||||||
@ -86,12 +90,20 @@ GetDatabasePath(Oid tblNode)
|
|||||||
bool
|
bool
|
||||||
IsSystemRelationName(const char *relname)
|
IsSystemRelationName(const char *relname)
|
||||||
{
|
{
|
||||||
if (relname[0] && relname[1] && relname[2])
|
/* ugly coding for speed */
|
||||||
return (relname[0] == 'p' &&
|
return (relname[0] == 'p' &&
|
||||||
relname[1] == 'g' &&
|
relname[1] == 'g' &&
|
||||||
relname[2] == '_');
|
relname[2] == '_');
|
||||||
else
|
}
|
||||||
return FALSE;
|
|
||||||
|
/*
|
||||||
|
* IsToastRelationName
|
||||||
|
* True iff name is the name of a TOAST support relation (or index).
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
IsToastRelationName(const char *relname)
|
||||||
|
{
|
||||||
|
return strncmp(relname, "pg_toast_", 9) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.65 2001/10/25 05:49:43 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.66 2001/11/16 23:30:35 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -385,7 +385,9 @@ acldefault(const char *relname, AclId ownerid)
|
|||||||
aip = ACL_DAT(acl);
|
aip = ACL_DAT(acl);
|
||||||
aip[0].ai_idtype = ACL_IDTYPE_WORLD;
|
aip[0].ai_idtype = ACL_IDTYPE_WORLD;
|
||||||
aip[0].ai_id = ACL_ID_WORLD;
|
aip[0].ai_id = ACL_ID_WORLD;
|
||||||
aip[0].ai_mode = IsSystemRelationName(relname) ? ACL_SELECT : ACL_WORLD_DEFAULT;
|
aip[0].ai_mode = (IsSystemRelationName(relname) &&
|
||||||
|
!IsToastRelationName(relname)) ? ACL_SELECT
|
||||||
|
: ACL_WORLD_DEFAULT;
|
||||||
aip[1].ai_idtype = ACL_IDTYPE_UID;
|
aip[1].ai_idtype = ACL_IDTYPE_UID;
|
||||||
aip[1].ai_id = ownerid;
|
aip[1].ai_id = ownerid;
|
||||||
aip[1].ai_mode = ACL_OWNER_DEFAULT;
|
aip[1].ai_mode = ACL_OWNER_DEFAULT;
|
||||||
|
6
src/backend/utils/cache/inval.c
vendored
6
src/backend/utils/cache/inval.c
vendored
@ -56,7 +56,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.46 2001/10/25 05:49:46 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.47 2001/11/16 23:30:35 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -437,9 +437,13 @@ PrepareForTupleInvalidation(Relation relation, HeapTuple tuple,
|
|||||||
* We only need to worry about invalidation for tuples that are in
|
* We only need to worry about invalidation for tuples that are in
|
||||||
* system relations; user-relation tuples are never in catcaches and
|
* system relations; user-relation tuples are never in catcaches and
|
||||||
* can't affect the relcache either.
|
* can't affect the relcache either.
|
||||||
|
*
|
||||||
|
* TOAST tuples can likewise be ignored here.
|
||||||
*/
|
*/
|
||||||
if (!IsSystemRelationName(NameStr(RelationGetForm(relation)->relname)))
|
if (!IsSystemRelationName(NameStr(RelationGetForm(relation)->relname)))
|
||||||
return;
|
return;
|
||||||
|
if (IsToastRelationName(NameStr(RelationGetForm(relation)->relname)))
|
||||||
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First let the catcache do its thing
|
* First let the catcache do its thing
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: catalog.h,v 1.20 2001/11/05 17:46:31 momjian Exp $
|
* $Id: catalog.h,v 1.21 2001/11/16 23:30:35 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -22,6 +22,7 @@ extern char *relpath(RelFileNode rnode);
|
|||||||
extern char *GetDatabasePath(Oid tblNode);
|
extern char *GetDatabasePath(Oid tblNode);
|
||||||
|
|
||||||
extern bool IsSystemRelationName(const char *relname);
|
extern bool IsSystemRelationName(const char *relname);
|
||||||
|
extern bool IsToastRelationName(const char *relname);
|
||||||
extern bool IsSharedSystemRelationName(const char *relname);
|
extern bool IsSharedSystemRelationName(const char *relname);
|
||||||
|
|
||||||
extern Oid newoid(void);
|
extern Oid newoid(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user