@@ -271,10 +271,15 @@ static const dshash_parameters srtr_typmod_table_params = {
271
271
/* hashtable for recognizing registered record types */
272
272
static HTAB * RecordCacheHash = NULL ;
273
273
274
- /* arrays of info about registered record types, indexed by assigned typmod */
275
- static TupleDesc * RecordCacheArray = NULL ;
276
- static uint64 * RecordIdentifierArray = NULL ;
277
- static int32 RecordCacheArrayLen = 0 ;/* allocated length of above arrays */
274
+ typedef struct RecordCacheArrayEntry
275
+ {
276
+ uint64 id ;
277
+ TupleDesc tupdesc ;
278
+ }RecordCacheArrayEntry ;
279
+
280
+ /* array of info about registered record types, indexed by assigned typmod */
281
+ static RecordCacheArrayEntry * RecordCacheArray = NULL ;
282
+ static int32 RecordCacheArrayLen = 0 ;/* allocated length of above array */
278
283
static int32 NextRecordTypmod = 0 ;/* number of entries used */
279
284
280
285
/*
@@ -1583,10 +1588,8 @@ ensure_record_cache_typmod_slot_exists(int32 typmod)
1583
1588
{
1584
1589
if (RecordCacheArray == NULL )
1585
1590
{
1586
- RecordCacheArray = (TupleDesc * )
1587
- MemoryContextAllocZero (CacheMemoryContext ,64 * sizeof (TupleDesc ));
1588
- RecordIdentifierArray = (uint64 * )
1589
- MemoryContextAllocZero (CacheMemoryContext ,64 * sizeof (uint64 ));
1591
+ RecordCacheArray = (RecordCacheArrayEntry * )
1592
+ MemoryContextAllocZero (CacheMemoryContext ,64 * sizeof (RecordCacheArrayEntry ));
1590
1593
RecordCacheArrayLen = 64 ;
1591
1594
}
1592
1595
@@ -1597,14 +1600,11 @@ ensure_record_cache_typmod_slot_exists(int32 typmod)
1597
1600
while (typmod >=newlen )
1598
1601
newlen *=2 ;
1599
1602
1600
- RecordCacheArray = (TupleDesc * )repalloc (RecordCacheArray ,
1601
- newlen * sizeof (TupleDesc ));
1603
+ RecordCacheArray = (RecordCacheArrayEntry * )
1604
+ repalloc (RecordCacheArray ,
1605
+ newlen * sizeof (RecordCacheArrayEntry ));
1602
1606
memset (RecordCacheArray + RecordCacheArrayLen ,0 ,
1603
- (newlen - RecordCacheArrayLen )* sizeof (TupleDesc ));
1604
- RecordIdentifierArray = (uint64 * )repalloc (RecordIdentifierArray ,
1605
- newlen * sizeof (uint64 ));
1606
- memset (RecordIdentifierArray + RecordCacheArrayLen ,0 ,
1607
- (newlen - RecordCacheArrayLen )* sizeof (uint64 ));
1607
+ (newlen - RecordCacheArrayLen )* sizeof (RecordCacheArrayEntry ));
1608
1608
RecordCacheArrayLen = newlen ;
1609
1609
}
1610
1610
}
@@ -1642,8 +1642,8 @@ lookup_rowtype_tupdesc_internal(Oid type_id, int32 typmod, bool noError)
1642
1642
{
1643
1643
/* It is already in our local cache? */
1644
1644
if (typmod < RecordCacheArrayLen &&
1645
- RecordCacheArray [typmod ]!= NULL )
1646
- return RecordCacheArray [typmod ];
1645
+ RecordCacheArray [typmod ]. tupdesc != NULL )
1646
+ return RecordCacheArray [typmod ]. tupdesc ;
1647
1647
1648
1648
/* Are we attached to a shared record typmod registry? */
1649
1649
if (CurrentSession -> shared_typmod_registry != NULL )
@@ -1669,19 +1669,19 @@ lookup_rowtype_tupdesc_internal(Oid type_id, int32 typmod, bool noError)
1669
1669
* Our local array can now point directly to the TupleDesc
1670
1670
* in shared memory, which is non-reference-counted.
1671
1671
*/
1672
- RecordCacheArray [typmod ]= tupdesc ;
1672
+ RecordCacheArray [typmod ]. tupdesc = tupdesc ;
1673
1673
Assert (tupdesc -> tdrefcount == -1 );
1674
1674
1675
1675
/*
1676
1676
* We don't share tupdesc identifiers across processes, so
1677
1677
* assign one locally.
1678
1678
*/
1679
- RecordIdentifierArray [typmod ]= ++ tupledesc_id_counter ;
1679
+ RecordCacheArray [typmod ]. id = ++ tupledesc_id_counter ;
1680
1680
1681
1681
dshash_release_lock (CurrentSession -> shared_typmod_table ,
1682
1682
entry );
1683
1683
1684
- return RecordCacheArray [typmod ];
1684
+ return RecordCacheArray [typmod ]. tupdesc ;
1685
1685
}
1686
1686
}
1687
1687
}
@@ -1892,10 +1892,10 @@ assign_record_type_typmod(TupleDesc tupDesc)
1892
1892
ensure_record_cache_typmod_slot_exists (entDesc -> tdtypmod );
1893
1893
}
1894
1894
1895
- RecordCacheArray [entDesc -> tdtypmod ]= entDesc ;
1895
+ RecordCacheArray [entDesc -> tdtypmod ]. tupdesc = entDesc ;
1896
1896
1897
1897
/* Assign a unique tupdesc identifier, too. */
1898
- RecordIdentifierArray [entDesc -> tdtypmod ]= ++ tupledesc_id_counter ;
1898
+ RecordCacheArray [entDesc -> tdtypmod ]. id = ++ tupledesc_id_counter ;
1899
1899
1900
1900
/* Fully initialized; create the hash table entry */
1901
1901
recentry = (RecordCacheEntry * )hash_search (RecordCacheHash ,
@@ -1944,10 +1944,10 @@ assign_record_type_identifier(Oid type_id, int32 typmod)
1944
1944
* It's a transient record type, so look in our record-type table.
1945
1945
*/
1946
1946
if (typmod >=0 && typmod < RecordCacheArrayLen &&
1947
- RecordCacheArray [typmod ]!= NULL )
1947
+ RecordCacheArray [typmod ]. tupdesc != NULL )
1948
1948
{
1949
- Assert (RecordIdentifierArray [typmod ]!= 0 );
1950
- return RecordIdentifierArray [typmod ];
1949
+ Assert (RecordCacheArray [typmod ]. id != 0 );
1950
+ return RecordCacheArray [typmod ]. id ;
1951
1951
}
1952
1952
1953
1953
/* For anonymous or unrecognized record type, generate a new ID */
@@ -2027,7 +2027,7 @@ SharedRecordTypmodRegistryInit(SharedRecordTypmodRegistry *registry,
2027
2027
TupleDesc tupdesc ;
2028
2028
bool found ;
2029
2029
2030
- tupdesc = RecordCacheArray [typmod ];
2030
+ tupdesc = RecordCacheArray [typmod ]. tupdesc ;
2031
2031
if (tupdesc == NULL )
2032
2032
continue ;
2033
2033