pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
psql terminates on first error
8+ messages / 4 participants
[nested] [flat]

* psql terminates on first error
@ 2023-03-02 11:53 Holger Jakobs <holger@jakobs.com>
  2023-03-02 12:32 ` Re: psql terminates on first error Erik Wienhold <ewie@ewie.name>
  2023-03-02 14:33 ` Re: psql terminates on first error Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 2 replies; 8+ messages in thread

From: Holger Jakobs @ 2023-03-02 11:53 UTC (permalink / raw)
  To: pgsql-admin@lists.postgresql.org <pgsql-admin@lists.postgresql.org>

Hi everyone,

While trying to transfer data from one instance to another using 
pg_dumpall and psql, the psql stopped on first error, causing pg_dumpall 
to terminate as well.

This behaviour was seen on Windows (EDB installer), but is different on 
Linux.

Only when using an option -c "\set ON_ERROR_STOP false" (plus -f - of 
course to continue reading) psql continued after first error.

Not even the option -v ON_ERROR_STOP=0 helped.

Why is the behaviour between Linux and Windows different? This is not 
reflected in the documentation.

Kind Regards,

Holger

-- 
Holger Jakobs, Bergisch Gladbach, Tel. +49-178-9759012



Attachments:

  [application/pgp-signature] OpenPGP_signature (202B, ../../572addf0-5116-cec0-77fb-9a0ba0161240@jakobs.com/2-OpenPGP_signature)
  download

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: psql terminates on first error
  2023-03-02 11:53 psql terminates on first error Holger Jakobs <holger@jakobs.com>
@ 2023-03-02 12:32 ` Erik Wienhold <ewie@ewie.name>
  2023-03-02 12:44   ` Re: psql terminates on first error Holger Jakobs <holger@jakobs.com>
  1 sibling, 1 reply; 8+ messages in thread

From: Erik Wienhold @ 2023-03-02 12:32 UTC (permalink / raw)
  To: Holger Jakobs <holger@jakobs.com>; pgsql-admin@lists.postgresql.org <pgsql-admin@lists.postgresql.org>

> On 02/03/2023 12:53 CET Holger Jakobs <holger@jakobs.com> wrote:
>
> While trying to transfer data from one instance to another using
> pg_dumpall and psql, the psql stopped on first error, causing pg_dumpall
> to terminate as well.
>
> This behaviour was seen on Windows (EDB installer), but is different on
> Linux.

Database on Windows and client on Linux?  What's the error and is it the same
on Linux?  Is there even an error on Linux?

> Only when using an option -c "\set ON_ERROR_STOP false" (plus -f - of
> course to continue reading) psql continued after first error.

Do you use PowerShell and pipe pg_dumpall into psql?  The first thing that
comes to my mind when reading Postgres+Windows is that PowerShell up to
version 5.1 converts stdout to UTF-16LE.  This already tripped me up in
past with pg_dump and psql.

--
Erik





^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: psql terminates on first error
  2023-03-02 11:53 psql terminates on first error Holger Jakobs <holger@jakobs.com>
  2023-03-02 12:32 ` Re: psql terminates on first error Erik Wienhold <ewie@ewie.name>
@ 2023-03-02 12:44   ` Holger Jakobs <holger@jakobs.com>
  2023-03-02 12:48     ` Re: psql terminates on first error Thomas Kellerer <shammat@gmx.net>
  0 siblings, 1 reply; 8+ messages in thread

From: Holger Jakobs @ 2023-03-02 12:44 UTC (permalink / raw)
  To: Erik Wienhold <ewie@ewie.name>; pgsql-admin@lists.postgresql.org <pgsql-admin@lists.postgresql.org>

Am 02.03.23 um 13:32 schrieb Erik Wienhold:
>> On 02/03/2023 12:53 CET Holger Jakobs <holger@jakobs.com> wrote:
>>
>> While trying to transfer data from one instance to another using
>> pg_dumpall and psql, the psql stopped on first error, causing pg_dumpall
>> to terminate as well.
>>
>> This behaviour was seen on Windows (EDB installer), but is different on
>> Linux.
> Database on Windows and client on Linux?  What's the error and is it the same
> on Linux?  Is there even an error on Linux?

Both on Windows or both on Linux

>> Only when using an option -c "\set ON_ERROR_STOP false" (plus -f - of
>> course to continue reading) psql continued after first error.
> Do you use PowerShell and pipe pg_dumpall into psql?  The first thing that
> comes to my mind when reading Postgres+Windows is that PowerShell up to
> version 5.1 converts stdout to UTF-16LE.  This already tripped me up in
> past with pg_dump and psql.
No, it was in cmd.exe or in bash
> --
> Erik

-- 
Holger Jakobs, Bergisch Gladbach, Tel. +49-178-9759012



Attachments:

  [application/pgp-signature] OpenPGP_signature (202B, ../../c2f5c47e-f603-a54a-7ad1-2d780857523e@jakobs.com/2-OpenPGP_signature)
  download

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: psql terminates on first error
  2023-03-02 11:53 psql terminates on first error Holger Jakobs <holger@jakobs.com>
  2023-03-02 12:32 ` Re: psql terminates on first error Erik Wienhold <ewie@ewie.name>
  2023-03-02 12:44   ` Re: psql terminates on first error Holger Jakobs <holger@jakobs.com>
@ 2023-03-02 12:48     ` Thomas Kellerer <shammat@gmx.net>
  2023-03-02 13:30       ` Re: psql terminates on first error Holger Jakobs <holger@jakobs.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Thomas Kellerer @ 2023-03-02 12:48 UTC (permalink / raw)
  To: pgsql-admin@lists.postgresql.org

Holger Jakobs schrieb am 02.03.2023 um 13:44:
>>> Only when using an option -c "\set ON_ERROR_STOP false" (plus -f - of
>>> course to continue reading) psql continued after first error.
>> Do you use PowerShell and pipe pg_dumpall into psql?  The first thing that
>> comes to my mind when reading Postgres+Windows is that PowerShell up to
>> version 5.1 converts stdout to UTF-16LE.  This already tripped me up in
>> past with pg_dump and psql.
> No, it was in cmd.exe or in bash

I find using pipes with the Postgres command line tools on Windows unreliable
in general (including cmd.exe). So if you did use redirection/pips, try without.







^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: psql terminates on first error
  2023-03-02 11:53 psql terminates on first error Holger Jakobs <holger@jakobs.com>
  2023-03-02 12:32 ` Re: psql terminates on first error Erik Wienhold <ewie@ewie.name>
  2023-03-02 12:44   ` Re: psql terminates on first error Holger Jakobs <holger@jakobs.com>
  2023-03-02 12:48     ` Re: psql terminates on first error Thomas Kellerer <shammat@gmx.net>
