search_path not recomputed when role name changes

Started by Jeff Davisover 2 years ago6 messagesbugs
Jump to latest
#1Jeff Davis
pgsql@j-davis.com

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

Attachments:

v1-0001-Recalculate-search_path-after-ALTER-ROLE.patchtext/x-patch; charset=UTF-8; name=v1-0001-Recalculate-search_path-after-ALTER-ROLE.patchDownload+5-2
#2Nathan Bossart
nathandbossart@gmail.com
In reply to: Jeff Davis (#1)
Re: search_path not recomputed when role name changes

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

#3Michael Paquier
michael@paquier.xyz
In reply to: Nathan Bossart (#2)
Re: search_path not recomputed when role name changes

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

#4Jeff Davis
pgsql@j-davis.com
In reply to: Michael Paquier (#3)
Re: search_path not recomputed when role name changes

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

Attachments:

v2-0001-Recalculate-search_path-after-ALTER-ROLE.patchtext/x-patch; charset=UTF-8; name=v2-0001-Recalculate-search_path-after-ALTER-ROLE.patchDownload+162-2
#5Nathan Bossart
nathandbossart@gmail.com
In reply to: Jeff Davis (#4)
Re: search_path not recomputed when role name changes

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

#6Michael Paquier
michael@paquier.xyz
In reply to: Nathan Bossart (#5)
Re: search_path not recomputed when role name changes

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