Thread: search_path not recomputed when role name changes

search_path not recomputed when role name changes

From
Jeff Davis
Date:
Session 1 as superuser:
  CREATE USER u1;
  CREATE SCHEMA u1 AUTHORIZATION u1;
  GRANT ALL PRIVILEGES ON SCHEMA public TO u1;

Session 2 as u1:
  SET search_path= "$user", public;
  CREATE TABLE u1.x(t) AS SELECT 'data in u1.x';
  CREATE TABLE public.x(t) AS SELECT 'data in public.x';
  SELECT t FROM x; -- uses u1.x

Session 1 as superuser:
  ALTER ROLE u1 RENAME TO u2;

Session 2 as u1:
  SELECT CURRENT_USER; -- shows u2
  SHOW search_path; -- $user, public
  SELECT t FROM x; -- UNEXPECTED: uses u1.x still
  SET search_path = public;
  SET search_path TO default;
  SELECT t FROM x; -- uses public.x

The fix is simple, attached.


--
Jeff Davis
PostgreSQL Contributor Team - AWS



Attachment

Re: search_path not recomputed when role name changes

From
Nathan Bossart
Date:
On Thu, Jul 27, 2023 at 11:21:25AM -0700, Jeff Davis wrote:
> The fix is simple, attached.

LGTM

-- 
Nathan Bossart
Amazon Web Services: https://aws.amazon.com



Re: search_path not recomputed when role name changes

From
Michael Paquier
Date:
On Sat, Jul 29, 2023 at 09:08:02PM -0700, Nathan Bossart wrote:
> On Thu, Jul 27, 2023 at 11:21:25AM -0700, Jeff Davis wrote:
>> The fix is simple, attached.
>
> LGTM

Is that something that should have an isolation test?
--
Michael

Attachment

Re: search_path not recomputed when role name changes

From
Jeff Davis
Date:
On Sun, 2023-07-30 at 14:58 +0900, Michael Paquier wrote:
> Is that something that should have an isolation test?

Good idea, attached.

Is there any logical ordering or grouping in the isolation_schedule? I
just added it at the end.

Regards,
    Jeff Davis


Attachment

Re: search_path not recomputed when role name changes

From
Nathan Bossart
Date:
On Wed, Aug 02, 2023 at 12:09:58PM -0700, Jeff Davis wrote:
> Is there any logical ordering or grouping in the isolation_schedule? I
> just added it at the end.

It looks like folks try to group related tests, but I don't sense any
strict ordering.  It's probably fine to add it to the end.  Maybe we should
alphabetize the list someday (/me braces for collation jokes).

-- 
Nathan Bossart
Amazon Web Services: https://aws.amazon.com



Re: search_path not recomputed when role name changes

From
Michael Paquier
Date:
On Thu, Aug 03, 2023 at 04:28:41PM -0700, Nathan Bossart wrote:
> It looks like folks try to group related tests, but I don't sense any
> strict ordering.  It's probably fine to add it to the end.  Maybe we should
> alphabetize the list someday (/me braces for collation jokes).

Isolation tests have been added over the years in the order that a
committer and/or author saw fit at the point when it was added.  There
has never been any kind of strict ordering, but there may be locations
where having a new test makes more sense than other locations.
--
Michael

Attachment