Re: pgsql: Fix search_path to a safe value during maintenance operations.

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Jeff Davis <pgsql(at)j-davis(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Noah Misch <noah(at)leadboat(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, Nathan Bossart <nathandbossart(at)gmail(dot)com>
Subject: Re: pgsql: Fix search_path to a safe value during maintenance operations.
Date: 2023-08-01 18:16:19
Message-ID: CAKFQuwaM_9=Xb_jAdX9x8-PuDFfWdx0YRt-Bh9QiEh2KpPF+cw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On Tue, Aug 1, 2023 at 10:42 AM Robert Haas <robertmhaas(at)gmail(dot)com> wrote:

> Now, if we don't go in the direction of resolving everything at parse
> time, then I think capturing search_path is probably the next best
> thing, or at least the next best thing that I've thought up so far.

I'd much rather strongly encourage the user to write a safe and
self-sufficient function definition. Specifically, if there is no
search_path attached to the function then the search path that will be in
place will be temp + pg_catalog only. Though I wonder whether it would be
advantageous to allow a function to have a temporary schema separate from
the session-scoped one...

They can use ALTER FUNCTION and the existing "FROM CURRENT" specification
to get back to current behavior if desired.

Going further, I could envision an "explicit" mode that both performs a
parse-time check for object existence and optionally reports an error if
the lookup happened via an inexact match - forcing lots more type casts to
occur (we'd probably need to invent something to say "must match the
anyelement function signature") but ensuring at parse time you've correctly
identified everything you intend to be using. Sure, the meanings of those
things could change but the surface is much smaller than plugging a new
function that matches earlier in the lookup resolution process.

David J.

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2023-08-01 21:18:03 pgsql: Fix pg_stat_io buffer reuse test instability
Previous Message Robert Haas 2023-08-01 17:56:46 pgsql: Add and use symbolic constants for tar header offsets and file t

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2023-08-01 18:24:15 Re: [PATCH] Support % wildcard in extension upgrade filenames
Previous Message Daniel Gustafsson 2023-08-01 18:15:41 Re: Improve the performance of nested loop join in the case of partitioned inner table