Am I in the same transaction block in complex PLPGSQL?

2022-03-11 Thread Durumdara
Hello! A critical question for me because of future planning. In autocommit mode, when I start a simple update or select, it is one transaction, so if something fails, the whole modification is rolled back (there is no "half update", or "only first record updated"). What will happen with complex

Postgres query

2022-03-11 Thread Ian Dauncey
Hi All Can anyone assist in shedding some light here. We getting this query popping up in our postgresql log file at the same time as the connections to the databases starts increasing. Not sure what is initiating this query, but we get around a hundred per second until we restart our applicati

Re: Postgres query

2022-03-11 Thread hubert depesz lubaczewski
On Fri, Mar 11, 2022 at 10:02:39AM +, Ian Dauncey wrote: > Can anyone assist in shedding some light here. > We getting this query popping up in our postgresql log file at the same time > as the connections to the databases starts increasing. > Not sure what is initiating this query, but we get

Re: foreign key on delete cascade order?

2022-03-11 Thread George Woodring
On Thu, Mar 10, 2022 at 12:38 PM Tom Lane wrote: > With the amount of detail you've provided (viz: none) > This is an example of the error we are seeing from our application. Sorry, I cannot find the postgresql log entry for this one. 2020-11-30T13:16:08,835 ERROR [foo/bar/01EF2.W01E/55159] Glo

Re: Am I in the same transaction block in complex PLPGSQL?

2022-03-11 Thread Tom Lane
Durumdara writes: > In autocommit mode, when I start a simple update or select, it is one > transaction, so if something fails, the whole modification is rolled back > (there is no "half update", or "only first record updated"). > What will happen with complex statements, like PLPGSQL stored proce

Re: Am I in the same transaction block in complex PLPGSQL?

2022-03-11 Thread Durumdara
Dear Tom! Ok, very-very thanks for the answer! I have the same experience with txid: DO $$DECLARE tx bigint; BEGIN select txid_current() into tx; raise notice ''TXID: %'', tx; insert into a values (26); select txid_current() into tx; raise notice ''TXID: %'', tx; insert into a values

COPY TO STDOUT WITH (FORMAT CSV, HEADER), and embedded newlines

2022-03-11 Thread Dominique Devienne
Hi. It's my first time using COPY TO. And first time using built-in CSV support. Performs well. BUT... The code below (real code, but using a custom libpq wrapper lib) is run on a few tables, with unit tests that verify the number of lines of the output file. And for a few of those tables, there'

Re: COPY TO STDOUT WITH (FORMAT CSV, HEADER), and embedded newlines

2022-03-11 Thread David G. Johnston
On Friday, March 11, 2022, Dominique Devienne wrote: > I've tracked these to text values in the DB with embedded > newlines. These values are 'normal'. I'm not use to CSV, but I suppose > such newlines > must be encoded, perhaps as \n, since AFAIK CSV needs to be 1 line per > row, no? Haven’t t

Re: COPY TO STDOUT WITH (FORMAT CSV, HEADER), and embedded newlines

2022-03-11 Thread Daniel Verite
Dominique Devienne wrote: > These values are 'normal'. I'm not use to CSV, but I suppose > such newlines > must be encoded, perhaps as \n, since AFAIK CSV needs to be 1 line per row, > no? No, but such fields must be enclosed by double quotes, as documented in RFC 4180 https://datatracker

Re: COPY TO STDOUT WITH (FORMAT CSV, HEADER), and embedded newlines

2022-03-11 Thread Dominique Devienne
On Fri, Mar 11, 2022 at 7:38 PM Daniel Verite wrote: >> Dominique Devienne wrote: > > These values are 'normal'. I'm not used to CSV, but I suppose such newlines > > must be encoded, perhaps as \n, since AFAIK CSV needs to be 1 line per row, > > no? > > No, but such fields must be enclose

Re: COPY TO STDOUT WITH (FORMAT CSV, HEADER), and embedded newlines

2022-03-11 Thread Daniel Verite
Dominique Devienne wrote: > so I can easily do that "\n" encoding myself, as a post-processing on > the buffer I get back. Alternatively, it might be easier to use the default TEXT format of COPY rather than CSV, as the TEXT format already produces \n for line feeds, along with half a d

Re: COPY TO STDOUT WITH (FORMAT CSV, HEADER), and embedded newlines

2022-03-11 Thread Dominique Devienne
On Fri, Mar 11, 2022 at 8:32 PM Daniel Verite wrote: > Dominique Devienne wrote: > > so I can easily do that "\n" encoding myself, as a post-processing on > > the buffer I get back. > > Alternatively, it might be easier to use the default TEXT format of > COPY rather than CSV, as the TEXT

Re: foreign key on delete cascade order?

2022-03-11 Thread Michael Lewis
> > We are updating the entire status table every 5 minutes with > BEGIN; > UPDATE status SET () WHERE pollid = $1; > COMMIT; > > The issue is arriving when some does a DELETE during the UPDATE of status > DELETE FROM mach WHERE machid=$1; > Could you set lock_timeout, lock table explicitly for SH

Re: Am I in the same transaction block in complex PLPGSQL?

2022-03-11 Thread David G. Johnston
On Fri, Mar 11, 2022 at 9:24 AM Durumdara wrote: > Do you have any idea? Or we must upgrade to min. PGSQL 11 for access > transaction handling and could post the logs through another transaction? > You really do need to open a second session somehow if you want the first session to be able to fa