@@ -211,7 +211,7 @@ pg_stat_get_backend_idset(PG_FUNCTION_ARGS)
211
211
if (fctx [0 ] <= pgstat_fetch_stat_numbackends ())
212
212
{
213
213
/* do when there is more left to send */
214
- LocalPgBackendStatus * local_beentry = pgstat_fetch_stat_local_beentry (fctx [0 ]);
214
+ LocalPgBackendStatus * local_beentry = pgstat_get_local_beentry_by_index (fctx [0 ]);
215
215
216
216
SRF_RETURN_NEXT (funcctx , Int32GetDatum (local_beentry -> backend_id ));
217
217
}
@@ -264,7 +264,7 @@ pg_stat_get_progress_info(PG_FUNCTION_ARGS)
264
264
bool nulls [PG_STAT_GET_PROGRESS_COLS ] = {0 };
265
265
int i ;
266
266
267
- local_beentry = pgstat_fetch_stat_local_beentry (curr_backend );
267
+ local_beentry = pgstat_get_local_beentry_by_index (curr_backend );
268
268
beentry = & local_beentry -> backendStatus ;
269
269
270
270
/*
@@ -325,7 +325,7 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
325
325
const char * wait_event = NULL ;
326
326
327
327
/* Get the next one in the list */
328
- local_beentry = pgstat_fetch_stat_local_beentry (curr_backend );
328
+ local_beentry = pgstat_get_local_beentry_by_index (curr_backend );
329
329
beentry = & local_beentry -> backendStatus ;
330
330
331
331
/* If looking for specific PID, ignore all the others */
@@ -672,7 +672,7 @@ pg_stat_get_backend_pid(PG_FUNCTION_ARGS)
672
672
int32 beid = PG_GETARG_INT32 (0 );
673
673
PgBackendStatus * beentry ;
674
674
675
- if ((beentry = pgstat_fetch_stat_beentry (beid )) == NULL )
675
+ if ((beentry = pgstat_get_beentry_by_backend_id (beid )) == NULL )
676
676
PG_RETURN_NULL ();
677
677
678
678
PG_RETURN_INT32 (beentry -> st_procpid );
@@ -685,7 +685,7 @@ pg_stat_get_backend_dbid(PG_FUNCTION_ARGS)
685
685
int32 beid = PG_GETARG_INT32 (0 );
686
686
PgBackendStatus * beentry ;
687
687
688
- if ((beentry = pgstat_fetch_stat_beentry (beid )) == NULL )
688
+ if ((beentry = pgstat_get_beentry_by_backend_id (beid )) == NULL )
689
689
PG_RETURN_NULL ();
690
690
691
691
PG_RETURN_OID (beentry -> st_databaseid );
@@ -698,7 +698,7 @@ pg_stat_get_backend_userid(PG_FUNCTION_ARGS)
698
698
int32 beid = PG_GETARG_INT32 (0 );
699
699
PgBackendStatus * beentry ;
700
700
701
- if ((beentry = pgstat_fetch_stat_beentry (beid )) == NULL )
701
+ if ((beentry = pgstat_get_beentry_by_backend_id (beid )) == NULL )
702
702
PG_RETURN_NULL ();
703
703
704
704
PG_RETURN_OID (beentry -> st_userid );
@@ -727,7 +727,7 @@ pg_stat_get_backend_subxact(PG_FUNCTION_ARGS)
727
727
728
728
BlessTupleDesc (tupdesc );
729
729
730
- if ((local_beentry = pgstat_fetch_stat_local_beentry (beid )) != NULL )
730
+ if ((local_beentry = pgstat_get_local_beentry_by_index (beid )) != NULL )
731
731
{
732
732
/* Fill values and NULLs */
733
733
values [0 ] = Int32GetDatum (local_beentry -> backend_subxact_count );
@@ -752,7 +752,7 @@ pg_stat_get_backend_activity(PG_FUNCTION_ARGS)
752
752
char * clipped_activity ;
753
753
text * ret ;
754
754
755
- if ((beentry = pgstat_fetch_stat_beentry (beid )) == NULL )
755
+ if ((beentry = pgstat_get_beentry_by_backend_id (beid )) == NULL )
756
756
activity = "<backend information not available>" ;
757
757
else if (!HAS_PGSTAT_PERMISSIONS (beentry -> st_userid ))
758
758
activity = "<insufficient privilege>" ;
@@ -776,7 +776,7 @@ pg_stat_get_backend_wait_event_type(PG_FUNCTION_ARGS)
776
776
PGPROC * proc ;
777
777
const char * wait_event_type = NULL ;
778
778
779
- if ((beentry = pgstat_fetch_stat_beentry (beid )) == NULL )
779
+ if ((beentry = pgstat_get_beentry_by_backend_id (beid )) == NULL )
780
780
wait_event_type = "<backend information not available>" ;
781
781
else if (!HAS_PGSTAT_PERMISSIONS (beentry -> st_userid ))
782
782
wait_event_type = "<insufficient privilege>" ;
@@ -797,7 +797,7 @@ pg_stat_get_backend_wait_event(PG_FUNCTION_ARGS)
797
797
PGPROC * proc ;
798
798
const char * wait_event = NULL ;
799
799
800
- if ((beentry = pgstat_fetch_stat_beentry (beid )) == NULL )
800
+ if ((beentry = pgstat_get_beentry_by_backend_id (beid )) == NULL )
801
801
wait_event = "<backend information not available>" ;
802
802
else if (!HAS_PGSTAT_PERMISSIONS (beentry -> st_userid ))
803
803
wait_event = "<insufficient privilege>" ;
@@ -818,7 +818,7 @@ pg_stat_get_backend_activity_start(PG_FUNCTION_ARGS)
818
818
TimestampTz result ;
819
819
PgBackendStatus * beentry ;
820
820
821
- if ((beentry = pgstat_fetch_stat_beentry (beid )) == NULL )
821
+ if ((beentry = pgstat_get_beentry_by_backend_id (beid )) == NULL )
822
822
PG_RETURN_NULL ();
823
823
824
824
else if (!HAS_PGSTAT_PERMISSIONS (beentry -> st_userid ))
@@ -844,7 +844,7 @@ pg_stat_get_backend_xact_start(PG_FUNCTION_ARGS)
844
844
TimestampTz result ;
845
845
PgBackendStatus * beentry ;
846
846
847
- if ((beentry = pgstat_fetch_stat_beentry (beid )) == NULL )
847
+ if ((beentry = pgstat_get_beentry_by_backend_id (beid )) == NULL )
848
848
PG_RETURN_NULL ();
849
849
850
850
else if (!HAS_PGSTAT_PERMISSIONS (beentry -> st_userid ))
@@ -866,7 +866,7 @@ pg_stat_get_backend_start(PG_FUNCTION_ARGS)
866
866
TimestampTz result ;
867
867
PgBackendStatus * beentry ;
868
868
869
- if ((beentry = pgstat_fetch_stat_beentry (beid )) == NULL )
869
+ if ((beentry = pgstat_get_beentry_by_backend_id (beid )) == NULL )
870
870
PG_RETURN_NULL ();
871
871
872
872
else if (!HAS_PGSTAT_PERMISSIONS (beentry -> st_userid ))
@@ -890,7 +890,7 @@ pg_stat_get_backend_client_addr(PG_FUNCTION_ARGS)
890
890
char remote_host [NI_MAXHOST ];
891
891
int ret ;
892
892
893
- if ((beentry = pgstat_fetch_stat_beentry (beid )) == NULL )
893
+ if ((beentry = pgstat_get_beentry_by_backend_id (beid )) == NULL )
894
894
PG_RETURN_NULL ();
895
895
896
896
else if (!HAS_PGSTAT_PERMISSIONS (beentry -> st_userid ))
@@ -935,7 +935,7 @@ pg_stat_get_backend_client_port(PG_FUNCTION_ARGS)
935
935
char remote_port [NI_MAXSERV ];
936
936
int ret ;
937
937
938
- if ((beentry = pgstat_fetch_stat_beentry (beid )) == NULL )
938
+ if ((beentry = pgstat_get_beentry_by_backend_id (beid )) == NULL )
939
939
PG_RETURN_NULL ();
940
940
941
941
else if (!HAS_PGSTAT_PERMISSIONS (beentry -> st_userid ))
@@ -978,12 +978,12 @@ pg_stat_get_db_numbackends(PG_FUNCTION_ARGS)
978
978
Oid dbid = PG_GETARG_OID (0 );
979
979
int32 result ;
980
980
int tot_backends = pgstat_fetch_stat_numbackends ();
981
- int beid ;
981
+ int idx ;
982
982
983
983
result = 0 ;
984
- for (beid = 1 ; beid <= tot_backends ; beid ++ )
984
+ for (idx = 1 ; idx <= tot_backends ; idx ++ )
985
985
{
986
- LocalPgBackendStatus * local_beentry = pgstat_fetch_stat_local_beentry ( beid );
986
+ LocalPgBackendStatus * local_beentry = pgstat_get_local_beentry_by_index ( idx );
987
987
988
988
if (local_beentry -> backendStatus .st_databaseid == dbid )
989
989
result ++ ;
0 commit comments