@ 2023-03-02 13:30       ` Holger Jakobs <holger@jakobs.com>
  2023-03-02 13:45         ` Re: psql terminates on first error Erik Wienhold <ewie@ewie.name>
  0 siblings, 1 reply; 8+ messages in thread

From: Holger Jakobs @ 2023-03-02 13:30 UTC (permalink / raw)
  To: pgsql-admin@lists.postgresql.org

Am 02.03.23 um 13:48 schrieb Thomas Kellerer:
> Holger Jakobs schrieb am 02.03.2023 um 13:44:
>>>> Only when using an option -c "\set ON_ERROR_STOP false" (plus -f - of
>>>> course to continue reading) psql continued after first error.
>>> Do you use PowerShell and pipe pg_dumpall into psql?  The first thing that
>>> comes to my mind when reading Postgres+Windows is that PowerShell up to
>>> version 5.1 converts stdout to UTF-16LE.  This already tripped me up in
>>> past with pg_dump and psql.
>> No, it was in cmd.exe or in bash
> I find using pipes with the Postgres command line tools on Windows unreliable
> in general (including cmd.exe). So if you did use redirection/pips, try without.
>
>
Whether I use pipes or writing stdout of pg_dumpall to a file and 
reading back with psql from the file made no difference.

-- 

Holger Jakobs, Bergisch Gladbach, Tel. +49-178-9759012



Attachments:

  [application/pgp-signature] OpenPGP_signature (202B, ../../ed1d66b8-1250-1e2d-cacf-b81aa9433cc8@jakobs.com/2-OpenPGP_signature)
  download

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: psql terminates on first error
  2023-03-02 11:53 psql terminates on first error Holger Jakobs <holger@jakobs.com>
  2023-03-02 12:32 ` Re: psql terminates on first error Erik Wienhold <ewie@ewie.name>
  2023-03-02 12:44   ` Re: psql terminates on first error Holger Jakobs <holger@jakobs.com>
  2023-03-02 12:48     ` Re: psql terminates on first error Thomas Kellerer <shammat@gmx.net>
  2023-03-02 13:30       ` Re: psql terminates on first error Holger Jakobs <holger@jakobs.com>
