Re-2: Problem with SqlState=23505 when inserting rows

2020-01-16 Thread Werner Kuhnle
Thanks Michael und Adrian for your answers. I think that " My guess is that the SERIAL was defined for the column, then the data was added with id values, but the counter for the sequence behind the SERIAL was not updated to a value greater the the last id added. " is a correct description of

Is there a GoTo ?

2020-01-16 Thread İlyas Derse
In this function I have to GOTO to a label1, but GOTO keyword is not working, can you please help me in getting the way from which I am able to jump from a particular code to label. Thanks... CREATE OR REPLACE FUNCTION test(i integer) RETURNS integer AS $$BEGINIF i<0 THEN RETURN i + 1;ELSE GOTO

Re: Is there a GoTo ?

2020-01-16 Thread Pavel Stehule
Hi čt 16. 1. 2020 v 11:53 odesílatel İlyas Derse napsal: > In this function I have to GOTO to a label1, but GOTO keyword is not > working, can you please help me in getting the way from which I am able to > jump from a particular code to label. > Thanks... > no, plpgsql has not GOTO statement.

minimal wal_level on subscriber

2020-01-16 Thread Arnaud L.
Hi list, is it OK to set wal_level to minimal on the subscriber side of the logical replication ? Thanks ! Regards -- Arnaud

Can I do this?

2020-01-16 Thread stan
I am trying to create a function to automatically create a reference value when a record is inserted into a table. I want the reference value to consist of the user that is doing the insert, plus a couple of dates, plus a sequence number, where the sequence number will increment every time a given

Can I drop a NOT NUL constrain on an existing table?

2020-01-16 Thread stan
I see how to do this if it is a "dcleared" constraint, but this was just defined in the table createion as inL report_no varchar UNIQUE , -- "They that would give up essential liberty for temporary safety deserve neither liberty nor safety."

Re: Can I do this?

2020-01-16 Thread Justin
Hi Stan in you code sample there are "(" mis-matched, "MAX(" matches to "= project_key)"; it should be MAX(NULLIF(regexp_replace(report_no, '\D','','g'), '')::numeric) I do exactly what you do, and you are correct sequences are not a good fit I typically do something like this for selec

Re: Can I drop a NOT NUL constrain on an existing table?

2020-01-16 Thread Justin
Alter table mytable drop constraint name_of_constraint https://www.postgresql.org/docs/current/sql-altertable.html On Thu, Jan 16, 2020 at 9:43 AM stan wrote: > I see how to do this if it is a "dcleared" constraint, but this was just > defined in the table createion as inL > > report_no

Re: Can I do this?

2020-01-16 Thread Michael Nolan
On Thu, Jan 16, 2020 at 6:28 AM stan wrote: > I am trying to create a function to automatically create a reference value > when a record is inserted into a table. I want the reference value to > consist of the user that is doing the insert, plus a couple of dates, plus > a sequence number, where

Re: Is there a GoTo ?

2020-01-16 Thread Adrian Klaver
On 1/16/20 2:48 AM, İlyas Derse wrote: In this function I have to GOTO to a label1, but GOTO keyword is not working, can you please help me in getting the way from which I am able to jump from a particular code to label.  Thanks... |CREATEORREPLACE FUNCTIONtest(i integer)RETURNS integer AS$$

Re: Can I do this?

2020-01-16 Thread Justin
it does not, but the odds the same user will run this command by this id in two different sessions at the same time are very low. this type of code exist for PO,SO, Invoices, to assign the next line item # in many apps. On Thu, Jan 16, 2020 at 10:40 AM Michael Nolan wrote: > > > On Thu, Jan

Inexplicable duplicate rows with unique constraint

