pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mischa Sandberg <mischa.sandberg@telus.net>
To: Wei Weng <wweng@kencast.com>
To: 'pgsql-sql@postgresql.org' <pgsql-sql@postgresql.org>
Subject: Re: How do I quit in the middle of a SQL script?
Date: Fri, 20 May 2005 13:51:45 -0700
Message-ID: <1116622305.428e4de1790dc@webmail.telus.net> (raw)
In-Reply-To: <5b3405142791217e121ed0e38f790ac9@pgedit.com>
References: <428E1CE2.2050605@kencast.com>
	<5b3405142791217e121ed0e38f790ac9@pgedit.com>

Quoting John DeSoi <desoi@pgedit.com>:

> 
> On May 20, 2005, at 1:22 PM, Wei Weng wrote:
> 
> > Say if I want to add a small snip of code in front of the sql script 
> > generated by the pg_dump, to check for something then if the condition 
> > doesn't match, the script terminates right away. (Without actually 
> > doing the restoring stuff that the following large chunk is supposed 
> > to do)
> >
> > Can I do that?
> 
> Put this at the start of the file to make psql stop if there is an 
> error:
> 
> \set ON_ERROR_STOP 1
> 
> > And is it a good idea to add arbitrary code to the database dump sql 
> > script?
> 
> No problem if you know what you are doing and/or have good backups :)

You don't have to:

    pg_restore mydb.dump | psql --set ON_ERROR_STOP=1






view thread (3+ messages)

Message-ID: <1116622305.428e4de1790dc@webmail.telus.net>
Permalink:  ../1116622305.428e4de1790dc@webmail.telus.net/
Also on:    postgresql.org/message-id/1116622305.428e4de1790dc@webmail.telus.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: mischa.sandberg@telus.net, wweng@kencast.com
  Subject: Re: How do I quit in the middle of a SQL script?
  In-Reply-To: <1116622305.428e4de1790dc@webmail.telus.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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