Re: Wrapping a where clause to preserve rows with nulls

2024-12-18 Thread Adrian Garcia Badaracco
Well, there is a wrinkle: if the predicate returns `false` but one of the columns is null then the whole thing ends up `true` when I'd want it to be `false`. Say col_a = [1] and col_b = [null]: WHERE (col_a < 1 AND col_b > 1) OR col_a IS NULL OR col_b IS NULL -> WHERE (false AND null) OR false OR

Re: How to deal with dangling files after aborted `pg_restore`?

2024-12-18 Thread Ron Johnson
It could be that he only restored *some* tables in an existing database. On Wed, Dec 18, 2024 at 7:02 PM Saul Perdomo wrote: > Genuine question: Why are you looking to recover from this half-cooked > state instead of restarting the restore process from the beginning? > > On Tue, Dec 17, 2024, 1:

Re: Wrapping a where clause to preserve rows with nulls

2024-12-18 Thread Adrian Garcia Badaracco
Thank you for the great idea Tom. While yes I can't modify the original WHERE clause I do think I'll be able to introspect it or get the system generating it to tell me which columns it references and then add an OR x is NULL OR y is NULL ... For context, just in case it's interesting, I store Par

Re: Wrapping a where clause to preserve rows with nulls

2024-12-18 Thread Tom Lane
"David G. Johnston" writes: > On Wednesday, December 18, 2024, Adrian Garcia Badaracco < > adr...@adriangb.com> wrote: >> Is there any way to include the rows where the predicate evaluates to null >> while still using an index? > ... A btree index, which handles =, can’t be told to behave > diffe

Re: Wrapping a where clause to preserve rows with nulls

2024-12-18 Thread David G. Johnston
On Wednesday, December 18, 2024, Adrian Garcia Badaracco < adr...@adriangb.com> wrote: > > Is there any way to include the rows where the predicate evaluates to null > while still using an index? > That seems quite unlikely. Your definition of equality is incompatible with the system’s standard

Re: Wrapping a where clause to preserve rows with nulls

2024-12-18 Thread Adrian Garcia Badaracco
I'll note that the clause is arbitrary in the sense that I don't generate it and cannot edit it but it's basically a bunch of boolean comparisons chained i.e. `col_a >= 1 and col_b <=5 and col_c ...` so I can in general add an index on say col_a and it does get used. On Wed, Dec 18, 2024 at 9:47 P

Wrapping a where clause to preserve rows with nulls

