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