@@ -366,7 +366,15 @@ search_be_status(int pid)
366366 for (beid = 1 ; beid <= pgstat_fetch_stat_numbackends (); beid ++ )
367367 {
368368#if PG_VERSION_NUM >= 160000
369- PgBackendStatus * be_status = pgstat_get_beentry_by_backend_id (beid );
369+ LocalPgBackendStatus * lbe_status = pgstat_get_local_beentry_by_index (beid );
370+ PgBackendStatus * be_status ;
371+
372+ Assert (lbe_status );
373+ #ifndef PGPRO_STD
374+ be_status = & lbe_status -> backendStatus ;
375+ #else
376+ be_status = lbe_status -> backendStatus ;
377+ #endif
370378#else
371379 PgBackendStatus * be_status = pgstat_fetch_stat_beentry (beid );
372380#endif
@@ -505,7 +513,14 @@ pg_query_state(PG_FUNCTION_ARGS)
505513 errmsg ("attempt to extract state of current process" )));
506514
507515 proc = BackendPidGetProc (pid );
508- if (!proc || proc -> backendId == InvalidBackendId || proc -> databaseId == InvalidOid || proc -> roleId == InvalidOid )
516+ if (!proc ||
517+ #if PG_VERSION_NUM >= 170000
518+ proc -> vxid .procNumber == INVALID_PROC_NUMBER ||
519+ #else
520+ proc -> backendId == InvalidBackendId ||
521+ #endif
522+ proc -> databaseId == InvalidOid ||
523+ proc -> roleId == InvalidOid )
509524 ereport (ERROR , (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
510525 errmsg ("backend with pid=%d not found" , pid )));
511526
@@ -730,15 +745,25 @@ GetRemoteBackendUserId(PGPROC *proc)
730745{
731746 Oid result ;
732747
748+ #if PG_VERSION_NUM >= 170000
749+ Assert (proc && proc -> vxid .procNumber != INVALID_PROC_NUMBER );
750+ #else
733751 Assert (proc && proc -> backendId != InvalidBackendId );
752+ #endif
753+
734754 Assert (UserIdPollReason != INVALID_PROCSIGNAL );
735755 Assert (counterpart_userid );
736756
737757 counterpart_userid -> userid = InvalidOid ;
738758 counterpart_userid -> caller = MyLatch ;
739759 pg_write_barrier ();
740760
761+ #if PG_VERSION_NUM >= 170000
762+ SendProcSignal (proc -> pid , UserIdPollReason , proc -> vxid .procNumber );
763+ #else
741764 SendProcSignal (proc -> pid , UserIdPollReason , proc -> backendId );
765+ #endif
766+
742767 for (;;)
743768 {
744769 SpinLockAcquire (& counterpart_userid -> mutex );
@@ -926,7 +951,12 @@ GetRemoteBackendWorkers(PGPROC *proc)
926951 List * result = NIL ;
927952 LOCKTAG tag ;
928953
954+ #if PG_VERSION_NUM >= 170000
955+ Assert (proc && proc -> vxid .procNumber != INVALID_PROC_NUMBER );
956+ #else
929957 Assert (proc && proc -> backendId != InvalidBackendId );
958+ #endif
959+
930960 Assert (WorkerPollReason != INVALID_PROCSIGNAL );
931961 Assert (mq );
932962
@@ -936,7 +966,12 @@ GetRemoteBackendWorkers(PGPROC *proc)
936966 shm_mq_set_receiver (mq , MyProc );
937967 UnlockShmem (& tag );
938968
969+ #if PG_VERSION_NUM >= 170000
970+ sig_result = SendProcSignal (proc -> pid , WorkerPollReason , proc -> vxid .procNumber );
971+ #else
939972 sig_result = SendProcSignal (proc -> pid , WorkerPollReason , proc -> backendId );
973+ #endif
974+
940975 if (sig_result == -1 )
941976 goto signal_error ;
942977
@@ -1088,9 +1123,16 @@ GetRemoteBackendQueryStates(PGPROC *leader,
10881123 * send signal `QueryStatePollReason` to all processes and define all alive
10891124 * ones
10901125 */
1126+ #if PG_VERSION_NUM >= 170000
1127+ sig_result = SendProcSignal (leader -> pid ,
1128+ QueryStatePollReason ,
1129+ leader -> vxid .procNumber );
1130+ #else
10911131 sig_result = SendProcSignal (leader -> pid ,
10921132 QueryStatePollReason ,
10931133 leader -> backendId );
1134+ #endif
1135+
10941136 if (sig_result == -1 )
10951137 goto signal_error ;
10961138 foreach (iter , pworkers )
@@ -1101,9 +1143,16 @@ GetRemoteBackendQueryStates(PGPROC *leader,
11011143
11021144 pg_atomic_add_fetch_u32 (& counterpart_userid -> n_peers , 1 );
11031145
1146+ #if PG_VERSION_NUM >= 170000
1147+ sig_result = SendProcSignal (proc -> pid ,
1148+ QueryStatePollReason ,
1149+ proc -> vxid .procNumber );
1150+ #else
11041151 sig_result = SendProcSignal (proc -> pid ,
11051152 QueryStatePollReason ,
11061153 proc -> backendId );
1154+ #endif
1155+
11071156 if (sig_result == -1 )
11081157 {
11091158 if (errno != ESRCH )
0 commit comments