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 be good to know the answer for any future queries that need 
> multiple exclusions.

Sure. First, it works fine with TCSH :). I repro a (different) failure
in BASH. But the below works fine for me:

psql "service=acme" -Xc 'select datname from pg_database where datname
!~ $$(template|postgres)$$ order by 1'

i.e. use single-quotes, and an inner $$ literal. One of 3 options an
AI chatbot gave me. --DD




Re: Duplicate Key Values

2025-03-09 Thread mark bradley
I tried adding a dummy column with different values and then deleting one, as 
you suggested.  Got the same message.


Mark Brady, Ph.D.
Deputy Chief Data Officer, TRMC
amazon.com/author/markjbrady

From: mark bradley 
Sent: Thursday, March 6, 2025 1:11 PM
To: Adrian Klaver ; Ron Johnson 
; pgsql-general 
Subject: Re: Duplicate Key Values

Here is the table definition:

[cid:ecac8e92-826b-45c8-95a8-aaf0e55c4f9c]

And here is the error message I get when I try to delete a duplicate:

[cid:a0f5f298-984d-4f89-abd2-475c02e65b9d]

Mark Brady,
amazon.com/author/markjbrady

From: Adrian Klaver 
Sent: Wednesday, March 5, 2025 6:49 PM
To: Ron Johnson ; pgsql-general 

Subject: Re: Duplicate Key Values

On 3/5/25 15:37, Ron Johnson wrote:
> What does "and unique identifier" mean?
>
> (Creating a Primary Key constraint automatically creates a unique
> no-nulls-allowed index on the column(s), so no other index is needed.)
>
> Can you show the table definition?
>
> Anyway, you /should/ be able to delete one of the duplicate node_id
> records by specifying another column with a different value;
>
> On Wed, Mar 5, 2025 at 6:14 PM mark bradley  > wrote:
>
> Hi Ron,
>
> The key is an integer.  I'm using pGAdmin4 and recently updated to
> the latest version.

1) Did you not see duplicates with the old version of pgAdmin4?

2) What do you see if you use psql?

3) Did you upgrade/move the Postgres server or the underlying OS?

4) Have you tried reindexing the node_id field?

>
> The records are not all identical, some have NULL values of the
> non-key for some unknown reason.  Here is a screenshot.  The key is
> node_id, which I have specified as a key and unique identifier.
>
>
>


--
Adrian Klaver
adrian.kla...@aklaver.com





Re: psql and regex not like

2025-03-09 Thread Ron Johnson
On Thu, Mar 6, 2025 at 6:11 AM hubert depesz lubaczewski 
wrote:

> On Thu, Mar 06, 2025 at 04:37:56AM -0500, Ron Johnson wrote:
> > This statement runs great from the psql prompt.  Does exactly what I
> want.
> > select datname from pg_database WHERE datname !~ 'template|postgres'
> ORDER
> > BY datname;
> > But it doesn't work so well from the bash prompt.  Not escaping the "!"
> > generates a bunch of garbage, while escaping throws an sql syntax error.
>
> The problem is that ! is magical in bash.
>
> The solution is to not use it. Instead you can easily do:
>
> psql -Xc "select datname from pg_database WHERE not datname ~
> 'template|postgres' ORDER BY datname;"
>

I've used WHERE NOT ()" before.  Should have thought of it here.

Thanks.

-- 
Death to , and butter sauce.
Don't boil me, I'm still alive.
 lobster!