Re: Unexpected Backend PID reported by Notification

2024-06-11 Thread Dominique Devienne
On Tue, Jun 11, 2024 at 5:29 PM David G. Johnston wrote: > On Tuesday, June 11, 2024, Dominique Devienne wrote: >> Are Stored PROCs running in a different backend? >> Are Triggers running in a different backend? > No to both. Whatever backend the SQL to invoke those

set search_path "$owner". And name versus literal for schemas.

2024-06-18 Thread Dominique Devienne
Hi. Two things related to the search_path. First, [the doc][1] mentions one can use a variable like "$user" for the search_path. But setting the search_path is also for FUNCTIONs and PROCEDUREs, and there what I really REALLY would like, is the ability to use "$owner", to limit the search_path to

current_role of caller of a DEFINER function

2024-06-26 Thread Dominique Devienne
Hi. I was led to believe (by an hallucination...) that I could know the current_role of the caller of a DEFINER function, but after actual experimentation, turns out it shows the OWNER of the function, and not the current_role of the caller. I foolishly thought curent_role != current_user inside t

Re: current_role of caller of a DEFINER function

2024-06-26 Thread Dominique Devienne
On Wed, Jun 26, 2024 at 12:11 PM wrote: > 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: > > C

Re: current_role of caller of a DEFINER function

