Re: psql internals queries breaks in presence of user-defined operators

From: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>
To: Kirill Reshke <reshkekirill(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: psql internals queries breaks in presence of user-defined operators
Date: 2026-06-25 09:25:52
Message-ID: CAJTYsWWKbeV4VTHxZNXSund86aEyLT8BU6FQzcAvbQhkyTcujw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Thu, 25 Jun 2026 at 12:03, Kirill Reshke <reshkekirill(at)gmail(dot)com> wrote:

> Hi!
> If a user creates a malformed operator in theirs database, like:
>
> ```
> create or replace function f (name, name) RETURNS boolean AS $$ begin
> RETURN $1::text = $2::text; end; $$ LANGUAGE plpgsql;
> CREATE OPERATOR public.!~ ( LEFTARG = name, RIGHTARG = name, FUNCTION = f);
> ```
>
> then psql's meta-commands queries like \du stop working.
>
> That's because the catalog misses operators for leftarg = name,
> rightarg = name and oprname = '!~'.
>
> I think this can be enhanced a little by schema-qualifying psql's
> internal query.
> While this issue is fully the user's fault, I think psql can still be
> a little more conservative in operator selection, and work anyways.
> PFA POC patch.
>

Thanks for the patch!

I reviewed it and the changes look good to me.\du, \dn, \dt work
with a shadowing operation present.

Would it be worth adding a test (maybe in the psql regression suite) that
the
describe queries still return the expected rows when such an operator
exists?

Regards,
Ayush

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Banck 2026-06-25 09:30:32 Out-of-Cycle release? (was Re: BUG #19490: Streaming standby on 16.14 stops applying WAL on MultiXactOffsetSLRU when primary is 16.8)
Previous Message shveta malik 2026-06-25 09:16:22 Re: Support EXCEPT for ALL SEQUENCES publications