fix_codestruct
This commit is contained in:
parent
60688c6b51
commit
207ba4a272
|
@ -2014,7 +2014,7 @@ static bool command_no_begin(const char* query)
|
|||
return true;
|
||||
if (wordlen == 10 && pg_strncasecmp(query, "tablespace", 10) == 0)
|
||||
return true;
|
||||
if (wordlen == 5 && (pg_strncasecmp(query, "index", 5) == 0 || pg_strncasecmp(query, "table", 5) == 0)){
|
||||
if (wordlen == 5 && (pg_strncasecmp(query, "index", 5) == 0 || pg_strncasecmp(query, "table", 5) == 0)) {
|
||||
query += wordlen;
|
||||
query = skip_white_space(query);
|
||||
wordlen = 0;
|
||||
|
@ -2653,4 +2653,4 @@ char* GetEnvStr(const char* env)
|
|||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2643,7 +2643,7 @@ static char** PsqlCompletion(const char *text, int start, int end)
|
|||
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_indexes, " UNION SELECT 'CONCURRENTLY'");
|
||||
else if (pg_strcasecmp(PREV_WD, "SYSTEM") == 0 || pg_strcasecmp(PREV_WD, "DATABASE") == 0)
|
||||
COMPLETE_WITH_QUERY(Query_for_list_of_databases " UNION SELECT 'CONCURRENTLY'");
|
||||
} else if (pg_strcasecmp(PREV3_WD, "REINDEX") == 0){
|
||||
} else if (pg_strcasecmp(PREV3_WD, "REINDEX") == 0) {
|
||||
if (pg_strcasecmp(PREV2_WD, "TABLE") == 0 && pg_strcasecmp(PREV_WD, "CONCURRENTLY") == 0)
|
||||
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tm, NULL);
|
||||
else if (pg_strcasecmp(PREV2_WD, "INDEX") == 0 && pg_strcasecmp(PREV_WD, "CONCURRENTLY") == 0)
|
||||
|
|
|
@ -1466,7 +1466,6 @@ void index_concurrently_build(Oid heapRelationId, Oid indexRelationId, bool isPr
|
|||
* insert new entries into the index for insertions and non-HOT updates.
|
||||
*/
|
||||
index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1569,8 +1568,7 @@ void index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char* oldName
|
|||
pg_constraint = heap_open(ConstraintRelationId, RowExclusiveLock);
|
||||
pg_trigger = heap_open(TriggerRelationId, RowExclusiveLock);
|
||||
|
||||
foreach(lc, constraintOids)
|
||||
{
|
||||
foreach(lc, constraintOids) {
|
||||
HeapTuple constraintTuple, triggerTuple;
|
||||
Form_pg_constraint conForm;
|
||||
ScanKeyData key[1];
|
||||
|
@ -1712,7 +1710,6 @@ void index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char* oldName
|
|||
/* The lock taken previously is not released until the end of transaction */
|
||||
relation_close(oldClassRel, NoLock);
|
||||
relation_close(newClassRel, NoLock);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1757,7 +1754,6 @@ void index_concurrently_set_dead(Oid heapId, Oid indexId)
|
|||
*/
|
||||
heap_close(userHeapRelation, NoLock);
|
||||
index_close(userIndexRelation, NoLock);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1805,7 +1801,7 @@ Oid index_concurrently_part_create_copy(Oid oldIndexPartId, const char* newName)
|
|||
|
||||
/* Fetch the options of index if any */
|
||||
classTuple = SearchSysCache1(RELOID, indexId);
|
||||
if(!HeapTupleIsValid(classTuple)){
|
||||
if(!HeapTupleIsValid(classTuple)) {
|
||||
ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("cache lookup failed for relation %u", indexId)));
|
||||
}
|
||||
optionDatum = SysCacheGetAttr(RELOID, classTuple, Anum_pg_class_reloptions, &isnull);
|
||||
|
@ -1814,7 +1810,7 @@ Oid index_concurrently_part_create_copy(Oid oldIndexPartId, const char* newName)
|
|||
* Extract the list of column names to be used for the index
|
||||
* creation.
|
||||
*/
|
||||
for(int i = 0; i < indexInfo->ii_NumIndexAttrs; i++){
|
||||
for(int i = 0; i < indexInfo->ii_NumIndexAttrs; i++) {
|
||||
TupleDesc indexTupDesc = RelationGetDescr(indexRelation);
|
||||
Form_pg_attribute att = TupleDescAttr(indexTupDesc, i);
|
||||
|
||||
|
@ -1896,7 +1892,6 @@ void index_concurrently_part_build(Oid heapRelationId, Oid heapPartitionId, Oid
|
|||
partitionClose(indexRelation, indexPartition, NoLock);
|
||||
heap_close(heapRelation, NoLock);
|
||||
index_close(indexRelation, NoLock);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1905,7 +1900,7 @@ void index_concurrently_part_build(Oid heapRelationId, Oid heapPartitionId, Oid
|
|||
* Swap name, dependencies, and constraints of the old index over to the new
|
||||
* index, while marking the old index as invalid and the new as valid.
|
||||
*/
|
||||
void index_concurrently_part_swap(Relation indexRelation, Oid newIndexPartId, Oid oldIndexPartId, const char *oldName){
|
||||
void index_concurrently_part_swap(Relation indexRelation, Oid newIndexPartId, Oid oldIndexPartId, const char *oldName) {
|
||||
Relation pg_partition;
|
||||
Partition oldIndexPartition, newIndexPartition;
|
||||
HeapTuple oldIndexPartTuple, newIndexPartTuple;
|
||||
|
@ -1975,7 +1970,6 @@ void index_concurrently_part_swap(Relation indexRelation, Oid newIndexPartId, Oi
|
|||
/* The lock taken previously is not released until the end of transaction */
|
||||
partitionClose(indexRelation, oldIndexPartition, NoLock);
|
||||
partitionClose(indexRelation, newIndexPartition, NoLock);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -451,8 +451,7 @@ long changeDependenciesOn(Oid refClassId, Oid oldRefObjectId, Oid newRefObjectId
|
|||
|
||||
if(newIsPinned)
|
||||
simple_heap_delete(depRel, &tup->t_self);
|
||||
else
|
||||
{
|
||||
else {
|
||||
/* make a modifiable copy */
|
||||
tup = heap_copytuple(tup);
|
||||
depform = (Form_pg_depend) GETSTRUCT(tup);
|
||||
|
@ -802,4 +801,4 @@ List* get_index_ref_constraints(Oid indexId)
|
|||
heap_close(depRel, AccessShareLock);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2961,8 +2961,8 @@ static bool ReindexRelationConcurrently(Oid relationOid, Oid relationPartOid, Ad
|
|||
oldcontext = MemoryContextSwitchTo(private_context);
|
||||
|
||||
/* Track this Relation for session lock */
|
||||
if (!RELATION_IS_PARTITIONED(heapRelation))
|
||||
heapRelationIds = lappend_oid(heapRelationIds, relationOid);
|
||||
if (!RELATION_IS_PARTITIONED(heapRelation))
|
||||
heapRelationIds = lappend_oid(heapRelationIds, relationOid);
|
||||
|
||||
MemoryContextSwitchTo(oldcontext);
|
||||
|
||||
|
@ -3002,8 +3002,7 @@ static bool ReindexRelationConcurrently(Oid relationOid, Oid relationPartOid, Ad
|
|||
indexPartIds = lappend_oid(indexPartIds, indexPartitionid);
|
||||
|
||||
MemoryContextSwitchTo(oldcontext);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
List* indexPartOidList = NULL;
|
||||
ListCell* partCell = NULL;
|
||||
|
||||
|
@ -3027,8 +3026,7 @@ static bool ReindexRelationConcurrently(Oid relationOid, Oid relationPartOid, Ad
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/* Save the list of relation OIDs in private context */
|
||||
oldcontext = MemoryContextSwitchTo(private_context);
|
||||
|
||||
|
@ -3045,8 +3043,7 @@ static bool ReindexRelationConcurrently(Oid relationOid, Oid relationPartOid, Ad
|
|||
Oid toastOid = heapRelation->rd_rel->reltoastrelid;
|
||||
relToastOids = lappend_oid(relToastOids, toastOid);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
List* partTupleList = NIL;
|
||||
ListCell* partCell = NULL;
|
||||
|
||||
|
@ -3146,8 +3143,7 @@ static bool ReindexRelationConcurrently(Oid relationOid, Oid relationPartOid, Ad
|
|||
indexPartIds = lappend_oid(indexPartIds, relationPartOid);
|
||||
|
||||
MemoryContextSwitchTo(oldcontext);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
List* indexPartOidList = NULL;
|
||||
ListCell* partCell = NULL;
|
||||
|
||||
|
@ -3171,8 +3167,7 @@ static bool ReindexRelationConcurrently(Oid relationOid, Oid relationPartOid, Ad
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
/* Save the list of relation OIDs in private context */
|
||||
oldcontext = MemoryContextSwitchTo(private_context);
|
||||
|
||||
|
@ -3236,7 +3231,7 @@ static bool ReindexRelationConcurrently(Oid relationOid, Oid relationPartOid, Ad
|
|||
* more detailed comments.
|
||||
*/
|
||||
|
||||
foreach(lc, indexIds){
|
||||
foreach(lc, indexIds) {
|
||||
char* concurrentName;
|
||||
Oid indexId = lfirst_oid(lc);
|
||||
Oid newIndexId;
|
||||
|
@ -3332,7 +3327,7 @@ static bool ReindexRelationConcurrently(Oid relationOid, Oid relationPartOid, Ad
|
|||
* Save the heap lock for following visibility checks with other backends
|
||||
* might conflict with this session.
|
||||
*/
|
||||
foreach(lc, heapRelationIds){
|
||||
foreach(lc, heapRelationIds) {
|
||||
Relation heapRelation = heap_open(lfirst_oid(lc), ShareUpdateExclusiveLock);
|
||||
LockRelId lockrelid = heapRelation->rd_lockInfo.lockRelId;
|
||||
LOCKTAG* heaplocktag;
|
||||
|
@ -3359,7 +3354,7 @@ static bool ReindexRelationConcurrently(Oid relationOid, Oid relationPartOid, Ad
|
|||
* Save the heap partition lock for following visibility checks wth other backends
|
||||
* might conflict with this session.
|
||||
*/
|
||||
foreach(lc, heapPartitionIds){
|
||||
foreach(lc, heapPartitionIds) {
|
||||
Oid heapPartId = lfirst_oid(lc);
|
||||
Oid heapId = PartIdGetParentId(heapPartId, false);
|
||||
Relation heapRelation = heap_open(heapId, AccessShareLock);
|
||||
|
@ -3388,7 +3383,7 @@ static bool ReindexRelationConcurrently(Oid relationOid, Oid relationPartOid, Ad
|
|||
}
|
||||
|
||||
/* Get a session-level lock on each table */
|
||||
foreach(lc, relationLocks){
|
||||
foreach(lc, relationLocks) {
|
||||
LockRelId* lockRel = (LockRelId*) lfirst(lc);
|
||||
|
||||
LockRelationIdForSession(lockRel, ShareUpdateExclusiveLock);
|
||||
|
@ -3449,7 +3444,7 @@ static bool ReindexRelationConcurrently(Oid relationOid, Oid relationPartOid, Ad
|
|||
CommitTransactionCommand();
|
||||
}
|
||||
|
||||
forboth(lc, indexPartIds, lc2, newIndexPartIds){
|
||||
forboth(lc, indexPartIds, lc2, newIndexPartIds) {
|
||||
Relation indexRelation;
|
||||
Oid oldIndexPartId = lfirst_oid(lc);
|
||||
Oid newIndexPartId = lfirst_oid(lc2);
|
||||
|
@ -3498,7 +3493,7 @@ static bool ReindexRelationConcurrently(Oid relationOid, Oid relationPartOid, Ad
|
|||
}
|
||||
CommitTransactionCommand();
|
||||
|
||||
foreach(lc, newIndexIds){
|
||||
foreach(lc, newIndexIds) {
|
||||
Oid newIndexId = lfirst_oid(lc);
|
||||
Oid heapId;
|
||||
TransactionId limitXmin;
|
||||
|
@ -3547,7 +3542,7 @@ static bool ReindexRelationConcurrently(Oid relationOid, Oid relationPartOid, Ad
|
|||
CommitTransactionCommand();
|
||||
}
|
||||
|
||||
foreach(lc, newIndexPartIds){
|
||||
foreach(lc, newIndexPartIds) {
|
||||
Oid newIndexPartId = lfirst_oid(lc);
|
||||
Oid heapPartId;
|
||||
TransactionId limitXmin;
|
||||
|
@ -3608,7 +3603,7 @@ static bool ReindexRelationConcurrently(Oid relationOid, Oid relationPartOid, Ad
|
|||
*/
|
||||
StartTransactionCommand();
|
||||
|
||||
forboth(lc, indexIds, lc2, newIndexIds){
|
||||
forboth(lc, indexIds, lc2, newIndexIds) {
|
||||
char* oldName;
|
||||
Oid oldIndexId = lfirst_oid(lc);
|
||||
Oid newIndexId = lfirst_oid(lc2);
|
||||
|
@ -3643,7 +3638,7 @@ static bool ReindexRelationConcurrently(Oid relationOid, Oid relationPartOid, Ad
|
|||
CommandCounterIncrement();
|
||||
}
|
||||
|
||||
forboth(lc, indexPartIds, lc2, newIndexPartIds){
|
||||
forboth(lc, indexPartIds, lc2, newIndexPartIds) {
|
||||
char* oldName;
|
||||
Oid oldIndexPartId = lfirst_oid(lc);
|
||||
Oid newIndexPartId = lfirst_oid(lc2);
|
||||
|
@ -3696,7 +3691,7 @@ static bool ReindexRelationConcurrently(Oid relationOid, Oid relationPartOid, Ad
|
|||
* transaction could be using the index for a query. See also
|
||||
* index_drop() for more details.
|
||||
*/
|
||||
foreach(lc, lockTags){
|
||||
foreach(lc, lockTags) {
|
||||
LOCKTAG* locktag = (LOCKTAG*) lfirst(lc);
|
||||
old_lockholders = GetLockConflicts(locktag, ShareLock);
|
||||
|
||||
|
@ -3706,7 +3701,7 @@ static bool ReindexRelationConcurrently(Oid relationOid, Oid relationPartOid, Ad
|
|||
}
|
||||
}
|
||||
|
||||
foreach(lc, indexIds){
|
||||
foreach(lc, indexIds) {
|
||||
Oid oldIndexId = lfirst_oid(lc);
|
||||
Oid heapId;
|
||||
|
||||
|
@ -3724,7 +3719,7 @@ static bool ReindexRelationConcurrently(Oid relationOid, Oid relationPartOid, Ad
|
|||
*
|
||||
* Drop the old indexes.
|
||||
*/
|
||||
foreach(lc, lockTags){
|
||||
foreach(lc, lockTags) {
|
||||
LOCKTAG* locktag = (LOCKTAG*) lfirst(lc);
|
||||
old_lockholders = GetLockConflicts(locktag, ShareLock);
|
||||
|
||||
|
@ -3739,7 +3734,7 @@ static bool ReindexRelationConcurrently(Oid relationOid, Oid relationPartOid, Ad
|
|||
{
|
||||
ObjectAddresses* objects = new_object_addresses();
|
||||
|
||||
foreach(lc, indexIds){
|
||||
foreach(lc, indexIds) {
|
||||
Oid oldIndexId = lfirst_oid(lc);
|
||||
ObjectAddress* object =(ObjectAddress*) palloc(sizeof(ObjectAddress));
|
||||
|
||||
|
@ -3758,7 +3753,7 @@ static bool ReindexRelationConcurrently(Oid relationOid, Oid relationPartOid, Ad
|
|||
}
|
||||
|
||||
/* Drop old part index */
|
||||
foreach(lc, indexPartIds){
|
||||
foreach(lc, indexPartIds) {
|
||||
Oid oldIndexPartId = lfirst_oid(lc);
|
||||
Oid indexId = InvalidOid;
|
||||
Oid heapPartId = InvalidOid;
|
||||
|
@ -3782,7 +3777,7 @@ static bool ReindexRelationConcurrently(Oid relationOid, Oid relationPartOid, Ad
|
|||
* Finally, release the session-level lock on the table.
|
||||
*/
|
||||
|
||||
foreach(lc, relationLocks){
|
||||
foreach(lc, relationLocks) {
|
||||
LockRelId* lockRel = (LockRelId*) lfirst(lc);
|
||||
|
||||
UnlockRelationIdForSession(lockRel, ShareUpdateExclusiveLock);
|
||||
|
|
|
@ -3624,13 +3624,13 @@ static void RangeVarCallbackForDropRelation(
|
|||
* only concerns indexes of toast relations that became invalid during a
|
||||
* REINDEX CONCURRENTLY process.
|
||||
*/
|
||||
if(IsSystemClass(classform)&&relkind == RELKIND_INDEX){
|
||||
if(IsSystemClass(classform)&&relkind == RELKIND_INDEX) {
|
||||
HeapTuple locTuple;
|
||||
Form_pg_index indexform;
|
||||
bool indisvalid;
|
||||
|
||||
locTuple = SearchSysCache1(INDEXRELID,ObjectIdGetDatum(relOid));
|
||||
if(!HeapTupleIsValid(locTuple)){
|
||||
if(!HeapTupleIsValid(locTuple)) {
|
||||
ReleaseSysCache(tuple);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue