@@ -89,7 +89,8 @@ typedef struct
8989typedef struct
9090{
9191MemoryContext pathman_contexts [PATHMAN_MCXT_COUNT ];
92- int current_context ;
92+ HTAB * pathman_htables [PATHMAN_MCXT_COUNT ];
93+ int current_item ;
9394}show_cache_stats_cxt ;
9495
9596
@@ -299,7 +300,12 @@ show_cache_stats_internal(PG_FUNCTION_ARGS)
299300usercxt -> pathman_contexts [2 ]= PathmanParentCacheContext ;
300301usercxt -> pathman_contexts [3 ]= PathmanCostraintCacheContext ;
301302
302- usercxt -> current_context = 0 ;
303+ usercxt -> pathman_htables [0 ]= NULL ;/* no HTAB for this entry */
304+ usercxt -> pathman_htables [1 ]= partitioned_rels ;
305+ usercxt -> pathman_htables [2 ]= parent_cache ;
306+ usercxt -> pathman_htables [3 ]= constraint_cache ;
307+
308+ usercxt -> current_item = 0 ;
303309
304310/* Create tuple descriptor */
305311tupdesc = CreateTemplateTupleDesc (Natts_pathman_cache_stats , false);
@@ -310,6 +316,8 @@ show_cache_stats_internal(PG_FUNCTION_ARGS)
310316"size" ,INT8OID ,-1 ,0 );
311317TupleDescInitEntry (tupdesc ,Anum_pathman_cs_used ,
312318"used" ,INT8OID ,-1 ,0 );
319+ TupleDescInitEntry (tupdesc ,Anum_pathman_cs_entries ,
320+ "entries" ,INT8OID ,-1 ,0 );
313321
314322funccxt -> tuple_desc = BlessTupleDesc (tupdesc );
315323funccxt -> user_fctx = (void * )usercxt ;
@@ -320,8 +328,9 @@ show_cache_stats_internal(PG_FUNCTION_ARGS)
320328funccxt = SRF_PERCALL_SETUP ();
321329usercxt = (show_cache_stats_cxt * )funccxt -> user_fctx ;
322330
323- if (usercxt -> current_context < lengthof (usercxt -> pathman_contexts ))
331+ if (usercxt -> current_item < lengthof (usercxt -> pathman_contexts ))
324332{
333+ HTAB * current_htab ;
325334MemoryContext current_mcxt ;
326335MemoryContextCounters mcxt_stats ;
327336HeapTuple htup ;
@@ -331,8 +340,9 @@ show_cache_stats_internal(PG_FUNCTION_ARGS)
331340/* Prepare context counters */
332341memset (& mcxt_stats ,0 ,sizeof (mcxt_stats ));
333342
334- /* Select current memory context */
335- current_mcxt = usercxt -> pathman_contexts [usercxt -> current_context ];
343+ /* Select current memory context and hash table (cache) */
344+ current_mcxt = usercxt -> pathman_contexts [usercxt -> current_item ];
345+ current_htab = usercxt -> pathman_htables [usercxt -> current_item ];
336346
337347/* NOTE: we do not consider child contexts if it's TopPathmanContext */
338348McxtStatsInternal (current_mcxt ,0 ,
@@ -348,8 +358,11 @@ show_cache_stats_internal(PG_FUNCTION_ARGS)
348358values [Anum_pathman_cs_used - 1 ]=
349359Int64GetDatum (mcxt_stats .totalspace - mcxt_stats .freespace );
350360
351- /* Switch to next context */
352- usercxt -> current_context ++ ;
361+ values [Anum_pathman_cs_entries - 1 ]=
362+ Int64GetDatum (current_htab ?hash_get_num_entries (current_htab ) :0 );
363+
364+ /* Switch to next item */
365+ usercxt -> current_item ++ ;
353366
354367/* Form output tuple */
355368htup = heap_form_tuple (funccxt -> tuple_desc ,values ,isnull );