Make pg_shseclabel available in early backend startup
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Tue, 5 Jan 2016 17:50:53 +0000 (14:50 -0300)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Tue, 5 Jan 2016 17:50:53 +0000 (14:50 -0300)
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

src/backend/utils/cache/relcache.c
src/include/catalog/catversion.h
src/include/catalog/pg_shseclabel.h

index 114b7a707c7f6a277f813e584033ab72f05e3115..fc5b9d99340934479a45324974cb8cfaf21e13ff 100644 (file)
@@ -51,6 +51,7 @@
 #include "catalog/pg_opclass.h"
 #include "catalog/pg_proc.h"
 #include "catalog/pg_rewrite.h"
+#include "catalog/pg_shseclabel.h"
 #include "catalog/pg_tablespace.h"
 #include "catalog/pg_trigger.h"
 #include "catalog/pg_type.h"
@@ -98,6 +99,7 @@ static const FormData_pg_attribute Desc_pg_database[Natts_pg_database] = {Schema
 static const FormData_pg_attribute Desc_pg_authid[Natts_pg_authid] = {Schema_pg_authid};
 static const FormData_pg_attribute Desc_pg_auth_members[Natts_pg_auth_members] = {Schema_pg_auth_members};
 static const FormData_pg_attribute Desc_pg_index[Natts_pg_index] = {Schema_pg_index};
+static const FormData_pg_attribute Desc_pg_shseclabel[Natts_pg_shseclabel] = {Schema_pg_shseclabel};
 
 /*
  *     Hash tables that index the relation cache
@@ -1537,7 +1539,7 @@ LookupOpclassInfo(Oid operatorClassOid,
  *     catalogs.
  *
  * formrdesc is currently used for: pg_database, pg_authid, pg_auth_members,
- * pg_class, pg_attribute, pg_proc, and pg_type
+ * pg_shseclabel, pg_class, pg_attribute, pg_proc, and pg_type
  * (see RelationCacheInitializePhase2/3).
  *
  * Note that these catalogs can't have constraints (except attnotnull),
@@ -3189,11 +3191,11 @@ RelationCacheInitialize(void)
  *
  *     This is called to prepare for access to shared catalogs during startup.
  *     We must at least set up nailed reldescs for pg_database, pg_authid,
- *     and pg_auth_members.  Ideally we'd like to have reldescs for their
- *     indexes, too.  We attempt to load this information from the shared
- *     relcache init file.  If that's missing or broken, just make phony
- *     entries for the catalogs themselves.  RelationCacheInitializePhase3
- *     will clean up as needed.
+ *     pg_auth_members, and pg_shseclabel. Ideally we'd like to have reldescs
+ *     for their indexes, too.  We attempt to load this information from the
+ *     shared relcache init file.  If that's missing or broken, just make
+ *     phony entries for the catalogs themselves.
+ *     RelationCacheInitializePhase3 will clean up as needed.
  */
 void
 RelationCacheInitializePhase2(void)
@@ -3229,8 +3231,10 @@ RelationCacheInitializePhase2(void)
                  true, Natts_pg_authid, Desc_pg_authid);
        formrdesc("pg_auth_members", AuthMemRelation_Rowtype_Id, true,
                  false, Natts_pg_auth_members, Desc_pg_auth_members);
+       formrdesc("pg_shseclabel", SharedSecLabelRelation_Rowtype_Id, true,
+                 false, Natts_pg_shseclabel, Desc_pg_shseclabel);
 
-#define NUM_CRITICAL_SHARED_RELS   3   /* fix if you change list above */
+#define NUM_CRITICAL_SHARED_RELS   4   /* fix if you change list above */
    }
 
    MemoryContextSwitchTo(oldcxt);
@@ -3351,7 +3355,9 @@ RelationCacheInitializePhase3(void)
     * non-shared catalogs at all.  Autovacuum calls InitPostgres with a
     * database OID, so it instead depends on DatabaseOidIndexId.  We also
     * need to nail up some indexes on pg_authid and pg_auth_members for use
-    * during client authentication.
+    * during client authentication.  SharedSecLabelObjectIndexId isn't
+    * critical for the core system, but authentication hooks might be
+    * interested in it.
     */
    if (!criticalSharedRelcachesBuilt)
    {
@@ -3365,8 +3371,10 @@ RelationCacheInitializePhase3(void)
                            AuthIdRelationId);
        load_critical_index(AuthMemMemRoleIndexId,
                            AuthMemRelationId);
+       load_critical_index(SharedSecLabelObjectIndexId,
+                           SharedSecLabelRelationId);
 
-#define NUM_CRITICAL_SHARED_INDEXES 5  /* fix if you change list above */
+#define NUM_CRITICAL_SHARED_INDEXES 6  /* fix if you change list above */
 
        criticalSharedRelcachesBuilt = true;
    }
index 3c3757fd35ca7f81338439384de823ad5bb33d0a..0e66e9286b82b3b37e660d38efeb762adcd947d1 100644 (file)
@@ -53,6 +53,6 @@
  */
 
 /*                         yyyymmddN */
-#define CATALOG_VERSION_NO 201511071
+#define CATALOG_VERSION_NO 201601041
 
 #endif
index 03b5cee7adf2d8eb070fbe1f3b0e0cab0b0814a9..c39e11df34c7fa8340e0ca8d46faf27bf5a4bfd3 100644 (file)
  *     typedef struct FormData_pg_shseclabel
  * ----------------
  */
-#define SharedSecLabelRelationId       3592
+#define SharedSecLabelRelationId           3592
+#define SharedSecLabelRelation_Rowtype_Id  4066
 
-CATALOG(pg_shseclabel,3592) BKI_SHARED_RELATION BKI_WITHOUT_OIDS
+CATALOG(pg_shseclabel,3592) BKI_SHARED_RELATION BKI_ROWTYPE_OID(4066) BKI_WITHOUT_OIDS BKI_SCHEMA_MACRO
 {
    Oid         objoid;         /* OID of the shared object itself */
    Oid         classoid;       /* OID of table containing the shared object */
@@ -31,6 +32,8 @@ CATALOG(pg_shseclabel,3592) BKI_SHARED_RELATION BKI_WITHOUT_OIDS
 #endif
 } FormData_pg_shseclabel;
 
+typedef FormData_pg_shseclabel *Form_pg_shseclabel;
+
 /* ----------------
  *     compiler constants for pg_shseclabel
  * ----------------