pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedHow do I quit in the middle of a SQL script?
3+ messages / 3 participants
[nested] [flat]
* How do I quit in the middle of a SQL script?
@ 2005-05-20 17:22 Wei Weng <wweng@kencast.com>
2005-05-20 18:36 ` Re: How do I quit in the middle of a SQL script? John DeSoi <desoi@pgedit.com>
0 siblings, 1 reply; 3+ messages in thread
From: Wei Weng @ 2005-05-20 17:22 UTC (permalink / raw)
To: pgsql-sql
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? And is it a good idea to add arbitrary code to the database
dump sql script?
Thanks!
Wei
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: How do I quit in the middle of a SQL script?
2005-05-20 17:22 How do I quit in the middle of a SQL script? Wei Weng <wweng@kencast.com>
@ 2005-05-20 18:36 ` John DeSoi <desoi@pgedit.com>
2005-05-20 20:51 ` Re: How do I quit in the middle of a SQL script? Mischa Sandberg <mischa.sandberg@telus.net>
0 siblings, 1 reply; 3+ messages in thread
From: John DeSoi @ 2005-05-20 18:36 UTC (permalink / raw)
To: Wei Weng <wweng@kencast.com>; +Cc: pgsql-sql
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 :)
John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: How do I quit in the middle of a SQL script?
2005-05-20 17:22 How do I quit in the middle of a SQL script? Wei Weng <wweng@kencast.com>
2005-05-20 18:36 ` Re: How do I quit in the middle of a SQL script? John DeSoi <desoi@pgedit.com>
@ 2005-05-20 20:51 ` Mischa Sandberg <mischa.sandberg@telus.net>
0 siblings, 0 replies; 3+ messages in thread
From: Mischa Sandberg @ 2005-05-20 20:51 UTC (permalink / raw)
To: Wei Weng <wweng@kencast.com>; pgsql-sql
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
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2005-05-20 20:51 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-05-20 17:22 How do I quit in the middle of a SQL script? Wei Weng <wweng@kencast.com>
2005-05-20 18:36 ` John DeSoi <desoi@pgedit.com>
2005-05-20 20:51 ` Mischa Sandberg <mischa.sandberg@telus.net>
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