psql internals queries breaks in presence of user-defined operators - Mailing list pgsql-hackers

From Kirill Reshke
Subject psql internals queries breaks in presence of user-defined operators
Date
Msg-id CALdSSPhZjj01YN5E2UmVOcr4QWKzgJ_hRQfv0x+MHwjk-dw=Dw@mail.gmail.com
Whole thread
Responses Re: psql internals queries breaks in presence of user-defined operators
List pgsql-hackers
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.


This is not a security issue, per:
https://www.postgresql.org/docs/current/app-psql.html says:

  If untrusted users have access to a database that has not adopted a secure
  schema usage pattern, begin your session by removing publicly-writable
  schemas from search_path.

-- 
Best regards,
Kirill Reshke

Attachment

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Handle concurrent drop when doing whole database vacuum
Next
From: Ashutosh Sharma
Date:
Subject: Re: Report bytes and transactions actually sent downtream