Re: Behavior of pg_catalog dependent on search_path: expected or bug? - Mailing list pgsql-bugs

From David G. Johnston
Subject Re: Behavior of pg_catalog dependent on search_path: expected or bug?
Date
Msg-id CAKFQuwar9sQqgL+8RUkgkQSe+ajCkvxvgkhvx07ZqRt_edAXNw@mail.gmail.com
Whole thread Raw
In response to Behavior of pg_catalog dependent on search_path: expected or bug?  ("ldh@laurent-hasson.com" <ldh@laurent-hasson.com>)
List pgsql-bugs
On Sat, Feb 4, 2023 at 9:38 PM ldh@laurent-hasson.com <ldh@laurent-hasson.com> wrote:

 

This script worked the first time but then failed on reruns. After some investigation, I noticed that this was run as part of a larger script and a “search_path” was set. I was able to isolate a behavior that I am not able to understand, i.e., bug or expected behavior?

 

The code below fails:

 

SET search_path TO XXX;

select p.oid::regprocedure

  from pg_catalog.pg_proc p

  join pg_catalog.pg_namespace n on p.pronamespace = n.oid

 where p.oid::regprocedure::text='sample(anyelement)'

   and n.nspname = 'public'


Working as documented:


"The reg<...> input converter handles the <...> lookup according to the schema path setting, and so it does the “right thing” automatically."

and, more pertinent to your example:

"All of the OID alias types for objects that are grouped by namespace accept schema-qualified names, and will display schema-qualified names on output if the object would not be found in the current search path without being qualified."

Thus what is really failing is your attempt to compare the text cast result in the where clause to a non-schema qualified procedure named sample(anyelement).

David J.

P.S. Please provide the behavior you observe and why you think it is incorrect in future reports, don't just say "it fails", there are many ways in which things can fail.
P.P.S. This mailing list is the bug system so you've already entered the details.

pgsql-bugs by date:

Previous
From: "ldh@laurent-hasson.com"
Date:
Subject: Behavior of pg_catalog dependent on search_path: expected or bug?
Next
From: Tom Lane
Date:
Subject: Re: Behavior of pg_catalog dependent on search_path: expected or bug?