2024-06-26 Thread Dominique Devienne
On Wed, Jun 26, 2024 at 2:42 PM David G. Johnston wrote: > On Wednesday, June 26, 2024, Dominique Devienne wrote: >> Only session_user >> is representative of the caller, and reliable (modulo SUPERUSER and >> SET AUTHORIZATION, but that's a different story and kinda n

MVCC: Using function doing INSERT and returning PK in WHERE clause of SELECT statement

2024-07-01 Thread Dominique Devienne
Hi. So for business rule reason, INSERT'ing a new row is wrapped in a DEFINER function, that returns the newly inserted row's OK (and integral ID). And in the code calling that function, I was SELECT * FROM table WHERE ID = insert_row_via_func() to "save a round trip", combining the inse

Re: re-novice coming back to pgsql: porting an SQLite update statement to postgres

2024-07-23 Thread Dominique Devienne
On Tue, Jul 23, 2024 at 10:35 PM Adrian Klaver wrote: > Just know that SQLite does not enforce types [...] That's true, and applies to the OP's schema. But for the record, SQLite *can* enforce types these days, on an opt-in basis, with [STRICT tables][1]. Albeit with a limited type-system. --DD

Re: Issue while creating index dynamically

2024-07-25 Thread Dominique Devienne
On Thu, Jul 25, 2024 at 7:42 AM veem v wrote: > I was thinking the individual statement will work fine if I pull out those > from the begin..end block, as those will then be not bounded by any outer > transaction. > However, When I was trying it from dbeaver by extracting individual index > cr

UPDATE-FROM and INNER-JOIN

2024-08-05 Thread Dominique Devienne
In https://sqlite.org/forum/forumpost/df23d80682 Richard Hipp (Mr SQLite) shows an example of something that used to be supported by SQLite, but then wasn't, to be compatible with PostgreSQL. Thus I'm curious as to why PostgreSQL refuses the first formulation. Could anyone provide any insights? Th

Building v17 Beta2 on Windows

2024-08-05 Thread Dominique Devienne
Hi. I'm using as the go-between for a colleague that's not subscribed to this ML. In short, we have Python-based automation scripts to build our 3rd parties. And the ones we have, that worked fine with v16, do not with v17 beta2, on Windows. Thus I'm asking for advice as how we should proceed. TIA

Re: UPDATE-FROM and INNER-JOIN

2024-08-05 Thread Dominique Devienne
On Mon, Aug 5, 2024 at 3:56 PM Tom Lane wrote: > Dominique Devienne writes: > > In https://sqlite.org/forum/forumpost/df23d80682 > > Richard Hipp (Mr SQLite) shows an example of something > > that used to be supported by SQLite, but then wasn't, to be > > com

Re: UPDATE-FROM and INNER-JOIN

2024-08-05 Thread Dominique Devienne
On Mon, Aug 5, 2024 at 5:01 PM Tom Lane wrote: > > Dominique Devienne writes: > > The reason I find the restriction damaging is that `FROM t1, t2 WHERE > > t1.c1 = t2.c2` > > is the "old" way to write joins, versus the "newer" `FROM t1 JOIN t2

Re: Building v17 Beta2 on Windows

2024-08-06 Thread Dominique Devienne
On Mon, Aug 5, 2024 at 2:26 PM David Rowley wrote: > Meson is now the only available method for Visual Studio builds." Thanks David. My colleague figured it out, thanks to your pointers. Cheers, --DD

libpq version macro to use or not PQsocketPoll

2024-08-06 Thread Dominique Devienne
Hi. Now that v17beta2 is part of my dev-env, I'm trying out the new API. And I discover there's no version macro for conditional compilation in LIBPQ... I found https://www.postgresql.org/message-id/968815.1623936849%40sss.pgh.pa.us where Tom thinks that a horrible idea, and instead proposes a new

Re: libpq version macro to use or not PQsocketPoll

2024-08-06 Thread Dominique Devienne
On Tue, Aug 6, 2024 at 4:31 PM Tom Lane wrote: > Dominique Devienne writes: > > Hi. Now that v17beta2 is part of my dev-env, I'm trying out the new API. > > And I discover there's no version macro for conditional compilation in > > LIBPQ... > > Indeed, that

Re: Building v17 Beta2 on Windows

2024-08-09 Thread Dominique Devienne
On Tue, Aug 6, 2024 at 10:53 AM Dominique Devienne wrote: > On Mon, Aug 5, 2024 at 2:26 PM David Rowley wrote: > > Meson is now the only available method for Visual Studio builds." > > Thanks David. My colleague figured it out, thanks to your pointers. Cheers, > -

Re: libpq version macro to use or not PQsocketPoll

2024-08-09 Thread Dominique Devienne
On Tue, Aug 6, 2024 at 4:48 PM Dominique Devienne wrote: > On Tue, Aug 6, 2024 at 4:31 PM Tom Lane wrote: > > Dominique Devienne writes: > > Indeed, that's an oversight, and there's a number of other things > > we added to libpq-fe.h between 16 and 17 that

Re: Column type modification in big tables

2024-08-14 Thread Dominique Devienne
On Tue, Aug 13, 2024 at 10:54 PM Peter J. Holzer wrote: > You could look at the data files. Tables in PostgreSQL are stored as a > series of 1GB files, so you watching them being created and/or read > gives you a pretty good idea about progress. Thanks Peter, very insightful. Appreciated. --DD

Using PQsocketPoll() for PIPELINE mode

2024-08-14 Thread Dominique Devienne
Hi. I've now used successfully the new PQsocketPoll() API in the context of waiting for notifications, using beta2 and 3. But now I'm looking into using it in the context of PIPELINE mode. Where I suppose both forRead and forWrite are 1, but the return code only indicates whether the condition is

Re: Using PQsocketPoll() for PIPELINE mode

2024-08-27 Thread Dominique Devienne
On Wed, Aug 14, 2024 at 2:50 PM Dominique Devienne wrote: > Hi. I've now used successfully the new PQsocketPoll() API > in the context of waiting for notifications, using beta2 and 3. > > But now I'm looking into using it in the context of PIPELINE mode. > Where I

Re: Using PQsocketPoll() for PIPELINE mode

2024-08-27 Thread Dominique Devienne
On Tue, Aug 27, 2024 at 12:23 PM Dominique Devienne wrote: > On Wed, Aug 14, 2024 at 2:50 PM Dominique Devienne > wrote: > > Hi. I've now used successfully the new PQsocketPoll() API > > in the context of waiting for notifications, using beta2 and 3. > > > > B

Re: How to grant role to other user

2024-09-03 Thread Dominique Devienne
On Tue, Sep 3, 2024 at 4:31 PM Andrus wrote: > GRANT "eeva_owner" TO "ingmar.e" > This command throws error > ERROR: permission denied to grant role "eeva_owner" Works are expected when I try it. FWIW. --DD c:\Users\ddevienne>psql service=pau16 psql (17beta3, server 16.1) ddevienne=> creat

Re: Faster data load

2024-09-09 Thread Dominique Devienne
On Sun, Sep 8, 2024 at 8:27 PM Adrian Klaver wrote: > > simple INSERT ... SELECT was more than twice as fast as 8 parallel COPY > > operations (and about 8 times as fast as a single COPY). > > Yeah they seem to have changed a great deal. Though you are correct in > saying COPY is not faster then

Backward compat issue with v16 around ROLEs

2024-09-11 Thread Dominique Devienne
Hi. I'm going around in circles trying to solve an issue with our system when running against a PostgreSQL v16 server. Which is linked to the weakening of CREATEROLE to have more granular permissions. I've distilled it down to a simple workflow, as shown below on both v14 (OK) and v16 (KO). In our

Re: Backward compat issue with v16 around ROLEs

2024-09-11 Thread Dominique Devienne
On Wed, Sep 11, 2024 at 5:06 PM David G. Johnston wrote: > As the error indicates, this grant needs to be done with admin option. Hi David. I did as you suggested, and it fails the same way. Did I misunderstand you? --DD D:\pdgm\trunk\psc2>psql service=pau16 psql (17beta3, server 16.1) Type "hel

Re: Backward compat issue with v16 around ROLEs

2024-09-11 Thread Dominique Devienne
On Wed, Sep 11, 2024 at 5:09 PM Adrian Klaver wrote: > What user did you do the above as? My own user, which lacks SUPERUSER (I have CREATEROLE and CREATEDB only, and LOGIN of course). > On my Postgres 16.4 instance logged in as postgres: > test=# create role dd_owner createrole; > CREATE ROLE

Re: Backward compat issue with v16 around ROLEs

2024-09-12 Thread Dominique Devienne
On Wed, Sep 11, 2024 at 11:39 PM Tom Lane wrote: > Dominique Devienne writes: > > Hi. I'm going around in circles trying to solve an issue with our > > system when running against a PostgreSQL v16 server. Which is linked > > to the weakening of CREATEROLE to have

Re: Backward compat issue with v16 around ROLEs

2024-09-12 Thread Dominique Devienne
On Wed, Sep 11, 2024 at 10:20 PM Pavel Luzanov wrote: > On 11.09.2024 22:21, David G. Johnston wrote: >> I think this needs to be the other way around: > [...]. In any case fixing the with admin error is the correct approach. > > Unfortunately, it won't work. > Dominique is right. This will lead

Re: Effects of REVOKE SELECT ON ALL TABLES IN SCHEMA pg_catalog FROM PUBLIC

2024-09-12 Thread Dominique Devienne
On Thu, Sep 12, 2024 at 3:06 PM Greg Sabino Mullane wrote: > (Also note that determining if a database or user exists does not even > require a successful login to the cluster.) Hi. How so? I was not aware of such possibilities. Can you please give pointers (docs, examples) of this? Thanks, --D

Re: Backward compat issue with v16 around ROLEs

2024-09-12 Thread Dominique Devienne
On Thu, Sep 12, 2024 at 2:40 PM Dominique Devienne wrote: > Basically the above explain why we have that > dd_user (INHERIT) > `-> member-of dd_admin (NOINHERIT) > `-> member-of dd_owner (INHERIT). > > In pre-v16, once again, this was fine. > Because v16+ a

Re: Effects of REVOKE SELECT ON ALL TABLES IN SCHEMA pg_catalog FROM PUBLIC

2024-09-12 Thread Dominique Devienne
On Thu, Sep 12, 2024 at 3:53 PM Greg Sabino Mullane wrote: > On Thu, Sep 12, 2024 at 9:12 AM Dominique Devienne > wrote: >> On Thu, Sep 12, 2024 at 3:06 PM Greg Sabino Mullane >> wrote: >> > (Also note that determining if a database or user exists does not even

LibPQ: Lifetime of PGresult passed in to PQnoticeReceiver callback

2021-12-13 Thread Dominique Devienne
Hi, The doc at https://www.postgresql.org/docs/current/libpq-notice-processing.html is not clear to me on whether it should be PQclear'd or not. Who manages the lifetime of that PGresult? Also, the "could be called as long as either the PGconn or PGresult exist" mention, implies we do not need to

Re: LibPQ: Lifetime of PGresult passed in to PQnoticeReceiver callback

2021-12-14 Thread Dominique Devienne
Hi again. Is this not the right ML? Which PostgreSQL ML should this question be asked to, to have a chance to get an answer? I'm new to this particular ML, and I'm surprised by the silence. Thanks, --DD On Mon, Dec 13, 2021 at 9:46 AM Dominique Devienne wrote: > Hi, > >

Trouble DROP'ing a ROLE, despite REVOKE'ing its privileges

2022-01-05 Thread Dominique Devienne
At least I think I've revoked the privileges... Hi. I'm writing a unit test that creates a set of schemas and roles, then drops all those roles and schemas. First I create a NOINHERIT NOLOGIN CREATEROLE "owner" ROLE, which I GRANT on the current user (and other LOGIN users later), then SET ROLE "

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

2022-01-10 Thread Dominique Devienne
I'm trying to DROP a ROLE that has 4 schemas: * 2 smallish ones (1 or 2 dozen tables each), * 2 largish ones (250 tables, totalling around 4000 columns each). And of course there are various indexes, constraints, etc... on each schema. This fails with: DDL Error: DROP OWNED BY "Epos-PNS (a73e1fb

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

2022-01-10 Thread Dominique Devienne
tables? I'm confused... --DD On Mon, Jan 10, 2022 at 7:06 PM Dominique Devienne wrote: > On Mon, Jan 10, 2022 at 6:39 PM Tom Lane wrote: > >> Dominique Devienne writes: >> > I'm trying to DROP a ROLE that has 4 schemas: >> > * 2 smallish ones (1 or 2 doze

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

2022-01-10 Thread Dominique Devienne
On Mon, Jan 10, 2022 at 10:29 PM Tom Lane wrote: > "David G. Johnston" writes: > > On Mon, Jan 10, 2022 at 12:09 PM Dominique Devienne > > > wrote: > >> Tom wrote "relation" for the number of locks necessary for DROP OWNED > BY. > &

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

2022-01-11 Thread Dominique Devienne
On Mon, Jan 10, 2022 at 10:40 PM Alvaro Herrera wrote: > On 2022-Jan-10, Dominique Devienne wrote: > > > Btw, is there a catalog accurately count a schémas relations from > the catalog? > > pg_class > ddevienne=> select relnamespace::regnamespace::text, count(*) from

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

2022-01-11 Thread Dominique Devienne
On Mon, Jan 10, 2022 at 11:13 PM Adrian Klaver wrote: > On 1/10/22 13:58, Dominique Devienne wrote: > > > Given that Tom mentions max_locks_per_transaction can be safely > increased, > > and given the stats I mentioned in this thread, what would a > > "reaso

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

2022-01-11 Thread Dominique Devienne
On Tue, Jan 11, 2022 at 11:05 AM Francisco Olarte wrote: > Dominique: > Not going to enter into the lock situation but... > OK :). But it does matter. those locks. Especially if DROP'ing a DB (as you suggest) requires just the same. > On Tue, 11 Jan 2022 at 10:24, Dominique

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

2022-01-11 Thread Dominique Devienne
On Tue, Jan 11, 2022 at 12:47 PM Wolfgang Walther wrote: > Dominique Devienne: > > I wish for DB-specific ROLEs BTW... > > Same here. That would be so useful. > In fact, in my case, I also want something even narrower than that, which are SCHEMA specific ROLEs. ROLEs tied

Template for schema? (as opposed to databases)

2022-01-11 Thread Dominique Devienne
Hi, As many have surmised from my previous messages, I need to create a set of schemas, where two schemas as smallish and distincts, with an arbitrary number of additional schemas (of a 3rd kind), which is "largish" (244 tables, 4'000+ columns, 1'300+ relations). That's why I say / write that I h

Re: Template for schema? (as opposed to databases)

2022-01-11 Thread Dominique Devienne
On Tue, Jan 11, 2022 at 5:30 PM David G. Johnston < david.g.johns...@gmail.com> wrote: > On Tuesday, January 11, 2022, Dominique Devienne > wrote: >> >> This means the template-schema name is part of the DDL for the schema, >> and a clone would need to use its own

Re: Template for schema? (as opposed to databases)

2022-01-11 Thread Dominique Devienne
On Tue, Jan 11, 2022 at 5:38 PM Francisco Olarte wrote: > > Right now, that implies quite a few round-trips to the server, about > 1'100, but on the LAN with sub-ms latency; > > How much sub-ms? I mean, I have 0.74 pings to my router, but this > would be .82s, a good chunk of your quoted 2-3s, (a

Re: Template for schema? (as opposed to databases)

2022-01-11 Thread Dominique Devienne
On Tue, Jan 11, 2022 at 5:38 PM Francisco Olarte wrote: > On Tue, 11 Jan 2022 at 17:10, Dominique Devienne > wrote: > ... > > Creating the first two "fixed" schemas is fast enough. 300ms, including > populating the 2nd with a bunch of rows. > > But creating the

Re: [Extern] Re: postgres event trigger workaround

2022-01-14 Thread Dominique Devienne
On Fri, Jan 14, 2022 at 10:01 AM Zwettler Markus (OIZ) < markus.zwett...@zuerich.ch> wrote: > We have the need to separate user (role) management from infrastructure > (database) management. > Granting CREATEROLE to any role also allows this role to create other > roles having CREATEDB privileges

Does PostgreSQL do bind-peeking? Is `col like '%'` optimized-away by the planner?

2022-01-21 Thread Dominique Devienne
Hi, I just saw some code of ours that takes 4 strings are arguments, and wants to do optional filtering on those, in a SELECT statement. Something like: ``` void foo(string arg1, string arg2, ...) { ... = exec( conn, "SELECT * from tab where col1 like $1 and col2 like $2 and ...",

Re: Does PostgreSQL do bind-peeking? Is `col like '%'` optimized-away by the planner?

2022-01-21 Thread Dominique Devienne
On Fri, Jan 21, 2022 at 5:47 PM Tom Lane wrote: >> Dominique Devienne writes: > > Will the query planner be able to *peek* into the args, and turn `colN like > > $N` into a no-op? Thanks for the replies, David and Tom. > No. It would not do that even if the pattern we

Re: Cannot find hstore operator

2022-01-24 Thread Dominique Devienne
Hi. In https://www.mail-archive.com/pgsql-general@lists.postgresql.org/msg29321.html I asked: > On Tue, Jan 11, 2022 at 5:30 PM David G. Johnston > wrote: > > On Tuesday, January 11, 2022, Dominique Devienne > > > wrote: > >> This means the template-schema n

Re: Cannot find hstore operator

2022-01-24 Thread Dominique Devienne
On Mon, Jan 24, 2022 at 11:19 AM Ganesh Korde wrote: > On Mon, 24 Jan 2022, 3:22 pm Dominique Devienne, wrote: >> Is there any way to achieve that, beside our current `SET search_path` >> workaround? > This might help. > Alter user SET search_path TO myschema,pub

Re: Cannot find hstore operator

2022-01-24 Thread Dominique Devienne
On Mon, Jan 24, 2022 at 3:48 PM David G. Johnston wrote: > On Monday, January 24, 2022, Dominique Devienne wrote: >> >> After re-reading >> https://www.postgresql.org/docs/14/sql-createfunction.html in light of >> Tom's answer, >> does that mean that

Re: SELECT with LIKE clause makes full table scan

2022-01-26 Thread Dominique Devienne
On Wed, Jan 26, 2022 at 11:55 AM Matthias Apitz wrote: > A SELECT with a LIKE clause on a table with ca. 5.200.000 rows on a > column with an Index ignores this and does a full table scan: > > sisis=# explain (analyze, buffers) select * from d01buch where d01ort like 'Z > 9610%' ; > -> Parallel S

Re: SELECT with LIKE clause makes full table scan

2022-01-26 Thread Dominique Devienne
On Wed, Jan 26, 2022 at 1:13 PM Julien Rouhaud wrote: > > > > Why is this (ignoring the Index) and what could be done? > > [...] > > create INDEX d01ort on d01buch(d01ort) ;/* D01ORT*/ > > That index can't be used with a LIKE that has a trailing wildcard. Really? That seems to contradict th

Re: "grant usage on schema" confers the ability to execute all user-defined functions in that schema, with needing to grant "execute"

2022-02-14 Thread Dominique Devienne
On Sat, Feb 12, 2022 at 8:43 PM Bryn Llewellyn wrote: > I.e. three facts per row: grantee, privilege, and grantee. Then I did this: > with c as ( > select > proname::text as name, > pronamespace::regnamespace::text as schema, > aclexplode(proacl)a

Re: UUID type question

2022-02-18 Thread Dominique Devienne
On Fri, Feb 18, 2022 at 3:06 PM Laura Smith wrote: > Is there anything inherently "special" about the UUID type ? i.e. if I store > a UUID in a text is it "worse" ? uuid is stored as 16 binary bytes. Store it as text, and that's 36 chars (assuming UTF-8, double-that in UTF-16, if that's possible

Re: UUID type question

2022-02-18 Thread Dominique Devienne
On Fri, Feb 18, 2022 at 3:24 PM Dominique Devienne wrote: > On Fri, Feb 18, 2022 at 3:06 PM Laura Smith > wrote: > > Is there anything inherently "special" about the UUID type ? i.e. if I > > store a UUID in a text is it "worse" ? > > uuid is stored

Advice on efficiently logging outputs to PostgreSQL

2024-10-15 Thread Dominique Devienne
I have an existing heavy ETL that serially loads tons of data to PostgreSQL. This is done using a CLI tool, processing one project after another. I'd like to parallelize / distribute the work, which I could do from my CLI tool, but 1) that would be confined to a single machine, and 2) we'd like to

Tablespace ACLs

2024-10-10 Thread Dominique Devienne
Hi. Why isn't the ::regrole::text cast working as usual? Aren't the OIDs for grantor and grantee returned by acldefault() valid ROLEs? C:\Users\ddevienne>psql service=... psql (17.0) SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, compression: off, ALPN: postgresql) Type "help"

Re: Tablespace ACLs

2024-10-10 Thread Dominique Devienne
On Thu, Oct 10, 2024 at 3:40 PM Erik Wienhold wrote: > On 2024-10-10 14:35 +0200, Dominique Devienne wrote: > > Hi. Why isn't the ::regrole::text cast working as usual? > > Aren't the OIDs for grantor and grantee returned by acldefault() valid > > ROLEs? >

Re: What are best practices wrt passwords?

2024-10-16 Thread Dominique Devienne
On Wed, Oct 16, 2024 at 2:25 PM wrote: > I'd like to be able to use psql without typing passwords again and > again. I know about `.pgpass` and PGPASSFILE, but I specifically do not > want to use it - I have the password in the `.env` file, and having it > in _two_ places comes with its own set o

Re: Tablespace ACLs

2024-10-10 Thread Dominique Devienne
On Thu, Oct 10, 2024 at 4:19 PM Erik Wienhold wrote: > > > On 2024-10-10 14:35 +0200, Dominique Devienne wrote: > > > > On a related but different matter, is it normal not having access to a > > > > single tablespace makes the whole output disappear? >

Re: Regression in Postgres 17?

2024-10-22 Thread Dominique Devienne
On Tue, Oct 22, 2024 at 6:03 PM Achilleas Mantzios wrote: > Στις 22/10/24 18:54, ο/η Colin 't Hart έγραψε: > This works in Postgres 15: > Do this instead : > create function json_test(out value text, out jsonparam jsonb) ... > apparently json is a reserved word (now) and won't be accepted as funct

Switching to NOINHERIT user triggers #XX000 error

2024-11-05 Thread Dominique Devienne
Hi. Still working on porting our stuff to v16+, with the ROLE changes. I'm facing a new issue. The same code and unit test works in v14, when the LOGIN user running the test is INHERIT or NOINHERIT. On v16 and v17 though, it works with INHERIT, but with NOINHERIT, I get: GRANT "...:USER" TO "dde

Re: Switching to NOINHERIT user triggers #XX000 error

2024-11-05 Thread Dominique Devienne
On Tue, Nov 5, 2024 at 6:42 PM Tom Lane wrote: > Dominique Devienne writes: > > On v16 and v17 though, it works with INHERIT, but with NOINHERIT, I get: > > GRANT "...:USER" TO "ddevienne" #XX000: ERROR: no possible grantors > > Any clue to what this m

Re: Switching to NOINHERIT user triggers #XX000 error

2024-11-05 Thread Dominique Devienne
On Tue, Nov 5, 2024 at 7:25 PM Tom Lane wrote: > Dominique Devienne writes: > > On Tue, Nov 5, 2024 at 6:42 PM Tom Lane wrote: > >> This is probably a bug, at least to the extent that we don't like > >> XX000 errors to be easily reachable, so please le

Re: COPY documentation with regard to references constraints

2024-10-31 Thread Dominique Devienne
On Thu, Oct 31, 2024 at 1:04 PM Bruno Wolff III wrote: > I was unable to find any documentation clarifying if using COPY to load a > table with rows referencing others rows in the same table, whether I > had to worry about ordering of the input. > What I found (in 17) is that even if the reference

Re: Fwd: A million users

2024-11-13 Thread Dominique Devienne
On Wed, Nov 13, 2024 at 11:29 AM Alvaro Herrera wrote: > On 2024-Nov-13, Vijaykumar Jain wrote: > > I tried to grant select permissions to 5000 different roles on one table, > > It failed with row size too big already at 2443. > > But you can grant select to one "reader" role, and grant that one r

Re: Why no pg_has_role(..., 'ADMIN')?

2024-09-23 Thread Dominique Devienne
On Fri, Sep 20, 2024 at 6:51 PM Robert Haas wrote: > On Fri, Sep 20, 2024 at 12:37 PM Laurenz Albe > wrote: > > That would be a useful addition, yes. > > I think this already exists. The full list of modes supported by > pg_has_role() is listed in convert_role_priv_string(). You can do > somethi

Re: Why no pg_has_role(..., 'ADMIN')?

2024-09-23 Thread Dominique Devienne
On Fri, Sep 20, 2024 at 8:49 PM Robert Haas wrote: > On Fri, Sep 20, 2024 at 2:34 PM Tom Lane wrote: > > I'm now inclined to add wording within the pg_has_role entry > I don't have an opinion about the details, but +1 for documenting it +1 as well. Especially since I now recall, in hindsight, ab

Re: Customize psql prompt to show current_role

2024-09-23 Thread Dominique Devienne
On Mon, Sep 23, 2024 at 2:51 PM Erik Wienhold wrote: > You could instead use this: > > SELECT current_role \gset > \set PROMPT1 '%n@%/ (%:current_role:)=%# ' > > But that won't work with subsequent SET ROLE commands. Bummer... That was kinda the point, that it updates automatically. Then

Re: Customize psql prompt to show current_role

2024-09-23 Thread Dominique Devienne
On Mon, Sep 23, 2024 at 5:16 PM Adrian Klaver wrote: > On 9/23/24 08:07, Dominique Devienne wrote: > > I often resort to \conninfo, but it's less automatic and > > harder to visually parse (IMHO) compared to a custom ad-hoc prompt. > For me that shows the user that conn

Re: Customize psql prompt to show current_role

2024-09-23 Thread Dominique Devienne
On Mon, Sep 23, 2024 at 2:22 PM Asad Ali wrote: > There is no direct prompt escape sequence like %n for displaying the > current_role in the psql prompt. > However, you can work around this by using a \set command to define a custom > prompt that includes the result of current_role. Hi Ali. Doe

Re: Customize psql prompt to show current_role

2024-09-23 Thread Dominique Devienne
On Mon, Sep 23, 2024 at 3:05 PM Laurenz Albe wrote: > On Mon, 2024-09-23 at 14:59 +0200, Dominique Devienne wrote: > > On Mon, Sep 23, 2024 at 2:51 PM Erik Wienhold wrote: > > > You could instead use this: > > > > > > SELECT current_role \gset > >

Customize psql prompt to show current_role

2024-09-23 Thread Dominique Devienne
Hi. I've successfully customized my psql PROMPT1, using %n for session_user, but I'd like to see current_role as well. And I can't seem to find a way. I didn't find a direct \x for it. I didn't find a %'X' variable for it. I didn't find a command to %`X` either. (and X = `select current_role` does

Re: Customize psql prompt to show current_role

2024-09-23 Thread Dominique Devienne
On Mon, Sep 23, 2024 at 4:55 PM Tom Lane wrote: > Laurenz Albe writes: > > To get the current role, psql would have to query the database whenever > > it displays the prompt. That would be rather expensive... > > See previous discussion: > https://www.postgresql.org/message-id/flat/CAFj8pRBFU-Wz

Why no pg_has_role(..., 'ADMIN')?

2024-09-20 Thread Dominique Devienne
To find out whether a ROLE can DROP another in v16+. Prior to v16, just having CREATEROLE was enough, so it didn't really seem necessary. But knowing whether DROP ROLE will work, w/o invalidating the current transaction, seems like something quite useful to know now, no? I can query pg_auth_membe

Re: About the stability of COPY BINARY data

2024-11-07 Thread Dominique Devienne
On Thu, Nov 7, 2024 at 7:04 PM Adrian Klaver wrote: > On 11/7/24 09:55, Dominique Devienne wrote: > > On Thu, Nov 7, 2024 at 6:39 PM Daniel Verite > > wrote: > >> Dominique Devienne wrote: > >>> Also, does the code for per-type _send() and _recv()

Re: About the stability of COPY BINARY data

2024-11-07 Thread Dominique Devienne
On Thu, Nov 7, 2024 at 5:37 PM Adrian Klaver wrote: > > On 11/6/24 08:20, Dominique Devienne wrote: > >>From https://www.postgresql.org/docs/current/sql-copy.html: > > |> binary-format file is less portable across machine architectures > > and PostgreSQL versions

Re: About the stability of COPY BINARY data

2024-11-07 Thread Dominique Devienne
On Thu, Nov 7, 2024 at 6:39 PM Daniel Verite wrote: > Dominique Devienne wrote: > > Also, does the code for per-type _send() and _recv() functions > > really change across versions of PostgreSQL? How common are > > instances of such changes across versions?

About the stability of COPY BINARY data

2024-11-06 Thread Dominique Devienne
>From https://www.postgresql.org/docs/current/sql-copy.html: |> binary-format file is less portable across machine architectures and PostgreSQL versions In my experience, the binary encoding of binding/resultset/copy is endian neutral (network byte order), so what is the less portable across machi

Re: Customize psql prompt to show current_role

2024-11-27 Thread Dominique Devienne
On Wed, Nov 27, 2024 at 3:14 PM Raphael Salguero Aragón wrote: > Am 23.09.2024 um 17:37 schrieb Dominique Devienne : > > I'd be glad to use Pavel's proposed %N. —DD > I just wanted to add that we are also supporting a larger customer with > exactly the same request. >

Re: Will PQsetSingleRowMode get me results faster?

2025-01-06 Thread Dominique Devienne
On Mon, Jan 6, 2025 at 12:21 PM Stijn Sanders wrote: > I've been using LibPQ to get data from PostgreSQL instances with great > success. > I'm using PQsendQuery and PQgetResult, but noticed there's also > PQsetSingleRowMode. > The documentation is clearly stating it only benefits a limited set o

Re: Pipeline Mode vs Single Row Mode / Chunked Rows Mode

2025-01-02 Thread Dominique Devienne
On Thu, Dec 19, 2024 at 3:37 PM Daniel Frey wrote: > I'm adding support for Pipeline Mode to my C++ PostgreSQL client library [...] > Anyway, is there some documentation about how these modes interact and how > they can be combined? Or should they never be combined? Hi. Happy New Year. I was int

Re: Postgres do not support tinyint?

2025-01-10 Thread Dominique Devienne
On Fri, Jan 10, 2025 at 10:13 AM Vladlen Popolitov wrote: > If you really need 1-byte integer, you can use "char" type. Cast it > to/from int. See comment at the end of the page > https://www.postgresql.org/docs/17/datatype-character.html Hi. What would be the best online doc to learn about the p

Re: Design of a reliable task processing queue

2025-01-21 Thread Dominique Devienne
On Sun, Jan 19, 2025 at 9:23 AM Alex Burkhart wrote: > I'm looking for help to organize locks and transaction for a reliable task > queue. Have a look at https://github.com/tembo-io/pgmq for inspiration maybe. --DD

Re: Best Approach for Swapping a Table with its Copy

2025-02-13 Thread Dominique Devienne
On Thu, Feb 13, 2025 at 4:09 PM Greg Sabino Mullane wrote: > On Wed, Feb 12, 2025 at 9:02 PM Marcelo Fernandes > wrote: > >> What I am after is the same, but I seek a deeper understanding of what it >> does, and why it does it. For example, it swaps relfilenode. Why? > > > It is surgically repla

Re: Interesting case of IMMUTABLE significantly hurting performance

2025-04-11 Thread Dominique Devienne
On Fri, Apr 11, 2025 at 5:52 AM Tom Lane wrote: > Merlin Moncure writes: > > I guess the real problems here are lack of feedback on a number of fronts: > > *) the server knows the function is not immutable but lets you create it > > anyway, even though it can have negative downstream consequences

Event-Triggers for DB owners instead of just SUPERUSER

2025-04-14 Thread Dominique Devienne
Hi. I'd like to use CREATE EVENT TRIGGER, but they are SUPERUSER only. In the past, CREATE EXTENSION was also SUPERUSER-only, but is now also available to DB owners. Which is great! Can't event-triggers also be available to DB owbers, instead of just SUPERUSER? Having CREATEDB does not imply ha

CREATE SCHEMA AUTHORIZATION and ALTER SCHEMA OWNER TO

2025-04-14 Thread Dominique Devienne
Hi. I'm on v16+. The DB owner ROLE has CREATEROLE, and obviously CREATE on the DB. So it can both CREATE SCHEMA, and CREATE ROLE. Yet it cannot CREATE SCHEMA AUTHORIZATION, and gets an ERROR: must be able to SET ROLE "..." Yet because this is v16+, thus the DB owner has ADMIN OPTION on the ROLEs

Re: Fwd: Identify system databases

2025-04-16 Thread Dominique Devienne
On Wed, Apr 16, 2025 at 4:39 PM Tom Lane wrote: > Laurenz Albe writes: > > On Wed, 2025-04-16 at 10:09 +0200, Dominique Devienne wrote: So in a way, you guys are saying one should never REVOKE CONNECT ON DATABASE FROM PUBLIC? All my DBs are not PUBLIC-accessible. And inside my DBs,

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

2025-04-14 Thread Dominique Devienne
On Mon, Apr 14, 2025 at 12:09 PM Wolfgang Walther wrote: > > From 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

Re: Fwd: Identify system databases

2025-04-16 Thread Dominique Devienne
On Wed, Apr 16, 2025 at 9:32 AM Laurenz Albe wrote: > On Tue, 2025-04-15 at 17:24 -0700, Adrian Klaver wrote: > But then you fortunately cannot drop all databases, because you cannot > drop the database you are connected to. > > Still, a cluster that is missing "postgres" will give beginners troub

Re: Request for official clarification on SQL parameter parsing changes in PostgreSQL 15 and 16

2025-04-17 Thread Dominique Devienne
On Thu, Apr 17, 2025 at 11:13 AM 王 博 wrote: > Hello PostgreSQL Community, > We have encountered unexpected SQL parsing errors during application upgrades > from PostgreSQL 14 to 15 and 16, related to the use of JDBC-style parameter > placeholders (`?`) in our legacy applications. AFAIK, Postgre

Re: Clarification on RLS policy

2025-04-25 Thread Dominique Devienne
On Fri, Apr 25, 2025 at 3:01 PM Vydehi Ganti wrote: > Then it should build up the lPredicate with the filter condition and append > to the query user runs on the Activity table. You're not reading us, and asking us to do the work for you... RLS Predicates don't return strings in PostgreSQL, but

Re: Clarification on RLS policy

2025-04-25 Thread Dominique Devienne
On Fri, Apr 25, 2025 at 2:43 PM Laurenz Albe wrote: > On Fri, 2025-04-25 at 12:38 +0530, Vydehi Ganti wrote: > > We are presently using Postgresql:PostgreSQL 15.12 on x86_64-pc-linux-gnu, > > compiled by gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-23), 64-bit > > 2.The function would return a charact

Re: Clarification on RLS policy

2025-04-25 Thread Dominique Devienne
On Fri, Apr 25, 2025 at 3:21 PM Vydehi Ganti wrote: > So I don't have a possibility to append where clause dynamically and can only > check the boolean? Indeed. But given that you can run arbitrary SQL inside the function, even dynamic SQL, that ends up pretty much the same. And you have access

Re: Clarification on RLS policy

2025-04-25 Thread Dominique Devienne
On Fri, Apr 25, 2025 at 3:29 PM Vydehi Ganti wrote: > Can i know if there is any scenario or ref document for the design you > suggested above? Some docs: https://www.postgresql.org/docs/current/ddl-rowsecurity.html https://satoricyber.com/postgres-security/postgres-row-level-security/ Your Ora

Re: Clarification on RLS policy

2025-04-25 Thread Dominique Devienne
On Fri, Apr 25, 2025 at 9:09 AM Vydehi Ganti wrote: > We are presently using Postgresql:PostgreSQL 15.12 on x86_64-pc-linux-gnu, > compiled by gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-23), 64-bit > I have a scenario where > 1.I need to enforce RLS policy on a table for Select by calling a Function

Re: DROP ROLE as SUPERUSER

2025-04-29 Thread Dominique Devienne
On Fri, Feb 21, 2025 at 3:44 PM Tom Lane wrote: > Dominique Devienne writes: > > On Fri, Feb 21, 2025 at 3:33 PM Tom Lane wrote: > >> REASSIGN OWNED then DROP OWNED is the recommended path. > > > Hi. Am I missing something? foobar does not OWN anything in this case. &

Re: psql and regex not like

2025-03-09 Thread Dominique Devienne
On Thu, Mar 6, 2025 at 11:24 AM Ron Johnson wrote: > I already do that. This is part of a long chain of commands so I'm trying to > minimize the length of commands. but given that your regexp patterns are not anchored, they are not equivalent. I think mine is "more correct". > Anyway, it would

<    1   2   3   4   >