@ 2023-03-02 13:45         ` Erik Wienhold <ewie@ewie.name>
  0 siblings, 0 replies; 8+ messages in thread

From: Erik Wienhold @ 2023-03-02 13:45 UTC (permalink / raw)
  To: Holger Jakobs <holger@jakobs.com>; pgsql-admin@lists.postgresql.org

> On 02/03/2023 14:30 CET Holger Jakobs <holger@jakobs.com> wrote:
>
> Am 02.03.23 um 13:48 schrieb Thomas Kellerer:
> > Holger Jakobs schrieb am 02.03.2023 um 13:44:
> >>>> Only when using an option -c "\set ON_ERROR_STOP false" (plus -f - of
> >>>> course to continue reading) psql continued after first error.
> >>> Do you use PowerShell and pipe pg_dumpall into psql?  The first thing
> >>> that comes to my mind when reading Postgres+Windows is that PowerShell
> >>> up to version 5.1 converts stdout to UTF-16LE.  This already tripped me
> >>> up in past with pg_dump and psql.
> >> No, it was in cmd.exe or in bash
> > I find using pipes with the Postgres command line tools on Windows
> > unreliable in general (including cmd.exe). So if you did use
> > redirection/pips, try without.
>
> Whether I use pipes or writing stdout of pg_dumpall to a file and 
> reading back with psql from the file made no difference.

Try pg_dumpall with option -f instead of redirecting stdout:

	pg_dumpall -f dump.sql
	psql -f dump.sql

Redirecting stdout to an intermediate file should have the same effect as
piping to psql.

And what error do you get from psql?

--
Erik





^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: psql terminates on first error
  2023-03-02 11:53 psql terminates on first error Holger Jakobs <holger@jakobs.com>
@ 2023-03-02 14:33 ` Tom Lane <tgl@sss.pgh.pa.us>
  2023-03-02 14:36   ` Re: psql terminates on first error Holger Jakobs <holger@jakobs.com>
  1 sibling, 1 reply; 8+ messages in thread

From: Tom Lane @ 2023-03-02 14:33 UTC (permalink / raw)
  To: Holger Jakobs <holger@jakobs.com>; +Cc: pgsql-admin@lists.postgresql.org <pgsql-admin@lists.postgresql.org>

Holger Jakobs <holger@jakobs.com> writes:
> While trying to transfer data from one instance to another using 
> pg_dumpall and psql, the psql stopped on first error, causing pg_dumpall 
> to terminate as well.
> This behaviour was seen on Windows (EDB installer), but is different on 
> Linux.
> Only when using an option -c "\set ON_ERROR_STOP false" (plus -f - of 
> course to continue reading) psql continued after first error.
> Not even the option -v ON_ERROR_STOP=0 helped.
> Why is the behaviour between Linux and Windows different? This is not 
> reflected in the documentation.

It shouldn't be different.  However, this report would be trivially
explained if your Windows machine has an %APPDATA%\postgresql\psqlrc.conf
file that turns ON_ERROR_STOP on.  You could try invoking psql with
the -X command line switch to prevent reading that.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: psql terminates on first error
  2023-03-02 11:53 psql terminates on first error Holger Jakobs <holger@jakobs.com>
  2023-03-02 14:33 ` Re: psql terminates on first error Tom Lane <tgl@sss.pgh.pa.us>
@ 2023-03-02 14:36   ` Holger Jakobs <holger@jakobs.com>
  0 siblings, 0 replies; 8+ messages in thread

From: Holger Jakobs @ 2023-03-02 14:36 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-admin@lists.postgresql.org <pgsql-admin@lists.postgresql.org>

Am 02.03.23 um 15:33 schrieb Tom Lane:
> Holger Jakobs <holger@jakobs.com> writes:
>> While trying to transfer data from one instance to another using
>> pg_dumpall and psql, the psql stopped on first error, causing pg_dumpall
>> to terminate as well.
>> This behaviour was seen on Windows (EDB installer), but is different on
>> Linux.
>> Only when using an option -c "\set ON_ERROR_STOP false" (plus -f - of
>> course to continue reading) psql continued after first error.
>> Not even the option -v ON_ERROR_STOP=0 helped.
>> Why is the behaviour between Linux and Windows different? This is not
>> reflected in the documentation.
> It shouldn't be different.  However, this report would be trivially
> explained if your Windows machine has an %APPDATA%\postgresql\psqlrc.conf
> file that turns ON_ERROR_STOP on.  You could try invoking psql with
> the -X command line switch to prevent reading that.
>
> 			regards, tom lane

BINGO!

Thanks a lot.

Sometimes you forget what you have done earlier. ;-)



-- 

Holger Jakobs, Bergisch Gladbach, Tel. +49-178-9759012



Attachments:

  [application/pgp-signature] OpenPGP_signature (202B, ../../1ec0565e-d303-fbe4-9bd2-bd9f3dcf2272@jakobs.com/2-OpenPGP_signature)
  download

^ permalink  raw  reply  [nested|flat] 8+ messages in thread


end of thread, other threads:[~2023-03-02 14:36 UTC | newest]

Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-03-02 11:53 psql terminates on first error Holger Jakobs <holger@jakobs.com>
2023-03-02 12:32 ` Erik Wienhold <ewie@ewie.name>
2023-03-02 12:44   ` Holger Jakobs <holger@jakobs.com>
2023-03-02 12:48     ` Thomas Kellerer <shammat@gmx.net>
2023-03-02 13:30       ` Holger Jakobs <holger@jakobs.com>
2023-03-02 13:45         ` Erik Wienhold <ewie@ewie.name>
2023-03-02 14:33 ` Tom Lane <tgl@sss.pgh.pa.us>
2023-03-02 14:36   ` Holger Jakobs <holger@jakobs.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox