@@ -272,10 +272,15 @@ static const dshash_parameters srtr_typmod_table_params = {
272
272
/* hashtable for recognizing registered record types */
273
273
static HTAB * RecordCacheHash = NULL ;
274
274
275
- /* arrays of info about registered record types, indexed by assigned typmod */
276
- static TupleDesc * RecordCacheArray = NULL ;
277
- static uint64 * RecordIdentifierArray = NULL ;
278
- static int32 RecordCacheArrayLen = 0 ;/* allocated length of above arrays */
275
+ typedef struct RecordCacheArrayEntry
276
+ {
277
+ uint64 id ;
278
+ TupleDesc tupdesc ;
279
+ }RecordCacheArrayEntry ;
280
+
281
+ /* array of info about registered record types, indexed by assigned typmod */
282
+ static RecordCacheArrayEntry * RecordCacheArray = NULL ;
283
+ static int32 RecordCacheArrayLen = 0 ;/* allocated length of above array */
279
284
static int32 NextRecordTypmod = 0 ;/* number of entries used */
280
285
281
286
/*
@@ -1702,10 +1707,8 @@ ensure_record_cache_typmod_slot_exists(int32 typmod)
1702
1707
{
1703
1708
if (RecordCacheArray == NULL )
1704
1709
{
1705
- RecordCacheArray = (TupleDesc * )
1706
- MemoryContextAllocZero (CacheMemoryContext ,64 * sizeof (TupleDesc ));
1707
- RecordIdentifierArray = (uint64 * )
1708
- MemoryContextAllocZero (CacheMemoryContext ,64 * sizeof (uint64 ));
1710
+ RecordCacheArray = (RecordCacheArrayEntry * )
1711
+ MemoryContextAllocZero (CacheMemoryContext ,64 * sizeof (RecordCacheArrayEntry ));
1709
1712
RecordCacheArrayLen = 64 ;
1710
1713
}
1711
1714
@@ -1716,14 +1719,11 @@ ensure_record_cache_typmod_slot_exists(int32 typmod)
1716
1719
while (typmod >=newlen )
1717
1720
newlen *=2 ;
1718
1721
1719
- RecordCacheArray = (TupleDesc * )repalloc (RecordCacheArray ,
1720
- newlen * sizeof (TupleDesc ));
1722
+ RecordCacheArray = (RecordCacheArrayEntry * )
1723
+ repalloc (RecordCacheArray ,
1724
+ newlen * sizeof (RecordCacheArrayEntry ));
1721
1725
memset (RecordCacheArray + RecordCacheArrayLen ,0 ,
1722
- (newlen - RecordCacheArrayLen )* sizeof (TupleDesc ));
1723
- RecordIdentifierArray = (uint64 * )repalloc (RecordIdentifierArray ,
1724
- newlen * sizeof (uint64 ));
1725
- memset (RecordIdentifierArray + RecordCacheArrayLen ,0 ,
1726
- (newlen - RecordCacheArrayLen )* sizeof (uint64 ));
1726
+ (newlen - RecordCacheArrayLen )* sizeof (RecordCacheArrayEntry ));
1727
1727
RecordCacheArrayLen = newlen ;
1728
1728
}
1729
1729
}
@@ -1761,8 +1761,8 @@ lookup_rowtype_tupdesc_internal(Oid type_id, int32 typmod, bool noError)
1761
1761
{
1762
1762
/* It is already in our local cache? */
1763
1763
if (typmod < RecordCacheArrayLen &&
1764
- RecordCacheArray [typmod ]!= NULL )
1765
- return RecordCacheArray [typmod ];
1764
+ RecordCacheArray [typmod ]. tupdesc != NULL )
1765
+ return RecordCacheArray [typmod ]. tupdesc ;
1766
1766
1767
1767
/* Are we attached to a shared record typmod registry? */
1768
1768
if (CurrentSession -> shared_typmod_registry != NULL )
@@ -1788,19 +1788,19 @@ lookup_rowtype_tupdesc_internal(Oid type_id, int32 typmod, bool noError)
1788
1788
* Our local array can now point directly to the TupleDesc
1789
1789
* in shared memory, which is non-reference-counted.
1790
1790
*/
1791
- RecordCacheArray [typmod ]= tupdesc ;
1791
+ RecordCacheArray [typmod ]. tupdesc = tupdesc ;
1792
1792
Assert (tupdesc -> tdrefcount == -1 );
1793
1793
1794
1794
/*
1795
1795
* We don't share tupdesc identifiers across processes, so
1796
1796
* assign one locally.
1797
1797
*/
1798
- RecordIdentifierArray [typmod ]= ++ tupledesc_id_counter ;
1798
+ RecordCacheArray [typmod ]. id = ++ tupledesc_id_counter ;
1799
1799
1800
1800
dshash_release_lock (CurrentSession -> shared_typmod_table ,
1801
1801
entry );
1802
1802
1803
- return RecordCacheArray [typmod ];
1803
+ return RecordCacheArray [typmod ]. tupdesc ;
1804
1804
}
1805
1805
}
1806
1806
}
@@ -2010,10 +2010,10 @@ assign_record_type_typmod(TupleDesc tupDesc)
2010
2010
ensure_record_cache_typmod_slot_exists (entDesc -> tdtypmod );
2011
2011
}
2012
2012
2013
- RecordCacheArray [entDesc -> tdtypmod ]= entDesc ;
2013
+ RecordCacheArray [entDesc -> tdtypmod ]. tupdesc = entDesc ;
2014
2014
2015
2015
/* Assign a unique tupdesc identifier, too. */
2016
- RecordIdentifierArray [entDesc -> tdtypmod ]= ++ tupledesc_id_counter ;
2016
+ RecordCacheArray [entDesc -> tdtypmod ]. id = ++ tupledesc_id_counter ;
2017
2017
2018
2018
/* Fully initialized; create the hash table entry */
2019
2019
recentry = (RecordCacheEntry * )hash_search (RecordCacheHash ,
@@ -2062,10 +2062,10 @@ assign_record_type_identifier(Oid type_id, int32 typmod)
2062
2062
* It's a transient record type, so look in our record-type table.
2063
2063
*/
2064
2064
if (typmod >=0 && typmod < RecordCacheArrayLen &&
2065
- RecordCacheArray [typmod ]!= NULL )
2065
+ RecordCacheArray [typmod ]. tupdesc != NULL )
2066
2066
{
2067
- Assert (RecordIdentifierArray [typmod ]!= 0 );
2068
- return RecordIdentifierArray [typmod ];
2067
+ Assert (RecordCacheArray [typmod ]. id != 0 );
2068
+ return RecordCacheArray [typmod ]. id ;
2069
2069
}
2070
2070
2071
2071
/* For anonymous or unrecognized record type, generate a new ID */
@@ -2145,7 +2145,7 @@ SharedRecordTypmodRegistryInit(SharedRecordTypmodRegistry *registry,
2145
2145
TupleDesc tupdesc ;
2146
2146
bool found ;
2147
2147
2148
- tupdesc = RecordCacheArray [typmod ];
2148
+ tupdesc = RecordCacheArray [typmod ]. tupdesc ;
2149
2149
if (tupdesc == NULL )
2150
2150
continue ;
2151
2151