Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit efa318b

Browse files
committed
Make pg_shseclabel available in early backend startup
While the in-core authentication mechanism doesn't need to access pg_shseclabel at all, it's reasonable to think that an authentication hook will want to look at the label for the role logging in, or for rows in other catalogs used during the authentication phase of startup. Catalog version bumped, because this changes the "is nailed" status for pg_shseclabel. Author: Adam Brightwell
1 parent 83be184 commit efa318b

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

src/backend/utils/cache/relcache.c

+17-9
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#include "catalog/pg_opclass.h"
5252
#include "catalog/pg_proc.h"
5353
#include "catalog/pg_rewrite.h"
54+
#include "catalog/pg_shseclabel.h"
5455
#include "catalog/pg_tablespace.h"
5556
#include "catalog/pg_trigger.h"
5657
#include "catalog/pg_type.h"
@@ -98,6 +99,7 @@ static const FormData_pg_attribute Desc_pg_database[Natts_pg_database] = {Schema
9899
static const FormData_pg_attribute Desc_pg_authid[Natts_pg_authid] = {Schema_pg_authid};
99100
static const FormData_pg_attribute Desc_pg_auth_members[Natts_pg_auth_members] = {Schema_pg_auth_members};
100101
static const FormData_pg_attribute Desc_pg_index[Natts_pg_index] = {Schema_pg_index};
102+
static const FormData_pg_attribute Desc_pg_shseclabel[Natts_pg_shseclabel] = {Schema_pg_shseclabel};
101103

102104
/*
103105
* Hash tables that index the relation cache
@@ -1537,7 +1539,7 @@ LookupOpclassInfo(Oid operatorClassOid,
15371539
* catalogs.
15381540
*
15391541
* formrdesc is currently used for: pg_database, pg_authid, pg_auth_members,
1540-
* pg_class, pg_attribute, pg_proc, and pg_type
1542+
* pg_shseclabel, pg_class, pg_attribute, pg_proc, and pg_type
15411543
* (see RelationCacheInitializePhase2/3).
15421544
*
15431545
* Note that these catalogs can't have constraints (except attnotnull),
@@ -3189,11 +3191,11 @@ RelationCacheInitialize(void)
31893191
*
31903192
* This is called to prepare for access to shared catalogs during startup.
31913193
* We must at least set up nailed reldescs for pg_database, pg_authid,
3192-
* and pg_auth_members. Ideally we'd like to have reldescs for their
3193-
* indexes, too. We attempt to load this information from the shared
3194-
* relcache init file. If that's missing or broken, just make phony
3195-
* entries for the catalogs themselves. RelationCacheInitializePhase3
3196-
* will clean up as needed.
3194+
* pg_auth_members, and pg_shseclabel. Ideally we'd like to have reldescs
3195+
* for their indexes, too. We attempt to load this information from the
3196+
* shared relcache init file. If that's missing or broken, just make
3197+
* phony entries for the catalogs themselves.
3198+
* RelationCacheInitializePhase3 will clean up as needed.
31973199
*/
31983200
void
31993201
RelationCacheInitializePhase2(void)
@@ -3229,8 +3231,10 @@ RelationCacheInitializePhase2(void)
32293231
true, Natts_pg_authid, Desc_pg_authid);
32303232
formrdesc("pg_auth_members", AuthMemRelation_Rowtype_Id, true,
32313233
false, Natts_pg_auth_members, Desc_pg_auth_members);
3234+
formrdesc("pg_shseclabel", SharedSecLabelRelation_Rowtype_Id, true,
3235+
false, Natts_pg_shseclabel, Desc_pg_shseclabel);
32323236

3233-
#define NUM_CRITICAL_SHARED_RELS 3 /* fix if you change list above */
3237+
#define NUM_CRITICAL_SHARED_RELS 4 /* fix if you change list above */
32343238
}
32353239

32363240
MemoryContextSwitchTo(oldcxt);
@@ -3351,7 +3355,9 @@ RelationCacheInitializePhase3(void)
33513355
* non-shared catalogs at all. Autovacuum calls InitPostgres with a
33523356
* database OID, so it instead depends on DatabaseOidIndexId. We also
33533357
* need to nail up some indexes on pg_authid and pg_auth_members for use
3354-
* during client authentication.
3358+
* during client authentication. SharedSecLabelObjectIndexId isn't
3359+
* critical for the core system, but authentication hooks might be
3360+
* interested in it.
33553361
*/
33563362
if (!criticalSharedRelcachesBuilt)
33573363
{
@@ -3365,8 +3371,10 @@ RelationCacheInitializePhase3(void)
33653371
AuthIdRelationId);
33663372
load_critical_index(AuthMemMemRoleIndexId,
33673373
AuthMemRelationId);
3374+
load_critical_index(SharedSecLabelObjectIndexId,
3375+
SharedSecLabelRelationId);
33683376

3369-
#define NUM_CRITICAL_SHARED_INDEXES 5 /* fix if you change list above */
3377+
#define NUM_CRITICAL_SHARED_INDEXES 6 /* fix if you change list above */
33703378

33713379
criticalSharedRelcachesBuilt = true;
33723380
}

src/include/catalog/catversion.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/* yyyymmddN */
56-
#define CATALOG_VERSION_NO 201511071
56+
#define CATALOG_VERSION_NO 201601041
5757

5858
#endif

src/include/catalog/pg_shseclabel.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
* typedef struct FormData_pg_shseclabel
1919
* ----------------
2020
*/
21-
#define SharedSecLabelRelationId 3592
21+
#define SharedSecLabelRelationId 3592
22+
#define SharedSecLabelRelation_Rowtype_Id 4066
2223

23-
CATALOG(pg_shseclabel,3592) BKI_SHARED_RELATION BKI_WITHOUT_OIDS
24+
CATALOG(pg_shseclabel,3592) BKI_SHARED_RELATION BKI_ROWTYPE_OID(4066) BKI_WITHOUT_OIDS BKI_SCHEMA_MACRO
2425
{
2526
Oid objoid; /* OID of the shared object itself */
2627
Oid classoid; /* OID of table containing the shared object */
@@ -31,6 +32,8 @@ CATALOG(pg_shseclabel,3592) BKI_SHARED_RELATION BKI_WITHOUT_OIDS
3132
#endif
3233
} FormData_pg_shseclabel;
3334

35+
typedef FormData_pg_shseclabel *Form_pg_shseclabel;
36+
3437
/* ----------------
3538
* compiler constants for pg_shseclabel
3639
* ----------------

0 commit comments

Comments
 (0)