LCOV - differential code coverage report
Current view: top level - src/backend/catalog - catalog.c (source / functions) Coverage Total Hit LBC UBC GNC CBC DCB
Current: 4b3c9325757dfd8f2312e9f1a8decf4431f344ae vs e87b024bfb8dd55e3049b1b6e6ab4e810cf1abc8 Lines: 80.2 % 187 150 37 8 142 1
Current Date: 2026-11-28 16:48:44 +0900 Functions: 95.2 % 21 20 1 3 17
Baseline: lcov-20261128-baseline Branches: 75.3 % 219 165 1 53 6 159
Baseline Date: 2026-11-28 16:48:48 +0900 Line coverage date bins:
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
(7,30] days: 100.0 % 10 10 10
(30,360] days: 100.0 % 8 8 8
(360..) days: 78.1 % 169 132 37 132
Function coverage date bins:
(7,30] days: 100.0 % 1 1 1
(30,360] days: 100.0 % 2 2 2
(360..) days: 94.4 % 18 17 1 1 16
Branch coverage date bins:
(7,30] days: 81.8 % 22 18 4 18
(30,360] days: 100.0 % 6 6 6
(360..) days: 73.8 % 191 141 1 49 141

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : /*-------------------------------------------------------------------------
                                  2                 :                :  *
                                  3                 :                :  * catalog.c
                                  4                 :                :  *      routines concerned with catalog naming conventions and other
                                  5                 :                :  *      bits of hard-wired knowledge
                                  6                 :                :  *
                                  7                 :                :  *
                                  8                 :                :  * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
                                  9                 :                :  * Portions Copyright (c) 1994, Regents of the University of California
                                 10                 :                :  *
                                 11                 :                :  *
                                 12                 :                :  * IDENTIFICATION
                                 13                 :                :  *    src/backend/catalog/catalog.c
                                 14                 :                :  *
                                 15                 :                :  *-------------------------------------------------------------------------
                                 16                 :                :  */
                                 17                 :                : 
                                 18                 :                : #include "postgres.h"
                                 19                 :                : 
                                 20                 :                : #include <fcntl.h>
                                 21                 :                : #include <unistd.h>
                                 22                 :                : 
                                 23                 :                : #include "access/genam.h"
                                 24                 :                : #include "access/htup_details.h"
                                 25                 :                : #include "access/table.h"
                                 26                 :                : #include "access/transam.h"
                                 27                 :                : #include "catalog/catalog.h"
                                 28                 :                : #include "catalog/namespace.h"
                                 29                 :                : #include "catalog/pg_auth_members.h"
                                 30                 :                : #include "catalog/pg_authid.h"
                                 31                 :                : #include "catalog/pg_database.h"
                                 32                 :                : #include "catalog/pg_db_role_setting.h"
                                 33                 :                : #include "catalog/pg_largeobject.h"
                                 34                 :                : #include "catalog/pg_namespace.h"
                                 35                 :                : #include "catalog/pg_parameter_acl.h"
                                 36                 :                : #include "catalog/pg_replication_origin.h"
                                 37                 :                : #include "catalog/pg_seclabel.h"
                                 38                 :                : #include "catalog/pg_shdepend.h"
                                 39                 :                : #include "catalog/pg_shdescription.h"
                                 40                 :                : #include "catalog/pg_shseclabel.h"
                                 41                 :                : #include "catalog/pg_subscription.h"
                                 42                 :                : #include "catalog/pg_tablespace.h"
                                 43                 :                : #include "catalog/pg_type.h"
                                 44                 :                : #include "miscadmin.h"
                                 45                 :                : #include "utils/fmgroids.h"
                                 46                 :                : #include "utils/fmgrprotos.h"
                                 47                 :                : #include "utils/rel.h"
                                 48                 :                : #include "utils/snapmgr.h"
                                 49                 :                : #include "utils/syscache.h"
                                 50                 :                : 
                                 51                 :                : /*
                                 52                 :                :  * Parameters to determine when to emit a log message in
                                 53                 :                :  * GetNewOidWithIndex()
                                 54                 :                :  */
                                 55                 :                : #define GETNEWOID_LOG_THRESHOLD 1000000
                                 56                 :                : #define GETNEWOID_LOG_MAX_INTERVAL 128000000
                                 57                 :                : 
                                 58                 :                : /*
                                 59                 :                :  * IsSystemRelation
                                 60                 :                :  *      True iff the relation is either a system catalog or a toast table.
                                 61                 :                :  *      See IsCatalogRelation for the exact definition of a system catalog.
                                 62                 :                :  *
                                 63                 :                :  *      We treat toast tables of user relations as "system relations" for
                                 64                 :                :  *      protection purposes, e.g. you can't change their schemas without
                                 65                 :                :  *      special permissions.  Therefore, most uses of this function are
                                 66                 :                :  *      checking whether allow_system_table_mods restrictions apply.
                                 67                 :                :  *      For other purposes, consider whether you shouldn't be using
                                 68                 :                :  *      IsCatalogRelation instead.
                                 69                 :                :  *
                                 70                 :                :  *      This function does not perform any catalog accesses.
                                 71                 :                :  *      Some callers rely on that!
                                 72                 :                :  */
                                 73                 :                : bool
 8996 tgl@sss.pgh.pa.us          74                 :CBC      686483 : IsSystemRelation(Relation relation)
                                 75                 :                : {
 4748 rhaas@postgresql.org       76                 :         686483 :     return IsSystemClass(RelationGetRelid(relation), relation->rd_rel);
                                 77                 :                : }
                                 78                 :                : 
                                 79                 :                : /*
                                 80                 :                :  * IsSystemClass
                                 81                 :                :  *      Like the above, but takes a Form_pg_class as argument.
                                 82                 :                :  *      Used when we do not want to open the relation and have to
                                 83                 :                :  *      search pg_class directly.
                                 84                 :                :  */
                                 85                 :                : bool
                                 86                 :         754645 : IsSystemClass(Oid relid, Form_pg_class reltuple)
                                 87                 :                : {
                                 88                 :                :     /* IsCatalogRelationOid is a bit faster, so test that first */
  149 akapila@postgresql.o       89         [ +  + ]:GNC      922004 :     return (IsCatalogRelationOid(relid) ||
                                 90   [ +  +  +  + ]:         922004 :             IsToastClass(reltuple) ||
                                 91                 :         152517 :             IsConflictLogTableClass(reltuple));
                                 92                 :                : }
                                 93                 :                : 
                                 94                 :                : /*
                                 95                 :                :  * IsCatalogRelation
                                 96                 :                :  *      True iff the relation is a system catalog.
                                 97                 :                :  *
                                 98                 :                :  *      By a system catalog, we mean one that is created during the bootstrap
                                 99                 :                :  *      phase of initdb.  That includes not just the catalogs per se, but
                                100                 :                :  *      also their indexes, and TOAST tables and indexes if any.
                                101                 :                :  *
                                102                 :                :  *      This function does not perform any catalog accesses.
                                103                 :                :  *      Some callers rely on that!
                                104                 :                :  */
                                105                 :                : bool
 4748 rhaas@postgresql.org      106                 :CBC    33826980 : IsCatalogRelation(Relation relation)
                                107                 :                : {
 2761 tgl@sss.pgh.pa.us         108                 :       33826980 :     return IsCatalogRelationOid(RelationGetRelid(relation));
                                109                 :                : }
                                110                 :                : 
                                111                 :                : /*
                                112                 :                :  * IsCatalogRelationOid
                                113                 :                :  *      True iff the relation identified by this OID is a system catalog.
                                114                 :                :  *
                                115                 :                :  *      By a system catalog, we mean one that is created during the bootstrap
                                116                 :                :  *      phase of initdb.  That includes not just the catalogs per se, but
                                117                 :                :  *      also their indexes, and TOAST tables and indexes if any.
                                118                 :                :  *
                                119                 :                :  *      This function does not perform any catalog accesses.
                                120                 :                :  *      Some callers rely on that!
                                121                 :                :  */
                                122                 :                : bool
                                123                 :      395579246 : IsCatalogRelationOid(Oid relid)
                                124                 :                : {
                                125                 :                :     /*
                                126                 :                :      * We consider a relation to be a system catalog if it has a pinned OID.
                                127                 :                :      * This includes all the defined catalogs, their indexes, and their TOAST
                                128                 :                :      * tables and indexes.
                                129                 :                :      *
                                130                 :                :      * This rule excludes the relations in information_schema, which are not
                                131                 :                :      * integral to the system and can be treated the same as user relations.
                                132                 :                :      * (Since it's valid to drop and recreate information_schema, any rule
                                133                 :                :      * that did not act this way would be wrong.)
                                134                 :                :      *
                                135                 :                :      * This test is reliable since an OID wraparound will skip this range of
                                136                 :                :      * OIDs; see GetNewObjectId().
                                137                 :                :      */
 1962                           138                 :      395579246 :     return (relid < (Oid) FirstUnpinnedObjectId);
                                139                 :                : }
                                140                 :                : 
                                141                 :                : /*
                                142                 :                :  * IsCatalogTextUniqueIndexOid
                                143                 :                :  *      True iff the relation identified by this OID is a catalog UNIQUE index
                                144                 :                :  *      having a column of type "text".
                                145                 :                :  *
                                146                 :                :  *      The relcache must not use these indexes.  Inserting into any UNIQUE
                                147                 :                :  *      index compares index keys while holding BUFFER_LOCK_EXCLUSIVE.
                                148                 :                :  *      bttextcmp() can search the COLLOID catcache.  Depending on concurrent
                                149                 :                :  *      invalidation traffic, catcache can reach relcache builds.  A backend
                                150                 :                :  *      would self-deadlock on LWLocks if the relcache build read the
                                151                 :                :  *      exclusive-locked buffer.
                                152                 :                :  *
                                153                 :                :  *      To avoid being itself the cause of self-deadlock, this doesn't read
                                154                 :                :  *      catalogs.  Instead, it uses a hard-coded list with a supporting
                                155                 :                :  *      regression test.
                                156                 :                :  */
                                157                 :                : bool
  590 noah@leadboat.com         158                 :          12602 : IsCatalogTextUniqueIndexOid(Oid relid)
                                159                 :                : {
                                160         [ +  + ]:          12602 :     switch (relid)
                                161                 :                :     {
                                162                 :             16 :         case ParameterAclParnameIndexId:
                                163                 :                :         case ReplicationOriginNameIndex:
                                164                 :                :         case SecLabelObjectIndexId:
                                165                 :                :         case SharedSecLabelObjectIndexId:
                                166                 :             16 :             return true;
                                167                 :                :     }
                                168                 :          12586 :     return false;
                                169                 :                : }
                                170                 :                : 
                                171                 :                : /*
                                172                 :                :  * IsInplaceUpdateRelation
                                173                 :                :  *      True iff core code performs inplace updates on the relation.
                                174                 :                :  *
                                175                 :                :  *      This is used for assertions and for making the executor follow the
                                176                 :                :  *      locking protocol described at README.tuplock section "Locking to write
                                177                 :                :  *      inplace-updated tables".  Extensions may inplace-update other heap
                                178                 :                :  *      tables, but concurrent SQL UPDATE on the same table may overwrite
                                179                 :                :  *      those modifications.
                                180                 :                :  *
                                181                 :                :  *      The executor can assume these are not partitions or partitioned and
                                182                 :                :  *      have no triggers.
                                183                 :                :  */
                                184                 :                : bool
  884                           185                 :        2800457 : IsInplaceUpdateRelation(Relation relation)
                                186                 :                : {
                                187                 :        2800457 :     return IsInplaceUpdateOid(RelationGetRelid(relation));
                                188                 :                : }
                                189                 :                : 
                                190                 :                : /*
                                191                 :                :  * IsInplaceUpdateOid
                                192                 :                :  *      Like the above, but takes an OID as argument.
                                193                 :                :  */
                                194                 :                : bool
                                195                 :        2800457 : IsInplaceUpdateOid(Oid relid)
                                196                 :                : {
                                197   [ +  +  +  + ]:        2800457 :     return (relid == RelationRelationId ||
                                198                 :                :             relid == DatabaseRelationId);
                                199                 :                : }
                                200                 :                : 
                                201                 :                : /*
                                202                 :                :  * HasVersionedAttributes
                                203                 :                :  *      Return whether the relation has versioned attributes.
                                204                 :                :  */
                                205                 :                : bool
   19 andres@anarazel.de        206                 :        3279676 : HasVersionedAttributes(Relation relation)
                                207                 :                : {
                                208         [ -  + ]:        3279676 :     Assert(RelationGetRelid(relation) != InvalidOid);
                                209                 :                : 
                                210                 :                :     /*
                                211                 :                :      * If the relation does not have a rowtype, its attributes obviously are
                                212                 :                :      * not versioned, since attribute versioning exists to protect against
                                213                 :                :      * deforming composite datums incompatible with the current type
                                214                 :                :      * definition.
                                215                 :                :      */
                                216   [ +  +  +  +  :        3279676 :     if (!RELKIND_HAS_ROWTYPE(relation->rd_rel->relkind))
                                     +  +  +  +  +  
                                           +  +  + ]
                                217                 :                :     {
                                218         [ -  + ]:        1889129 :         Assert(relation->rd_rel->reltype == InvalidOid);
                                219                 :        1889129 :         return false;
                                220                 :                :     }
                                221                 :                : 
                                222         [ -  + ]:        1390547 :     Assert(relation->rd_rel->reltype != InvalidOid);
                                223                 :                : 
                                224                 :                :     /*
                                225                 :                :      * Bootstrapped relations are not versioned, for two reasons:
                                226                 :                :      *
                                227                 :                :      * First, they can't ever change, i.e. we never need to detect mismatches.
                                228                 :                :      *
                                229                 :                :      * Second, to determine an attribute's version, we might need to do
                                230                 :                :      * syscache lookups, which could lead to recursion dangers (this is not
                                231                 :                :      * the case right now, but might again be at a later point). As there's no
                                232                 :                :      * reason to version, it's not worth analyzing further.
                                233                 :                :      */
                                234         [ +  + ]:        1390547 :     if (RelationGetRelid(relation) < FirstUnpinnedObjectId)
                                235                 :        1039084 :         return false;
                                236                 :                : 
                                237         [ -  + ]:         351463 :     Assert(!IsBootstrapProcessingMode());
                                238                 :                : 
                                239                 :         351463 :     return true;
                                240                 :                : }
                                241                 :                : 
                                242                 :                : /*
                                243                 :                :  * IsToastRelation
                                244                 :                :  *      True iff relation is a TOAST support relation (or index).
                                245                 :                :  *
                                246                 :                :  *      Does not perform any catalog accesses.
                                247                 :                :  */
                                248                 :                : bool
 8996 tgl@sss.pgh.pa.us         249                 :        3387229 : IsToastRelation(Relation relation)
                                250                 :                : {
                                251                 :                :     /*
                                252                 :                :      * What we actually check is whether the relation belongs to a pg_toast
                                253                 :                :      * namespace.  This should be equivalent because of restrictions that are
                                254                 :                :      * enforced elsewhere against creating user relations in, or moving
                                255                 :                :      * relations into/out of, a pg_toast namespace.  Notice also that this
                                256                 :                :      * will not say "true" for toast tables belonging to other sessions' temp
                                257                 :                :      * tables; we expect that other mechanisms will prevent access to those.
                                258                 :                :      */
                                259                 :        3387229 :     return IsToastNamespace(RelationGetNamespace(relation));
                                260                 :                : }
                                261                 :                : 
                                262                 :                : /*
                                263                 :                :  * IsToastClass
                                264                 :                :  *      Like the above, but takes a Form_pg_class as argument.
                                265                 :                :  *      Used when we do not want to open the relation and have to
                                266                 :                :  *      search pg_class directly.
                                267                 :                :  */
                                268                 :                : bool
                                269                 :         167359 : IsToastClass(Form_pg_class reltuple)
                                270                 :                : {
 8851 bruce@momjian.us          271                 :         167359 :     Oid         relnamespace = reltuple->relnamespace;
                                272                 :                : 
                                273                 :         167359 :     return IsToastNamespace(relnamespace);
                                274                 :                : }
                                275                 :                : 
                                276                 :                : /*
                                277                 :                :  * IsConflictLogTableClass
                                278                 :                :  *      True iff pg_class tuple represents a Conflict Log Table.
                                279                 :                :  *
                                280                 :                :  *      Does not perform any catalog accesses.  See
                                281                 :                :  *      IsConflictLogTableNamespace() for why operations on these tables are
                                282                 :                :  *      restricted.
                                283                 :                :  */
                                284                 :                : bool
  149 akapila@postgresql.o      285                 :GNC      560645 : IsConflictLogTableClass(Form_pg_class reltuple)
                                286                 :                : {
                                287                 :         560645 :     Oid         relnamespace = reltuple->relnamespace;
                                288                 :                : 
                                289                 :         560645 :     return IsConflictLogTableNamespace(relnamespace);
                                290                 :                : }
                                291                 :                : 
                                292                 :                : /*
                                293                 :                :  * IsCatalogNamespace
                                294                 :                :  *      True iff namespace is pg_catalog.
                                295                 :                :  *
                                296                 :                :  *      Does not perform any catalog accesses.
                                297                 :                :  *
                                298                 :                :  * NOTE: the reason this isn't a macro is to avoid having to include
                                299                 :                :  * catalog/pg_namespace.h in a lot of places.
                                300                 :                :  */
                                301                 :                : bool
 2761 tgl@sss.pgh.pa.us         302                 :CBC      144329 : IsCatalogNamespace(Oid namespaceId)
                                303                 :                : {
 8996                           304                 :         144329 :     return namespaceId == PG_CATALOG_NAMESPACE;
                                305                 :                : }
                                306                 :                : 
                                307                 :                : /*
                                308                 :                :  * IsToastNamespace
                                309                 :                :  *      True iff namespace is pg_toast or my temporary-toast-table namespace.
                                310                 :                :  *
                                311                 :                :  *      Does not perform any catalog accesses.
                                312                 :                :  *
                                313                 :                :  * Note: this will return false for temporary-toast-table namespaces belonging
                                314                 :                :  * to other backends.  Those are treated the same as other backends' regular
                                315                 :                :  * temp table namespaces, and access is prevented where appropriate.
                                316                 :                :  * If you need to check for those, you may be able to use isAnyTempNamespace,
                                317                 :                :  * but beware that that does involve a catalog access.
                                318                 :                :  */
                                319                 :                : bool
                                320                 :        3617096 : IsToastNamespace(Oid namespaceId)
                                321                 :                : {
 7066                           322   [ +  +  +  + ]:        7188011 :     return (namespaceId == PG_TOAST_NAMESPACE) ||
                                323                 :        3570915 :         isTempToastNamespace(namespaceId);
                                324                 :                : }
                                325                 :                : 
                                326                 :                : /*
                                327                 :                :  * IsConflictLogTableNamespace
                                328                 :                :  *      True iff namespace is pg_conflict.
                                329                 :                :  *
                                330                 :                :  *      Does not perform any catalog accesses.
                                331                 :                :  *
                                332                 :                :  * Tables in the pg_conflict namespace are conflict log tables, created and
                                333                 :                :  * maintained by the system to record logical replication conflicts. The
                                334                 :                :  * apply worker's inserts depend on their fixed structure, so they are treated
                                335                 :                :  * as system-managed: call sites across the backend use this (and
                                336                 :                :  * IsConflictLogTableClass()) to reject operations that could disrupt logging,
                                337                 :                :  * such as DDL, manual INSERT/UPDATE/MERGE, and row locking. SELECT, DELETE
                                338                 :                :  * and TRUNCATE are the only data operations allowed, so that users can still
                                339                 :                :  * query and prune conflict rows.
                                340                 :                :  */
                                341                 :                : bool
  149 akapila@postgresql.o      342                 :GNC     1593398 : IsConflictLogTableNamespace(Oid namespaceId)
                                343                 :                : {
                                344                 :        1593398 :     return namespaceId == PG_CONFLICT_NAMESPACE;
                                345                 :                : }
                                346                 :                : 
                                347                 :                : /*
                                348                 :                :  * IsReservedName
                                349                 :                :  *      True iff name starts with the pg_ prefix.
                                350                 :                :  *
                                351                 :                :  *      For some classes of objects, the prefix pg_ is reserved for
                                352                 :                :  *      system objects only.  As of 8.0, this was only true for
                                353                 :                :  *      schema and tablespace names.  With 9.6, this is also true
                                354                 :                :  *      for roles.
                                355                 :                :  */
                                356                 :                : bool
 8996 tgl@sss.pgh.pa.us         357                 :CBC        2458 : IsReservedName(const char *name)
                                358                 :                : {
                                359                 :                :     /* ugly coding for speed */
                                360                 :           2522 :     return (name[0] == 'p' &&
                                361   [ +  +  +  + ]:           2472 :             name[1] == 'g' &&
                                362         [ +  + ]:             14 :             name[2] == '_');
                                363                 :                : }
                                364                 :                : 
                                365                 :                : 
                                366                 :                : /*
                                367                 :                :  * IsSharedRelation
                                368                 :                :  *      Given the OID of a relation, determine whether it's supposed to be
                                369                 :                :  *      shared across an entire database cluster.
                                370                 :                :  *
                                371                 :                :  * In older releases, this had to be hard-wired so that we could compute the
                                372                 :                :  * locktag for a relation and lock it before examining its catalog entry.
                                373                 :                :  * Since we now have MVCC catalog access, the race conditions that made that
                                374                 :                :  * a hard requirement are gone, so we could look at relaxing this restriction.
                                375                 :                :  * However, if we scanned the pg_class entry to find relisshared, and only
                                376                 :                :  * then locked the relation, pg_class could get updated in the meantime,
                                377                 :                :  * forcing us to scan the relation again, which would definitely be complex
                                378                 :                :  * and might have undesirable performance consequences.  Fortunately, the set
                                379                 :                :  * of shared relations is fairly static, so a hand-maintained list of their
                                380                 :                :  * OIDs isn't completely impractical.
                                381                 :                :  */
                                382                 :                : bool
 7425                           383                 :       27613620 : IsSharedRelation(Oid relationId)
                                384                 :                : {
                                385                 :                :     /* These are the shared catalogs (look for BKI_SHARED_RELATION) */
                                386   [ +  +  +  + ]:       27613620 :     if (relationId == AuthIdRelationId ||
                                387         [ +  + ]:       27480221 :         relationId == AuthMemRelationId ||
                                388         [ +  + ]:       27385481 :         relationId == DatabaseRelationId ||
 4231 andres@anarazel.de        389         [ +  + ]:       27359438 :         relationId == DbRoleSettingRelationId ||
 1697 tgl@sss.pgh.pa.us         390         [ +  + ]:       27339395 :         relationId == ParameterAclRelationId ||
 3600 peter_e@gmx.net           391         [ +  + ]:       27320807 :         relationId == ReplicationOriginRelationId ||
 1697 tgl@sss.pgh.pa.us         392         [ +  + ]:       27010169 :         relationId == SharedDependRelationId ||
                                393         [ +  + ]:       27006458 :         relationId == SharedDescriptionRelationId ||
                                394         [ +  + ]:       26999348 :         relationId == SharedSecLabelRelationId ||
                                395         [ +  + ]:       26975032 :         relationId == SubscriptionRelationId ||
                                396                 :                :         relationId == TableSpaceRelationId)
 7425                           397                 :         667269 :         return true;
                                398                 :                :     /* These are their indexes */
 1697                           399   [ +  +  +  + ]:       26946351 :     if (relationId == AuthIdOidIndexId ||
                                400         [ +  + ]:       26869838 :         relationId == AuthIdRolnameIndexId ||
 7425                           401         [ +  + ]:       26859827 :         relationId == AuthMemMemRoleIndexId ||
 1697                           402         [ +  + ]:       26854653 :         relationId == AuthMemRoleMemIndexId ||
 1563 rhaas@postgresql.org      403         [ +  + ]:       26852712 :         relationId == AuthMemOidIndexId ||
                                404         [ +  + ]:       26851383 :         relationId == AuthMemGrantorIndexId ||
 7425 tgl@sss.pgh.pa.us         405         [ +  + ]:       26827263 :         relationId == DatabaseNameIndexId ||
                                406         [ +  + ]:       26778943 :         relationId == DatabaseOidIndexId ||
 4231 andres@anarazel.de        407         [ +  + ]:       26699107 :         relationId == DbRoleSettingDatidRolidIndexId ||
 1697 tgl@sss.pgh.pa.us         408         [ +  + ]:       26693192 :         relationId == ParameterAclOidIndexId ||
                                409         [ +  + ]:       26687310 :         relationId == ParameterAclParnameIndexId ||
 4231 andres@anarazel.de        410         [ +  + ]:       26682604 :         relationId == ReplicationOriginIdentIndex ||
 3600 peter_e@gmx.net           411         [ +  + ]:       26677973 :         relationId == ReplicationOriginNameIndex ||
 1697 tgl@sss.pgh.pa.us         412         [ +  + ]:       26508043 :         relationId == SharedDependDependerIndexId ||
                                413         [ +  + ]:       26499613 :         relationId == SharedDependReferenceIndexId ||
                                414         [ +  + ]:       26497136 :         relationId == SharedDescriptionObjIndexId ||
                                415         [ +  + ]:       26491249 :         relationId == SharedSecLabelObjectIndexId ||
                                416         [ +  + ]:       26485866 :         relationId == SubscriptionNameIndexId ||
 3600 peter_e@gmx.net           417         [ +  + ]:       26479763 :         relationId == SubscriptionObjectIndexId ||
 1697 tgl@sss.pgh.pa.us         418         [ +  + ]:       26477469 :         relationId == TablespaceNameIndexId ||
                                419                 :                :         relationId == TablespaceOidIndexId)
 7425                           420                 :         482964 :         return true;
                                421                 :                :     /* These are their toast tables and toast indexes */
  798 nathan@postgresql.or      422   [ +  +  +  + ]:       26463387 :     if (relationId == PgDatabaseToastTable ||
 3053 michael@paquier.xyz       423         [ +  + ]:       26462024 :         relationId == PgDatabaseToastIndex ||
 6261 alvherre@alvh.no-ip.      424         [ +  + ]:       26461394 :         relationId == PgDbRoleSettingToastTable ||
 4270 bruce@momjian.us          425         [ +  + ]:       26461011 :         relationId == PgDbRoleSettingToastIndex ||
 1697 tgl@sss.pgh.pa.us         426         [ +  + ]:       26460381 :         relationId == PgParameterAclToastTable ||
                                427         [ +  + ]:       26459998 :         relationId == PgParameterAclToastIndex ||
 3053 michael@paquier.xyz       428         [ +  + ]:       26459335 :         relationId == PgShdescriptionToastTable ||
                                429         [ +  + ]:       26458919 :         relationId == PgShdescriptionToastIndex ||
 4270 bruce@momjian.us          430         [ +  + ]:       26458289 :         relationId == PgShseclabelToastTable ||
 3053 michael@paquier.xyz       431         [ +  + ]:       26457906 :         relationId == PgShseclabelToastIndex ||
                                432         [ +  + ]:       26457276 :         relationId == PgSubscriptionToastTable ||
                                433         [ +  + ]:       26456893 :         relationId == PgSubscriptionToastIndex ||
                                434         [ +  + ]:       26456237 :         relationId == PgTablespaceToastTable ||
                                435                 :                :         relationId == PgTablespaceToastIndex)
 7425 tgl@sss.pgh.pa.us         436                 :           7560 :         return true;
                                437                 :       26455827 :     return false;
                                438                 :                : }
                                439                 :                : 
                                440                 :                : /*
                                441                 :                :  * IsPinnedObject
                                442                 :                :  *      Given the class + OID identity of a database object, report whether
                                443                 :                :  *      it is "pinned", that is not droppable because the system requires it.
                                444                 :                :  *
                                445                 :                :  * We used to represent this explicitly in pg_depend, but that proved to be
                                446                 :                :  * an undesirable amount of overhead, so now we rely on an OID range test.
                                447                 :                :  */
                                448                 :                : bool
 1962                           449                 :        2178868 : IsPinnedObject(Oid classId, Oid objectId)
                                450                 :                : {
                                451                 :                :     /*
                                452                 :                :      * Objects with OIDs above FirstUnpinnedObjectId are never pinned.  Since
                                453                 :                :      * the OID generator skips this range when wrapping around, this check
                                454                 :                :      * guarantees that user-defined objects are never considered pinned.
                                455                 :                :      */
                                456         [ +  + ]:        2178868 :     if (objectId >= FirstUnpinnedObjectId)
                                457                 :         881939 :         return false;
                                458                 :                : 
                                459                 :                :     /*
                                460                 :                :      * Large objects are never pinned.  We need this special case because
                                461                 :                :      * their OIDs can be user-assigned.
                                462                 :                :      */
                                463         [ +  + ]:        1296929 :     if (classId == LargeObjectRelationId)
                                464                 :             36 :         return false;
                                465                 :                : 
                                466                 :                :     /*
                                467                 :                :      * There are a few objects defined in the catalog .dat files that, as a
                                468                 :                :      * matter of policy, we prefer not to treat as pinned.  We used to handle
                                469                 :                :      * that by excluding them from pg_depend, but it's just as easy to
                                470                 :                :      * hard-wire their OIDs here.  (If the user does indeed drop and recreate
                                471                 :                :      * them, they'll have new but certainly-unpinned OIDs, so no problem.)
                                472                 :                :      *
                                473                 :                :      * Checking both classId and objectId is overkill, since OIDs below
                                474                 :                :      * FirstGenbkiObjectId should be globally unique, but do it anyway for
                                475                 :                :      * robustness.
                                476                 :                :      */
                                477                 :                : 
                                478                 :                :     /* the public namespace is not pinned */
                                479   [ +  +  +  + ]:        1296893 :     if (classId == NamespaceRelationId &&
                                480                 :                :         objectId == PG_PUBLIC_NAMESPACE)
                                481                 :          80964 :         return false;
                                482                 :                : 
                                483                 :                :     /*
                                484                 :                :      * Databases are never pinned.  It might seem that it'd be prudent to pin
                                485                 :                :      * at least template0; but we do this intentionally so that template0 and
                                486                 :                :      * template1 can be rebuilt from each other, thus letting them serve as
                                487                 :                :      * mutual backups (as long as you've not modified template1, anyway).
                                488                 :                :      */
 1682                           489         [ -  + ]:        1215929 :     if (classId == DatabaseRelationId)
 1682 tgl@sss.pgh.pa.us         490                 :UBC           0 :         return false;
                                491                 :                : 
                                492                 :                :     /*
                                493                 :                :      * All other initdb-created objects are pinned.  This is overkill (the
                                494                 :                :      * system doesn't really depend on having every last weird datatype, for
                                495                 :                :      * instance) but generating only the minimum required set of dependencies
                                496                 :                :      * seems hard, and enforcing an accurate list would be much more expensive
                                497                 :                :      * than the simple range test used here.
                                498                 :                :      */
 1962 tgl@sss.pgh.pa.us         499                 :CBC     1215929 :     return true;
                                500                 :                : }
                                501                 :                : 
                                502                 :                : 
                                503                 :                : /*
                                504                 :                :  * GetNewOidWithIndex
                                505                 :                :  *      Generate a new OID that is unique within the system relation.
                                506                 :                :  *
                                507                 :                :  * Since the OID is not immediately inserted into the table, there is a
                                508                 :                :  * race condition here; but a problem could occur only if someone else
                                509                 :                :  * managed to cycle through 2^32 OIDs and generate the same OID before we
                                510                 :                :  * finish inserting our row.  This seems unlikely to be a problem.  Note
                                511                 :                :  * that if we had to *commit* the row to end the race condition, the risk
                                512                 :                :  * would be rather higher; therefore we use SnapshotAny in the test, so that
                                513                 :                :  * we will see uncommitted rows.  (We used to use SnapshotDirty, but that has
                                514                 :                :  * the disadvantage that it ignores recently-deleted rows, creating a risk
                                515                 :                :  * of transient conflicts for as long as our own MVCC snapshots think a
                                516                 :                :  * recently-deleted row is live.  The risk is far higher when selecting TOAST
                                517                 :                :  * OIDs, because SnapshotToast considers dead rows as active indefinitely.)
                                518                 :                :  *
                                519                 :                :  * Note that we are effectively assuming that the table has a relatively small
                                520                 :                :  * number of entries (much less than 2^32) and there aren't very long runs of
                                521                 :                :  * consecutive existing OIDs.  This is a mostly reasonable assumption for
                                522                 :                :  * system catalogs.
                                523                 :                :  *
                                524                 :                :  * Caller must have a suitable lock on the relation.
                                525                 :                :  */
                                526                 :                : Oid
 6804                           527                 :         571663 : GetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn)
                                528                 :                : {
                                529                 :                :     Oid         newOid;
                                530                 :                :     SysScanDesc scan;
                                531                 :                :     ScanKeyData key;
                                532                 :                :     bool        collides;
 2075 fujii@postgresql.org      533                 :         571663 :     uint64      retries = 0;
                                534                 :         571663 :     uint64      retries_before_log = GETNEWOID_LOG_THRESHOLD;
                                535                 :                : 
                                536                 :                :     /* Only system relations are supported */
 2930 andres@anarazel.de        537         [ -  + ]:         571663 :     Assert(IsSystemRelation(relation));
                                538                 :                : 
                                539                 :                :     /* In bootstrap mode, we don't have any indexes to use */
                                540         [ +  + ]:         571663 :     if (IsBootstrapProcessingMode())
                                541                 :           6840 :         return GetNewObjectId();
                                542                 :                : 
                                543                 :                :     /*
                                544                 :                :      * We should never be asked to generate a new pg_type OID during
                                545                 :                :      * pg_upgrade; doing so would risk collisions with the OIDs it wants to
                                546                 :                :      * assign.  Hitting this assert means there's some path where we failed to
                                547                 :                :      * ensure that a type OID is determined by commands in the dump script.
                                548                 :                :      */
 3456 tgl@sss.pgh.pa.us         549   [ +  +  -  + ]:         564823 :     Assert(!IsBinaryUpgrade || RelationGetRelid(relation) != TypeRelationId);
                                550                 :                : 
                                551                 :                :     /* Generate new OIDs until we find one not in the table */
                                552                 :                :     do
                                553                 :                :     {
 6856                           554         [ -  + ]:         564823 :         CHECK_FOR_INTERRUPTS();
                                555                 :                : 
 7778                           556                 :         564823 :         newOid = GetNewObjectId();
                                557                 :                : 
                                558                 :         564823 :         ScanKeyInit(&key,
                                559                 :                :                     oidcolumn,
                                560                 :                :                     BTEqualStrategyNumber, F_OIDEQ,
                                561                 :                :                     ObjectIdGetDatum(newOid));
                                562                 :                : 
                                563                 :                :         /* see notes above about using SnapshotAny */
 6804                           564                 :         564823 :         scan = systable_beginscan(relation, indexId, true,
                                565                 :                :                                   SnapshotAny, 1, &key);
                                566                 :                : 
                                567                 :         564823 :         collides = HeapTupleIsValid(systable_getnext(scan));
                                568                 :                : 
                                569                 :         564823 :         systable_endscan(scan);
                                570                 :                : 
                                571                 :                :         /*
                                572                 :                :          * Log that we iterate more than GETNEWOID_LOG_THRESHOLD but have not
                                573                 :                :          * yet found OID unused in the relation. Then repeat logging with
                                574                 :                :          * exponentially increasing intervals until we iterate more than
                                575                 :                :          * GETNEWOID_LOG_MAX_INTERVAL. Finally repeat logging every
                                576                 :                :          * GETNEWOID_LOG_MAX_INTERVAL unless an unused OID is found. This
                                577                 :                :          * logic is necessary not to fill up the server log with the similar
                                578                 :                :          * messages.
                                579                 :                :          */
 2075 fujii@postgresql.org      580         [ -  + ]:         564823 :         if (retries >= retries_before_log)
                                581                 :                :         {
 2075 fujii@postgresql.org      582         [ #  # ]:UBC           0 :             ereport(LOG,
                                583                 :                :                     (errmsg("still searching for an unused OID in relation \"%s\"",
                                584                 :                :                             RelationGetRelationName(relation)),
                                585                 :                :                      errdetail_plural("OID candidates have been checked %" PRIu64 " time, but no unused OID has been found yet.",
                                586                 :                :                                       "OID candidates have been checked %" PRIu64 " times, but no unused OID has been found yet.",
                                587                 :                :                                       retries,
                                588                 :                :                                       retries)));
                                589                 :                : 
                                590                 :                :             /*
                                591                 :                :              * Double the number of retries to do before logging next until it
                                592                 :                :              * reaches GETNEWOID_LOG_MAX_INTERVAL.
                                593                 :                :              */
                                594         [ #  # ]:              0 :             if (retries_before_log * 2 <= GETNEWOID_LOG_MAX_INTERVAL)
                                595                 :              0 :                 retries_before_log *= 2;
                                596                 :                :             else
                                597                 :              0 :                 retries_before_log += GETNEWOID_LOG_MAX_INTERVAL;
                                598                 :                :         }
                                599                 :                : 
 2075 fujii@postgresql.org      600                 :CBC      564823 :         retries++;
 7778 tgl@sss.pgh.pa.us         601         [ -  + ]:         564823 :     } while (collides);
                                602                 :                : 
                                603                 :                :     /*
                                604                 :                :      * If at least one log message is emitted, also log the completion of OID
                                605                 :                :      * assignment.
                                606                 :                :      */
 2075 fujii@postgresql.org      607         [ -  + ]:         564823 :     if (retries > GETNEWOID_LOG_THRESHOLD)
                                608                 :                :     {
 2075 fujii@postgresql.org      609         [ #  # ]:UBC           0 :         ereport(LOG,
                                610                 :                :                 (errmsg_plural("new OID has been assigned in relation \"%s\" after %" PRIu64 " retry",
                                611                 :                :                                "new OID has been assigned in relation \"%s\" after %" PRIu64 " retries",
                                612                 :                :                                retries,
                                613                 :                :                                RelationGetRelationName(relation), retries)));
                                614                 :                :     }
                                615                 :                : 
 7778 tgl@sss.pgh.pa.us         616                 :CBC      564823 :     return newOid;
                                617                 :                : }
                                618                 :                : 
                                619                 :                : /*
                                620                 :                :  * GetNewRelFileNumber
                                621                 :                :  *      Generate a new relfilenumber that is unique within the
                                622                 :                :  *      database of the given tablespace.
                                623                 :                :  *
                                624                 :                :  * If the relfilenumber will also be used as the relation's OID, pass the
                                625                 :                :  * opened pg_class catalog, and this routine will guarantee that the result
                                626                 :                :  * is also an unused OID within pg_class.  If the result is to be used only
                                627                 :                :  * as a relfilenumber for an existing relation, pass NULL for pg_class.
                                628                 :                :  *
                                629                 :                :  * As with GetNewOidWithIndex(), there is some theoretical risk of a race
                                630                 :                :  * condition, but it doesn't seem worth worrying about.
                                631                 :                :  *
                                632                 :                :  * Note: we don't support using this in bootstrap mode.  All relations
                                633                 :                :  * created by bootstrap have preassigned OIDs, so there's no need.
                                634                 :                :  */
                                635                 :                : RelFileNumber
 1522 rhaas@postgresql.org      636                 :          82321 : GetNewRelFileNumber(Oid reltablespace, Relation pg_class, char relpersistence)
                                637                 :                : {
                                638                 :                :     RelFileLocatorBackend rlocator;
                                639                 :                :     RelPathStr  rpath;
                                640                 :                :     bool        collides;
                                641                 :                :     ProcNumber  procNumber;
                                642                 :                : 
                                643                 :                :     /*
                                644                 :                :      * If we ever get here during pg_upgrade, there's something wrong; all
                                645                 :                :      * relfilenumber assignments during a binary-upgrade run should be
                                646                 :                :      * determined by commands in the dump script.
                                647                 :                :      */
                                648         [ -  + ]:          82321 :     Assert(!IsBinaryUpgrade);
                                649                 :                : 
                                650      [ +  +  - ]:          82321 :     switch (relpersistence)
                                651                 :                :     {
                                652                 :           5012 :         case RELPERSISTENCE_TEMP:
 1000 heikki.linnakangas@i      653         [ +  - ]:           5012 :             procNumber = ProcNumberForTempRelations();
 1522 rhaas@postgresql.org      654                 :           5012 :             break;
                                655                 :          77309 :         case RELPERSISTENCE_UNLOGGED:
                                656                 :                :         case RELPERSISTENCE_PERMANENT:
 1000 heikki.linnakangas@i      657                 :          77309 :             procNumber = INVALID_PROC_NUMBER;
 1522 rhaas@postgresql.org      658                 :          77309 :             break;
 1522 rhaas@postgresql.org      659                 :UBC           0 :         default:
                                660         [ #  # ]:              0 :             elog(ERROR, "invalid relpersistence: %c", relpersistence);
                                661                 :                :             return InvalidRelFileNumber;    /* placate compiler */
                                662                 :                :     }
                                663                 :                : 
                                664                 :                :     /* This logic should match RelationInitPhysicalAddr */
 1522 rhaas@postgresql.org      665         [ +  + ]:CBC       82321 :     rlocator.locator.spcOid = reltablespace ? reltablespace : MyDatabaseTableSpace;
                                666                 :          82321 :     rlocator.locator.dbOid =
                                667                 :          82321 :         (rlocator.locator.spcOid == GLOBALTABLESPACE_OID) ?
                                668         [ +  + ]:          82321 :         InvalidOid : MyDatabaseId;
                                669                 :                : 
                                670                 :                :     /*
                                671                 :                :      * The relpath will vary based on the backend number, so we must
                                672                 :                :      * initialize that properly here to make sure that any collisions based on
                                673                 :                :      * filename are properly detected.
                                674                 :                :      */
 1000 heikki.linnakangas@i      675                 :          82321 :     rlocator.backend = procNumber;
                                676                 :                : 
                                677                 :                :     do
                                678                 :                :     {
 1522 rhaas@postgresql.org      679         [ -  + ]:          82321 :         CHECK_FOR_INTERRUPTS();
                                680                 :                : 
                                681                 :                :         /* Generate the OID */
                                682         [ +  + ]:          82321 :         if (pg_class)
                                683                 :          74070 :             rlocator.locator.relNumber = GetNewOidWithIndex(pg_class, ClassOidIndexId,
                                684                 :                :                                                             Anum_pg_class_oid);
                                685                 :                :         else
                                686                 :           8251 :             rlocator.locator.relNumber = GetNewObjectId();
                                687                 :                : 
                                688                 :                :         /* Check for existing file of same name */
                                689                 :          82321 :         rpath = relpath(rlocator, MAIN_FORKNUM);
                                690                 :                : 
  641 andres@anarazel.de        691         [ -  + ]:          82321 :         if (access(rpath.str, F_OK) == 0)
                                692                 :                :         {
                                693                 :                :             /* definite collision */
 1522 rhaas@postgresql.org      694                 :UBC           0 :             collides = true;
                                695                 :                :         }
                                696                 :                :         else
                                697                 :                :         {
                                698                 :                :             /*
                                699                 :                :              * Here we have a little bit of a dilemma: if errno is something
                                700                 :                :              * other than ENOENT, should we declare a collision and loop? In
                                701                 :                :              * practice it seems best to go ahead regardless of the errno.  If
                                702                 :                :              * there is a colliding file we will get an smgr failure when we
                                703                 :                :              * attempt to create the new relation file.
                                704                 :                :              */
 1522 rhaas@postgresql.org      705                 :CBC       82321 :             collides = false;
                                706                 :                :         }
                                707         [ -  + ]:          82321 :     } while (collides);
                                708                 :                : 
                                709                 :          82321 :     return rlocator.locator.relNumber;
                                710                 :                : }
                                711                 :                : 
                                712                 :                : /*
                                713                 :                :  * SQL callable interface for GetNewOidWithIndex().  Outside of initdb's
                                714                 :                :  * direct insertions into catalog tables, and recovering from corruption, this
                                715                 :                :  * should rarely be needed.
                                716                 :                :  *
                                717                 :                :  * Function is intentionally not documented in the user facing docs.
                                718                 :                :  */
                                719                 :                : Datum
 2930 andres@anarazel.de        720                 :UBC           0 : pg_nextoid(PG_FUNCTION_ARGS)
                                721                 :                : {
 2747 tgl@sss.pgh.pa.us         722                 :              0 :     Oid         reloid = PG_GETARG_OID(0);
                                723                 :              0 :     Name        attname = PG_GETARG_NAME(1);
                                724                 :              0 :     Oid         idxoid = PG_GETARG_OID(2);
                                725                 :                :     Relation    rel;
                                726                 :                :     Relation    idx;
                                727                 :                :     HeapTuple   atttuple;
                                728                 :                :     Form_pg_attribute attform;
                                729                 :                :     AttrNumber  attno;
                                730                 :                :     Oid         newoid;
                                731                 :                : 
                                732                 :                :     /*
                                733                 :                :      * As this function is not intended to be used during normal running, and
                                734                 :                :      * only supports system catalogs (which require superuser permissions to
                                735                 :                :      * modify), just checking for superuser ought to not obstruct valid
                                736                 :                :      * usecases.
                                737                 :                :      */
 2930 andres@anarazel.de        738         [ #  # ]:              0 :     if (!superuser())
                                739         [ #  # ]:              0 :         ereport(ERROR,
                                740                 :                :                 (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
                                741                 :                :                  errmsg("must be superuser to call %s()",
                                742                 :                :                         "pg_nextoid")));
                                743                 :                : 
 2868                           744                 :              0 :     rel = table_open(reloid, RowExclusiveLock);
 2930                           745                 :              0 :     idx = index_open(idxoid, RowExclusiveLock);
                                746                 :                : 
                                747         [ #  # ]:              0 :     if (!IsSystemRelation(rel))
                                748         [ #  # ]:              0 :         ereport(ERROR,
                                749                 :                :                 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                                750                 :                :                  errmsg("pg_nextoid() can only be used on system catalogs")));
                                751                 :                : 
                                752         [ #  # ]:              0 :     if (idx->rd_index->indrelid != RelationGetRelid(rel))
                                753         [ #  # ]:              0 :         ereport(ERROR,
                                754                 :                :                 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                                755                 :                :                  errmsg("index \"%s\" does not belong to table \"%s\"",
                                756                 :                :                         RelationGetRelationName(idx),
                                757                 :                :                         RelationGetRelationName(rel))));
                                758                 :                : 
                                759                 :              0 :     atttuple = SearchSysCacheAttName(reloid, NameStr(*attname));
                                760         [ #  # ]:              0 :     if (!HeapTupleIsValid(atttuple))
                                761         [ #  # ]:              0 :         ereport(ERROR,
                                762                 :                :                 (errcode(ERRCODE_UNDEFINED_COLUMN),
                                763                 :                :                  errmsg("column \"%s\" of relation \"%s\" does not exist",
                                764                 :                :                         NameStr(*attname), RelationGetRelationName(rel))));
                                765                 :                : 
                                766                 :              0 :     attform = ((Form_pg_attribute) GETSTRUCT(atttuple));
                                767                 :              0 :     attno = attform->attnum;
                                768                 :                : 
                                769         [ #  # ]:              0 :     if (attform->atttypid != OIDOID)
                                770         [ #  # ]:              0 :         ereport(ERROR,
                                771                 :                :                 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                                772                 :                :                  errmsg("column \"%s\" is not of type %s",
                                773                 :                :                         NameStr(*attname), "oid")));
                                774                 :                : 
                                775         [ #  # ]:              0 :     if (IndexRelationGetNumberOfKeyAttributes(idx) != 1 ||
                                776         [ #  # ]:              0 :         idx->rd_index->indkey.values[0] != attno)
                                777         [ #  # ]:              0 :         ereport(ERROR,
                                778                 :                :                 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                                779                 :                :                  errmsg("index \"%s\" is not the index for column \"%s\"",
                                780                 :                :                         RelationGetRelationName(idx),
                                781                 :                :                         NameStr(*attname))));
                                782                 :                : 
                                783                 :              0 :     newoid = GetNewOidWithIndex(rel, idxoid, attno);
                                784                 :                : 
                                785                 :              0 :     ReleaseSysCache(atttuple);
 2868                           786                 :              0 :     table_close(rel, RowExclusiveLock);
 2930                           787                 :              0 :     index_close(idx, RowExclusiveLock);
                                788                 :                : 
 1962 tgl@sss.pgh.pa.us         789                 :              0 :     PG_RETURN_OID(newoid);
                                790                 :                : }
                                791                 :                : 
                                792                 :                : /*
                                793                 :                :  * SQL callable interface for StopGeneratingPinnedObjectIds().
                                794                 :                :  *
                                795                 :                :  * This is only to be used by initdb, so it's intentionally not documented in
                                796                 :                :  * the user facing docs.
                                797                 :                :  */
                                798                 :                : Datum
 1962 tgl@sss.pgh.pa.us         799                 :CBC          58 : pg_stop_making_pinned_objects(PG_FUNCTION_ARGS)
                                800                 :                : {
                                801                 :                :     /*
                                802                 :                :      * Belt-and-suspenders check, since StopGeneratingPinnedObjectIds will
                                803                 :                :      * fail anyway in non-single-user mode.
                                804                 :                :      */
                                805         [ -  + ]:             58 :     if (!superuser())
 1962 tgl@sss.pgh.pa.us         806         [ #  # ]:UBC           0 :         ereport(ERROR,
                                807                 :                :                 (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
                                808                 :                :                  errmsg("must be superuser to call %s()",
                                809                 :                :                         "pg_stop_making_pinned_objects")));
                                810                 :                : 
 1962 tgl@sss.pgh.pa.us         811                 :CBC          58 :     StopGeneratingPinnedObjectIds();
                                812                 :                : 
                                813                 :             58 :     PG_RETURN_VOID();
                                814                 :                : }
        

Generated by: LCOV version 2.0-1