SET SESSION AUTHORIZATION command doesn't update status of backend - Mailing list pgsql-bugs

From Andrey V. Lepikhov
Subject SET SESSION AUTHORIZATION command doesn't update status of backend
Date
Msg-id 76ae5aaf-1843-4d84-0430-f35da7f786b9@postgrespro.ru
Whole thread Raw
Responses Re: SET SESSION AUTHORIZATION command doesn't update status of backend  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
Hi,

Nikita Degtyarev (n.degtyarev@postgrespro.ru) reported a suspicious 
behaviour of a SET SESSION AUTHORIZATION command. If you switch user in 
a session:

CREATE USER abc;
SET SESSION AUTHORIZATION abc;

command "SELECT SESSION_USER, CURRENT_USER" shows us:

  session_user | current_user
--------------+--------------
  abc          | abc

But if you launch a job:
SELECT pg_sleep(60);

and will see into the pg_stat_activity:

SELECT usename,query FROM pg_stat_activity
WHERE backend_type = 'client backend';

it tell you that this job is executing with the original user:

  usename |                   query
---------+--------------------------------------------
  andrey  | SELECT usename,query FROM pg_stat_activity+
          | WHERE backend_type = 'client backend';
  abc     | SELECT pg_sleep(60);

The deal is in missed update of PgBackendStatus after updating of 
session user.
The attached patch fixes this bug.

-- 
regards,
Andrey Lepikhov
Postgres Professional

Attachment

pgsql-bugs by date:

Previous
From: Masahiko Sawada
Date:
Subject: Re: Inconsistent behavior of pg_dump/pg_restore on DEFAULT PRIVILEGES
Next
From: Tom Lane
Date:
Subject: Re: SET SESSION AUTHORIZATION command doesn't update status of backend