Reorder superuser check in pg_log_backend_memory_contexts()
authorMichael Paquier <michael@paquier.xyz>
Mon, 7 Jun 2021 23:53:12 +0000 (08:53 +0900)
committerMichael Paquier <michael@paquier.xyz>
Mon, 7 Jun 2021 23:53:12 +0000 (08:53 +0900)
commit4e47b02834827fa700627290fae02f89a450368c
tree0a944a3770ddca203cb21369860c2198ca061e1d
parent3bb309be7533e153d86390642e8a2d054bbe82c8
Reorder superuser check in pg_log_backend_memory_contexts()

The use of this function is limited to superusers and the code includes
a hardcoded check for that.  However, the code would look for the PGPROC
entry to signal for the memory dump before checking if the user is a
superuser or not, which does not make sense if we know that an error
will be returned.  Note that the code would let one know if a process
was a PostgreSQL process or not even for non-authorized users, which is
not the case now, but this avoids taking ProcArrayLock that will most
likely finish by being unnecessary.

Thanks to Julien Rouhaud and Tom Lane for the discussion.

Discussion: https://postgr.es/m/YLxw1uVGIAP5uMPl@paquier.xyz
src/backend/utils/adt/mcxtfuncs.c