@@ -311,7 +311,6 @@ ConstructTupleDescriptor(Relation heapRelation,
311
311
Form_pg_attribute to = indexTupDesc -> attrs [i ];
312
312
HeapTuple tuple ;
313
313
Form_pg_type typeTup ;
314
- Form_pg_opclass opclassTup ;
315
314
Oid keyType ;
316
315
317
316
if (atnum != 0 )
@@ -436,6 +435,8 @@ ConstructTupleDescriptor(Relation heapRelation,
436
435
*/
437
436
if (i < indexInfo -> ii_NumIndexKeyAttrs )
438
437
{
438
+ Form_pg_opclass opclassTup ;
439
+
439
440
tuple = SearchSysCache1 (CLAOID , ObjectIdGetDatum (classObjectId [i ]));
440
441
if (!HeapTupleIsValid (tuple ))
441
442
elog (ERROR , "cache lookup failed for opclass %u" ,
@@ -445,40 +446,40 @@ ConstructTupleDescriptor(Relation heapRelation,
445
446
keyType = opclassTup -> opckeytype ;
446
447
447
448
ReleaseSysCache (tuple );
448
- }
449
-
450
- /*
451
- * If keytype is specified as ANYELEMENT, and opcintype is ANYARRAY,
452
- * then the attribute type must be an array (else it'd not have
453
- * matched this opclass); use its element type.
454
- */
455
- if (keyType == ANYELEMENTOID && opclassTup -> opcintype == ANYARRAYOID )
456
- {
457
- keyType = get_base_element_type (to -> atttypid );
458
- if (!OidIsValid (keyType ))
459
- elog (ERROR , "could not get element type of array type %u" ,
460
- to -> atttypid );
461
- }
462
449
463
- /*
464
- * If a key type different from the heap value is specified, update
465
- * the type-related fields in the index tupdesc.
466
- */
467
- if (OidIsValid (keyType ) && keyType != to -> atttypid )
468
- {
469
- tuple = SearchSysCache1 (TYPEOID , ObjectIdGetDatum (keyType ));
470
- if (!HeapTupleIsValid (tuple ))
471
- elog (ERROR , "cache lookup failed for type %u" , keyType );
472
- typeTup = (Form_pg_type ) GETSTRUCT (tuple );
473
-
474
- to -> atttypid = keyType ;
475
- to -> atttypmod = -1 ;
476
- to -> attlen = typeTup -> typlen ;
477
- to -> attbyval = typeTup -> typbyval ;
478
- to -> attalign = typeTup -> typalign ;
479
- to -> attstorage = typeTup -> typstorage ;
450
+ /*
451
+ * If keytype is specified as ANYELEMENT, and opcintype is ANYARRAY,
452
+ * then the attribute type must be an array (else it'd not have
453
+ * matched this opclass); use its element type.
454
+ */
455
+ if (keyType == ANYELEMENTOID && opclassTup -> opcintype == ANYARRAYOID )
456
+ {
457
+ keyType = get_base_element_type (to -> atttypid );
458
+ if (!OidIsValid (keyType ))
459
+ elog (ERROR , "could not get element type of array type %u" ,
460
+ to -> atttypid );
461
+ }
480
462
481
- ReleaseSysCache (tuple );
463
+ /*
464
+ * If a key type different from the heap value is specified, update
465
+ * the type-related fields in the index tupdesc.
466
+ */
467
+ if (OidIsValid (keyType ) && keyType != to -> atttypid )
468
+ {
469
+ tuple = SearchSysCache1 (TYPEOID , ObjectIdGetDatum (keyType ));
470
+ if (!HeapTupleIsValid (tuple ))
471
+ elog (ERROR , "cache lookup failed for type %u" , keyType );
472
+ typeTup = (Form_pg_type ) GETSTRUCT (tuple );
473
+
474
+ to -> atttypid = keyType ;
475
+ to -> atttypmod = -1 ;
476
+ to -> attlen = typeTup -> typlen ;
477
+ to -> attbyval = typeTup -> typbyval ;
478
+ to -> attalign = typeTup -> typalign ;
479
+ to -> attstorage = typeTup -> typstorage ;
480
+
481
+ ReleaseSysCache (tuple );
482
+ }
482
483
}
483
484
}
484
485
0 commit comments