2020-01-16 Thread Richard van der Hoff
I'm trying to track down the cause of some duplicate rows in a table which I would expect to be impossible due to a unique constraint. I'm hoping that somebody here will be able to suggest something I might have missed. The problem relates to a bug filed against our application (https://githu

Re: Re-2: Problem with SqlState=23505 when inserting rows

2020-01-16 Thread Adrian Klaver
On 1/16/20 12:14 AM, Werner Kuhnle wrote: Thanks Michael und Adrian for your answers. I think that " My guess is that the SERIAL was defined for the column, then the data was added with id values, but the counter for the sequence behind the SERIAL was not updated to a value greater the the last i

Re: Is there a GoTo ?

2020-01-16 Thread Justin
Hi İlyas As noted by other there is no GOTO you can move the goto code into the else statement or move that code into a new function call and return that function or just return null in the else if that is all the it is doing CREATE OR REPLACE FUNCTION test(i integer) RETURNS integer AS $$BE

Re: Inexplicable duplicate rows with unique constraint

2020-01-16 Thread Adrian Klaver
On 1/16/20 8:50 AM, Richard van der Hoff wrote: I'm trying to track down the cause of some duplicate rows in a table which I would expect to be impossible due to a unique constraint. I'm hoping that somebody here will be able to suggest something I might have missed. The problem relates to a

Re: Inexplicable duplicate rows with unique constraint

2020-01-16 Thread Tom Lane
Richard van der Hoff writes: > I'm trying to track down the cause of some duplicate rows in a table > which I would expect to be impossible due to a unique constraint. I'm > hoping that somebody here will be able to suggest something I might have > missed. Since these are text columns, one pos

Re: Inexplicable duplicate rows with unique constraint

2020-01-16 Thread Daniel Verite
Richard van der Hoff wrote: > So, question: what could we be doing wrong to get ourselves into this > situation? OS/libc upgrades without reindexing come to mind. See https://wiki.postgresql.org/wiki/Collations > * At least one user reports that he has recently migrated his database >

Re: Inexplicable duplicate rows with unique constraint

2020-01-16 Thread Magnus Hagander
On Thu, Jan 16, 2020 at 6:08 PM Tom Lane wrote: > > Richard van der Hoff writes: > > I'm trying to track down the cause of some duplicate rows in a table > > which I would expect to be impossible due to a unique constraint. I'm > > hoping that somebody here will be able to suggest something I mig

Re: Inexplicable duplicate rows with unique constraint

2020-01-16 Thread Richard van der Hoff
On 16/01/2020 17:12, Magnus Hagander wrote: On Thu, Jan 16, 2020 at 6:08 PM Tom Lane wrote: Richard van der Hoff writes: I'm trying to track down the cause of some duplicate rows in a table which I would expect to be impossible due to a unique constraint. I'm hoping that somebody here will

Re: Inexplicable duplicate rows with unique constraint

2020-01-16 Thread Daniel Verite
Richard van der Hoff wrote: > synapse=> select count(*), room_id, type, state_key from > current_state_events group by 2,3,4 order by count(*) DESC LIMIT 2; > count | room_id | type | state_key > ---+---+---

Re: Inexplicable duplicate rows with unique constraint

2020-01-16 Thread Adrian Klaver
On 1/16/20 9:24 AM, Richard van der Hoff wrote: On 16/01/2020 17:12, Magnus Hagander wrote: On Thu, Jan 16, 2020 at 6:08 PM Tom Lane wrote: Richard van der Hoff writes: I'm trying to track down the cause of some duplicate rows in a table which I would expect to be impossible due to a uniqu

Re: Inexplicable duplicate rows with unique constraint

2020-01-16 Thread Richard van der Hoff
On 16/01/2020 17:24, Daniel Verite wrote: Looking at these columns which are of type text but do not contain words of any particular language, there's probably no point in using a linguistic-aware collation for them. If you maintain the database schema, what you could do to avoid the dependen

Re: Inexplicable duplicate rows with unique constraint

2020-01-16 Thread Richard van der Hoff
On 16/01/2020 17:27, Adrian Klaver wrote: On 1/16/20 9:24 AM, Richard van der Hoff wrote: It seems like a plausible explanation but it's worth noting that all the indexed data here is (despite being in text columns), plain ascii. I'm surprised that a change in collation rules would change the

Re: Inexplicable duplicate rows with unique constraint

2020-01-16 Thread Tom Lane
Richard van der Hoff writes: > On 16/01/2020 17:12, Magnus Hagander wrote: >> See https://wiki.postgresql.org/wiki/Locale_data_changes for hints on >> which linux distros updated when. > It seems like a plausible explanation but it's worth noting that all the > indexed data here is (despite bein

Re: Inexplicable duplicate rows with unique constraint

2020-01-16 Thread Richard van der Hoff
On 16/01/2020 17:48, Tom Lane wrote: Richard van der Hoff writes: On 16/01/2020 17:12, Magnus Hagander wrote: See https://wiki.postgresql.org/wiki/Locale_data_changes for hints on which linux distros updated when. It seems like a plausible explanation but it's worth noting that all the inde

Re: Inexplicable duplicate rows with unique constraint

2020-01-16 Thread Susan Hurst
That's why I created a virtual_string function to squeeze out everything but alpha characters and numbers 0-9 from any varchar or text columns that I want to use as business key columns. For example, if I have a column named job_name, I will have a companion column named v_job_name. The v_ co

Re: Inexplicable duplicate rows with unique constraint

2020-01-16 Thread Laurenz Albe
On Thu, 2020-01-16 at 16:50 +, Richard van der Hoff wrote: > I'm trying to track down the cause of some duplicate rows in a table > which I would expect to be impossible due to a unique constraint. I'm > hoping that somebody here will be able to suggest something I might have > missed. > >

Re: minimal wal_level on subscriber

2020-01-16 Thread Laurenz Albe
On Thu, 2020-01-16 at 12:09 +0100, Arnaud L. wrote: > is it OK to set wal_level to minimal on the subscriber side of the > logical replication ? Yes, if you don't want physical backups. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com

Re: pg_stat_statements extension

2020-01-16 Thread Andreas Kretschmer
On 13 January 2020 20:15:21 CET, Rushikesh socha wrote: >HI, Is there any good link that shows how to install pg_stat_statements >extension >I am getting below error > >postgres=# CREATE EXTENSION pg_stat_statements; >ERROR: could not open extension control file >"/usr/pgsql-11/share/extension/pg

Re: minimal wal_level on subscriber

2020-01-16 Thread Arnaud L.
Le 16/01/2020 à 19:58, Laurenz Albe a écrit : On Thu, 2020-01-16 at 12:09 +0100, Arnaud L. wrote: is it OK to set wal_level to minimal on the subscriber side of the logical replication ? Yes, if you don't want physical backups. You mean online physical backups ? I could still shutdown the su