@@ -366,7 +366,15 @@ search_be_status(int pid)
366
366
for (beid = 1 ; beid <= pgstat_fetch_stat_numbackends (); beid ++ )
367
367
{
368
368
#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
370
378
#else
371
379
PgBackendStatus * be_status = pgstat_fetch_stat_beentry (beid );
372
380
#endif
@@ -505,7 +513,14 @@ pg_query_state(PG_FUNCTION_ARGS)
505
513
errmsg ("attempt to extract state of current process" )));
506
514
507
515
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 )
509
524
ereport (ERROR , (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
510
525
errmsg ("backend with pid=%d not found" , pid )));
511
526
@@ -730,15 +745,25 @@ GetRemoteBackendUserId(PGPROC *proc)
730
745
{
731
746
Oid result ;
732
747
748
+ #if PG_VERSION_NUM >= 170000
749
+ Assert (proc && proc -> vxid .procNumber != INVALID_PROC_NUMBER );
750
+ #else
733
751
Assert (proc && proc -> backendId != InvalidBackendId );
752
+ #endif
753
+
734
754
Assert (UserIdPollReason != INVALID_PROCSIGNAL );
735
755
Assert (counterpart_userid );
736
756
737
757
counterpart_userid -> userid = InvalidOid ;
738
758
counterpart_userid -> caller = MyLatch ;
739
759
pg_write_barrier ();
740
760
761
+ #if PG_VERSION_NUM >= 170000
762
+ SendProcSignal (proc -> pid , UserIdPollReason , proc -> vxid .procNumber );
763
+ #else
741
764
SendProcSignal (proc -> pid , UserIdPollReason , proc -> backendId );
765
+ #endif
766
+
742
767
for (;;)
743
768
{
744
769
SpinLockAcquire (& counterpart_userid -> mutex );
@@ -926,7 +951,12 @@ GetRemoteBackendWorkers(PGPROC *proc)
926
951
List * result = NIL ;
927
952
LOCKTAG tag ;
928
953
954
+ #if PG_VERSION_NUM >= 170000
955
+ Assert (proc && proc -> vxid .procNumber != INVALID_PROC_NUMBER );
956
+ #else
929
957
Assert (proc && proc -> backendId != InvalidBackendId );
958
+ #endif
959
+
930
960
Assert (WorkerPollReason != INVALID_PROCSIGNAL );
931
961
Assert (mq );
932
962
@@ -936,7 +966,12 @@ GetRemoteBackendWorkers(PGPROC *proc)
936
966
shm_mq_set_receiver (mq , MyProc );
937
967
UnlockShmem (& tag );
938
968
969
+ #if PG_VERSION_NUM >= 170000
970
+ sig_result = SendProcSignal (proc -> pid , WorkerPollReason , proc -> vxid .procNumber );
971
+ #else
939
972
sig_result = SendProcSignal (proc -> pid , WorkerPollReason , proc -> backendId );
973
+ #endif
974
+
940
975
if (sig_result == -1 )
941
976
goto signal_error ;
942
977
@@ -1088,9 +1123,16 @@ GetRemoteBackendQueryStates(PGPROC *leader,
1088
1123
* send signal `QueryStatePollReason` to all processes and define all alive
1089
1124
* ones
1090
1125
*/
1126
+ #if PG_VERSION_NUM >= 170000
1127
+ sig_result = SendProcSignal (leader -> pid ,
1128
+ QueryStatePollReason ,
1129
+ leader -> vxid .procNumber );
1130
+ #else
1091
1131
sig_result = SendProcSignal (leader -> pid ,
1092
1132
QueryStatePollReason ,
1093
1133
leader -> backendId );
1134
+ #endif
1135
+
1094
1136
if (sig_result == -1 )
1095
1137
goto signal_error ;
1096
1138
foreach (iter , pworkers )
@@ -1101,9 +1143,16 @@ GetRemoteBackendQueryStates(PGPROC *leader,
1101
1143
1102
1144
pg_atomic_add_fetch_u32 (& counterpart_userid -> n_peers , 1 );
1103
1145
1146
+ #if PG_VERSION_NUM >= 170000
1147
+ sig_result = SendProcSignal (proc -> pid ,
1148
+ QueryStatePollReason ,
1149
+ proc -> vxid .procNumber );
1150
+ #else
1104
1151
sig_result = SendProcSignal (proc -> pid ,
1105
1152
QueryStatePollReason ,
1106
1153
proc -> backendId );
1154
+ #endif
1155
+
1107
1156
if (sig_result == -1 )
1108
1157
{
1109
1158
if (errno != ESRCH )
0 commit comments