2024-12-18 Thread Adrian Garcia Badaracco
I have a query where I have to run a where clause generated by another system (i.e., I can't modify that where clause. The where clause may return `null`, but I actually want to keep rows that return `null` (and rows that return `true` but not rows that return `false`). I thought it would be as s

Re: How to deal with dangling files after aborted `pg_restore`?

2024-12-18 Thread Saul Perdomo
Genuine question: Why are you looking to recover from this half-cooked state instead of restarting the restore process from the beginning? On Tue, Dec 17, 2024, 1:10 a.m. Ivan Kurnosov wrote: > The scenario: > > 1. There is a postgresql 17 server running > 2. Restore dump with `--single-transact

Re: Query about pg_wal directory filled up

2024-12-18 Thread Saul Perdomo
On Wed, Dec 18, 2024, 5:01 a.m. Rama Krishnan wrote: > > Hi Team, > > One of our clients recently migrated from Oracle to PostgreSQL and is > conducting multiple scenarios to understand PostgreSQL behavior. > > One of their main concerns is whether the database will allow `INSERT` > queries when

Re: Intermittent errors when fetching cursor rows on PostgreSQL 16

2024-12-18 Thread Adrian Klaver
On 12/17/24 08:30, Enrico Schenone wrote: Good day. My name is Enrico Schenone, from Genoa, Italy. I'm a software achitect working at Cleis Tech - Genoa - Italy  - http://gruppocleis.it Me and my team are using PostgreSQL v12 to v16 on Debian 10-12 and Ubuntu Server 22.04 LTS with no-cluster co

Re: Cannot drop column

2024-12-18 Thread Adrian Klaver
On 12/18/24 11:04 AM, Rich Shepard wrote: On Wed, 18 Dec 2024, Viral Shah wrote: Since your column name has an Upper case character, you will have to use double quotes to drop it. Try alter table statustypes drop column "Suspect"; Viral, Huh! I've not before encountered this in the 30+ y

Re: Cannot drop column

2024-12-18 Thread David G. Johnston
On Wednesday, December 18, 2024, Rich Shepard wrote: > On Wed, 18 Dec 2024, Rich Shepard wrote: > > Since your column name has an Upper case character, you will have to use >>> double quotes to drop it. Try alter table statustypes drop column >>> "Suspect"; >>> >> > Thanks for the lesson. >> > >

Re: Cannot drop column

2024-12-18 Thread Rich Shepard
On Wed, 18 Dec 2024, Rich Shepard wrote: Since your column name has an Upper case character, you will have to use double quotes to drop it. Try alter table statustypes drop column "Suspect"; Thanks for the lesson. But, bustrac=# alter table statustypes drop column "Suspect"; ERROR: colum

Re: Cannot drop column

2024-12-18 Thread Rich Shepard
On Wed, 18 Dec 2024, David G. Johnston wrote: Failed to double-quote your column name. David, Thanks. That's a new one on me. Regards, Rich

Re: Cannot drop column

2024-12-18 Thread Rich Shepard
On Wed, 18 Dec 2024, Viral Shah wrote: Since your column name has an Upper case character, you will have to use double quotes to drop it. Try alter table statustypes drop column "Suspect"; Viral, Huh! I've not before encountered this in the 30+ years I've used postgres. Thanks for the lesson

Re: Cannot drop column

2024-12-18 Thread Viral Shah
Since your column name has an Upper case character, you will have to use double quotes to drop it. Try alter table statustypes drop column "Suspect"; Thanks, Viral On Wed, Dec 18, 2024 at 1:47 PM Rich Shepard wrote: > I'm not seeing why postgres won't drop a table's column: > > bustrac=# sele

Re: Cannot drop column

2024-12-18 Thread Ron Johnson
On Wed, Dec 18, 2024 at 1:47 PM Rich Shepard wrote: > I'm not seeing why postgres won't drop a table's column: > > bustrac=# select * from statustypes order by stat_name; > stat_name > > Client > Lead > No further contact > Opportunity > Proposal submitted >

Re: Cannot drop column

2024-12-18 Thread David G. Johnston
On Wed, Dec 18, 2024 at 11:47 AM Rich Shepard wrote: > I'm not seeing why postgres won't drop a table's column: > > bustrac=# select * from statustypes order by stat_name; > stat_name > > Client > Lead > No further contact > Opportunity > Proposal submitted >

Cannot drop column

2024-12-18 Thread Rich Shepard
I'm not seeing why postgres won't drop a table's column: bustrac=# select * from statustypes order by stat_name; stat_name Client Lead No further contact Opportunity Proposal submitted Prospect Qualified Referral Suspect (9 rows) bustrac=# alter table statust

Re: Documentation enancement regarding NULL and operators

2024-12-18 Thread Adrian Klaver
On 12/15/24 09:35, Luca Dametto wrote: Hi All, I'm coming from hours of debugging a SQL trigger that wasn't working properly. After a beautiful headache and infinite hours of documentation reading I've found out that something doesn't work as I would expect. Most programming languages return

Re: Intermittent errors when fetching cursor rows on PostgreSQL 16

2024-12-18 Thread Ron Johnson
On Wed, Dec 18, 2024 at 5:01 AM Enrico Schenone wrote: > Good day. > My name is Enrico Schenone, from Genoa, Italy. > I'm a software achitect working at Cleis Tech - Genoa - Italy - > http://gruppocleis.it > Me and my team are using PostgreSQL v12 to v16 on Debian 10-12 and Ubuntu > Server 22.04

Re: Documentation enancement regarding NULL and operators

2024-12-18 Thread Laurenz Albe
On Sun, 2024-12-15 at 17:35 +, Luca Dametto wrote: > Most programming languages return "true" when two null values are compared, > and false when, being the two values nullable, one of them is null and the > other one isn't. > > [not SQL, however] > > Whilst I'd love to discuss the reasons of

Re: Query about pg_wal directory filled up

2024-12-18 Thread Laurenz Albe
On Tue, 2024-12-17 at 19:11 +0530, Rama Krishnan wrote: > One of their main concerns is whether the database will allow `INSERT` queries > when the `pg_wal` directory becomes full.   > > As I understand, once the `pg_wal` directory is completely filled, the > database > will allow only read queri

Re: How to do an update with XML column ?

2024-12-18 Thread Francisco Olarte
Hi: On Wed, 18 Dec 2024 at 11:00, celati Laurent wrote: > ERROR: could not identify an equality operator for type xml > LINE 39: group by orga_name > ^ Have you tried the obvious group by cast(orga_name as text) ? Never used XML but most types in postgres convert to text inje

PG16 ADMIN OPTION

2024-12-18 Thread Pawan Sharma
Hello Everyone, I recently noticed the difference between PG15 and PG16 regarding *CREATEROLE *and ADMIN OPTION. Granting the Admin Option to another role is not allowed in PG16, whereas it was permitted in PG15. Please help me with how we can allow them without superuser intervention. PostgreSQ

Documentation enancement regarding NULL and operators

2024-12-18 Thread Luca Dametto
Hi All, I'm coming from hours of debugging a SQL trigger that wasn't working properly. After a beautiful headache and infinite hours of documentation reading I've found out that something doesn't work as I would expect. Most programming languages return "true" when two null values are compare

Intermittent errors when fetching cursor rows on PostgreSQL 16

2024-12-18 Thread Enrico Schenone
Good day. My name is Enrico Schenone, from Genoa, Italy. I'm a software achitect working at Cleis Tech - Genoa - Italy  - http://gruppocleis.it Me and my team are using PostgreSQL v12 to v16 on Debian 10-12 and Ubuntu Server 22.04 LTS with no-cluster configuration. Our applications are developed

How to do an update with XML column ?

2024-12-18 Thread celati Laurent
Dear all, I'm taking the liberty to ask an question. Do you know if there are some ways in order to update and/or do group by with an XML column ? For instance, select id, unnest(xpath( '//cit:CI_Organisation/cit:name/gco:CharacterString/text()', CAST(data AS XML), ARRAY[

Query about pg_wal directory filled up

2024-12-18 Thread Rama Krishnan
Hi Team, One of our clients recently migrated from Oracle to PostgreSQL and is conducting multiple scenarios to understand PostgreSQL behavior. One of their main concerns is whether the database will allow `INSERT` queries when the `pg_wal` directory becomes full. As I understand, once the `pg_w