@@ -2813,7 +2813,7 @@ ReindexRelationConcurrently(Oid relationOid, int options)
2813
2813
Relation indexRel ;
2814
2814
Relation heapRel ;
2815
2815
Relation newIndexRel ;
2816
- LockRelId lockrelid ;
2816
+ LockRelId * lockrelid ;
2817
2817
2818
2818
indexRel = index_open (indexId , ShareUpdateExclusiveLock );
2819
2819
heapRel = table_open (indexRel -> rd_index -> indrelid ,
@@ -2847,10 +2847,12 @@ ReindexRelationConcurrently(Oid relationOid, int options)
2847
2847
* avoid multiple locks taken on the same relation, instead we rely on
2848
2848
* parentRelationIds built earlier.
2849
2849
*/
2850
- lockrelid = indexRel -> rd_lockInfo .lockRelId ;
2851
- relationLocks = lappend (relationLocks , & lockrelid );
2852
- lockrelid = newIndexRel -> rd_lockInfo .lockRelId ;
2853
- relationLocks = lappend (relationLocks , & lockrelid );
2850
+ lockrelid = palloc (sizeof (* lockrelid ));
2851
+ * lockrelid = indexRel -> rd_lockInfo .lockRelId ;
2852
+ relationLocks = lappend (relationLocks , lockrelid );
2853
+ lockrelid = palloc (sizeof (* lockrelid ));
2854
+ * lockrelid = newIndexRel -> rd_lockInfo .lockRelId ;
2855
+ relationLocks = lappend (relationLocks , lockrelid );
2854
2856
2855
2857
MemoryContextSwitchTo (oldcontext );
2856
2858
@@ -2866,19 +2868,21 @@ ReindexRelationConcurrently(Oid relationOid, int options)
2866
2868
foreach (lc , heapRelationIds )
2867
2869
{
2868
2870
Relation heapRelation = table_open (lfirst_oid (lc ), ShareUpdateExclusiveLock );
2869
- LockRelId lockrelid = heapRelation -> rd_lockInfo . lockRelId ;
2871
+ LockRelId * lockrelid ;
2870
2872
LOCKTAG * heaplocktag ;
2871
2873
2872
2874
/* Save the list of locks in private context */
2873
2875
oldcontext = MemoryContextSwitchTo (private_context );
2874
2876
2875
2877
/* Add lockrelid of heap relation to the list of locked relations */
2876
- relationLocks = lappend (relationLocks , & lockrelid );
2878
+ lockrelid = palloc (sizeof (* lockrelid ));
2879
+ * lockrelid = heapRelation -> rd_lockInfo .lockRelId ;
2880
+ relationLocks = lappend (relationLocks , lockrelid );
2877
2881
2878
2882
heaplocktag = (LOCKTAG * ) palloc (sizeof (LOCKTAG ));
2879
2883
2880
2884
/* Save the LOCKTAG for this parent relation for the wait phase */
2881
- SET_LOCKTAG_RELATION (* heaplocktag , lockrelid . dbId , lockrelid . relId );
2885
+ SET_LOCKTAG_RELATION (* heaplocktag , lockrelid -> dbId , lockrelid -> relId );
2882
2886
lockTags = lappend (lockTags , heaplocktag );
2883
2887
2884
2888
MemoryContextSwitchTo (oldcontext );
@@ -2890,9 +2894,9 @@ ReindexRelationConcurrently(Oid relationOid, int options)
2890
2894
/* Get a session-level lock on each table. */
2891
2895
foreach (lc , relationLocks )
2892
2896
{
2893
- LockRelId lockRel = * (( LockRelId * ) lfirst (lc ) );
2897
+ LockRelId * lockrelid = ( LockRelId * ) lfirst (lc );
2894
2898
2895
- LockRelationIdForSession (& lockRel , ShareUpdateExclusiveLock );
2899
+ LockRelationIdForSession (lockrelid , ShareUpdateExclusiveLock );
2896
2900
}
2897
2901
2898
2902
PopActiveSnapshot ();
@@ -3127,9 +3131,9 @@ ReindexRelationConcurrently(Oid relationOid, int options)
3127
3131
*/
3128
3132
foreach (lc , relationLocks )
3129
3133
{
3130
- LockRelId lockRel = * (( LockRelId * ) lfirst (lc ) );
3134
+ LockRelId * lockrelid = ( LockRelId * ) lfirst (lc );
3131
3135
3132
- UnlockRelationIdForSession (& lockRel , ShareUpdateExclusiveLock );
3136
+ UnlockRelationIdForSession (lockrelid , ShareUpdateExclusiveLock );
3133
3137
}
3134
3138
3135
3139
/* Start a new transaction to finish process properly */
0 commit comments