Index: src/backend/postmaster/pgstat.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/postmaster/pgstat.c,v retrieving revision 1.179 diff -c -r1.179 pgstat.c *** src/backend/postmaster/pgstat.c 15 Aug 2008 08:37:39 -0000 1.179 --- src/backend/postmaster/pgstat.c 25 Aug 2008 09:08:46 -0000 *************** *** 2264,2269 **** --- 2264,2294 ---- } /* ---------- + * pgstat_report_change_authorization() + * + * Called from *** to report the changing of session authorization. + * ---------- + */ + void + pgstat_report_change_authorization(void) + { + volatile PgBackendStatus *beentry = MyBEEntry; + + if (!pgstat_track_activities || !beentry) + return; + + /* + * Update my status entry, following the protocol of bumping + * st_changecount before and after. We use a volatile pointer + * here to ensure the compiler doesn't try to get cute. + */ + beentry->st_changecount++; + beentry->st_userid = GetSessionUserId(); + beentry->st_changecount++; + Assert((beentry->st_changecount & 1) == 0); + } + + /* ---------- * pgstat_report_waiting() - * * Called from lock manager to report beginning or end of a lock wait. Index: src/backend/utils/init/miscinit.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/utils/init/miscinit.c,v retrieving revision 1.167 diff -c -r1.167 miscinit.c *** src/backend/utils/init/miscinit.c 27 Mar 2008 17:24:16 -0000 1.167 --- src/backend/utils/init/miscinit.c 25 Aug 2008 09:08:46 -0000 *************** *** 349,354 **** --- 349,357 ---- /* We force the effective user IDs to match, too */ OuterUserId = userid; CurrentUserId = userid; + + /* Let the stats subsystem know of the change */ + pgstat_report_change_authorization(); } Index: src/include/pgstat.h =================================================================== RCS file: /projects/cvsroot/pgsql/src/include/pgstat.h,v retrieving revision 1.78 diff -c -r1.78 pgstat.h *** src/include/pgstat.h 15 Aug 2008 08:37:40 -0000 1.78 --- src/include/pgstat.h 25 Aug 2008 09:08:46 -0000 *************** *** 626,631 **** --- 626,632 ---- extern void pgstat_report_activity(const char *what); extern void pgstat_report_xact_timestamp(TimestampTz tstamp); + extern void pgstat_report_change_authorization(void); extern void pgstat_report_waiting(bool waiting); extern const char *pgstat_get_backend_current_activity(int pid, bool checkUser);