Re: Event-Triggers for DB owners instead of just SUPERUSER

2025-04-14 Thread Wolfgang Walther
Dominique Devienne: Can't event-triggers also be available to DB owners, instead of just SUPERUSER? There's a recent -hackers thread exactly about this: https://www.postgresql.org/message-id/flat/CAGRrpzbtYDkg7_xwfzrqByYgCJQbbL38tADyuN%2B6tAkbA-Pnkg%40mail.gmail.com Best, Wolfgang

Re: Interesting case of IMMUTABLE significantly hurting performance

2025-04-14 Thread Wolfgang Walther
Tom Lane: If you err in the other direction, you don't get slapped on the wrist that way. We're willing to inline VOLATILE functions, for instance, whether or not the contained expression is volatile. Similarly for STRICT, and I think parallel safety as well. So my own habit when writing a SQL f

Re: Fwd: A million users

2024-11-22 Thread walther
Eric Hanson: Did you find some way to prevent RESET ROLE?  I once advocated for a NO RESET option on SET ROLE [1] so that RESET ROLE would be impossible for the rest of the session.  Still think it would be helpful. Yeah, this is still on my list of things to research more about eventually -

Re: Fwd: A million users

2024-11-13 Thread walther
Dominique Devienne: Hi. Sure, that's a good point, and a best practice IMHO. But I already do that, and the original question remain, i.e. how does PostgreSQL with thousands or millions of roles? In my use case, 1000 LOGIN users, and 10'000 schema related ROLEs, is possible, with can translate to

Re: Backward compat issue with v16 around ROLEs

2024-09-11 Thread Wolfgang Walther
Dominique Devienne: Hi David. I did as you suggested, and it fails the same way. Did I misunderstand you? --DD [..] ddevienne=> grant dd_owner to dd_admin with admin option; -- I think this needs to be the other way around: grant dd_admin to dd_owner with admin option; Best, Wol

Re: current_role of caller of a DEFINER function

2024-06-26 Thread walther
Dominique Devienne: 1) Is there any way to know the current_role of the caller of a DEFINER function. I fear the answer is no, but better be sure from experts here. You can do something like this: CREATE DOMAIN current_user_only AS text CONSTRAINT current_user_only CHECK (VALUE = CURRENT_USE

Re: DEFINER / INVOKER conundrum

2023-04-03 Thread walther
Erik Wienhold: A single DEFINER function works if you capture current_user with a parameter and default value. Let's call it claimed_role. Use pg_has_role[0] to check that session_user has the privilege for claimed_role (in case the function is called with an explicit value), otherwise raise an

Re: DROP OWNED BY fails with #53200: ERROR: out of shared memory

2022-01-11 Thread Wolfgang Walther
Dominique Devienne: I wish for DB-specific ROLEs BTW... Same here. That would be so useful.

Re: ALTER ROLE ... SET in current database only

2021-02-16 Thread Wolfgang Walther
Abdul Qoyyuum: Wouldnt you need to connect to the database first before you can ALTER ROLE anything? Of course, otherwise the notion of "current database" wouldn't make sense at all. But that's only before executing the code. I am not writing and executing this code at the same time. In my

ALTER ROLE ... SET in current database only

2021-02-15 Thread Wolfgang Walther
Hi, I'm trying to set a GUC for a role in the current database only - but don't know the name of the database at the time of writing code. Could be development, staging, ... I would basically like to do something like this: ALTER ROLE a IN CURRENT DATABASE SET b TO c; Although that syntax d

Re: Execution order of CTEs / set_config and current_setting in the same query

2020-12-09 Thread Wolfgang Walther
Tom Lane: I think you're on fairly shaky ground here. Generally speaking, a CTE will be executed/read only when the parent query needs the next row from it. Your examples ensure that the CTE is read before the parent query's results are computed; but in realistic usage you'd presumably be joini

Execution order of CTEs / set_config and current_setting in the same query

2020-12-09 Thread Wolfgang Walther
Hi, with PostgREST [1] we are translating HTTP requests into SQL queries. For each request we are setting some metadata (headers, ...) as GUCs. We used to do it like this: SET LOCAL request.headers.x = 'y'; ... Since this is user-provided data, we want to use parametrized/prepared statements