67{
72 int save_sec_context;
73 int save_nestlevel;
74
75 /*
76 * We must lock table before index to avoid deadlocks. However, if the
77 * passed indrelid isn't an index then IndexGetRelation() will fail.
78 * Rather than emitting a not-very-helpful error message, postpone
79 * complaining, expecting that the is-it-an-index test below will fail.
80 *
81 * In hot standby mode this will raise an error when parentcheck is true.
82 */
85 {
87
88 /*
89 * Switch to the table owner's userid, so that any index functions are
90 * run as that user. Also lock down security-restricted operations
91 * and arrange to make GUC variable changes local to this command.
92 */
97 }
98 else
99 {
100 heaprel = NULL;
101 /* Set these just to suppress "uninitialized variable" warnings */
103 save_sec_context = -1;
104 save_nestlevel = -1;
105 }
106
107 /*
108 * Open the target index relations separately (like relation_openrv(), but
109 * with heap relation locked first to prevent deadlocking). In hot
110 * standby mode this will raise an error when parentcheck is true.
111 *
112 * There is no need for the usual indcheckxmin usability horizon test
113 * here, even in the heapallindexed case, because index undergoing
114 * verification only needs to have entries for a new transaction snapshot.
115 * (If this is a parentcheck verification, there is no question about
116 * committed or recently dead heap tuples lacking index entries due to
117 * concurrent activity.)
118 */
120
121 /*
122 * Since we did the IndexGetRelation call above without any lock, it's
123 * barely possible that a race against an index drop/recreation could have
124 * netted us the wrong table.
125 */
129 errmsg(
"could not open parent table of index \"%s\"",
131
132 /* Check that relation suitable for checking */
135
136 /* Roll back any GUC changes executed by index functions */
138
139 /* Restore userid and security context */
141
142 /*
143 * Release locks early. That's ok here because nothing in the called
144 * routines will trigger shared cache invalidations to be sent, so we can
145 * relax the usual pattern of only releasing locks after commit.
146 */
148 if (heaprel)
150}
#define OidIsValid(objectId)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
int NewGUCNestLevel(void)
void AtEOXact_GUC(bool isCommit, int nestLevel)
Oid IndexGetRelation(Oid indexId, bool missing_ok)
void index_close(Relation relation, LOCKMODE lockmode)
Relation index_open(Oid relationId, LOCKMODE lockmode)
#define SECURITY_RESTRICTED_OPERATION
void GetUserIdAndSecContext(Oid *userid, int *sec_context)
void SetUserIdAndSecContext(Oid userid, int sec_context)
#define ERRCODE_UNDEFINED_TABLE
#define RelationGetRelationName(relation)
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
static bool index_checkable(Relation rel, Oid am_id)