X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6ED6E52841 for ; Fri, 20 May 2005 17:51:32 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 89498-09 for ; Fri, 20 May 2005 20:51:23 +0000 (GMT) Received: from priv-edtnes51.telusplanet.net (outbound04.telus.net [199.185.220.223]) by svr1.postgresql.org (Postfix) with ESMTP id D557E52882 for ; Fri, 20 May 2005 17:51:21 -0300 (ADT) Received: from localhost ([199.185.220.240]) by priv-edtnes51.telusplanet.net (InterMail vM.6.01.04.04 201-2131-118-104-20050224) with ESMTP id <20050520205146.GITI26803.priv-edtnes51.telusplanet.net@localhost>; Fri, 20 May 2005 14:51:46 -0600 Received: from 209.17.183.249 ( [209.17.183.249]) as user a3a18850@192.168.200.1 by webmail.telus.net with HTTP; Fri, 20 May 2005 13:51:45 -0700 Message-ID: <1116622305.428e4de1790dc@webmail.telus.net> Date: Fri, 20 May 2005 13:51:45 -0700 From: Mischa Sandberg To: Wei Weng , "'pgsql-sql@postgresql.org'" Subject: Re: How do I quit in the middle of a SQL script? References: <428E1CE2.2050605@kencast.com> <5b3405142791217e121ed0e38f790ac9@pgedit.com> In-Reply-To: <5b3405142791217e121ed0e38f790ac9@pgedit.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.1-cvs X-Originating-IP: 209.17.183.249 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.041 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_POST, FORGED_RCVD_HELO X-Spam-Level: * X-Archive-Number: 200505/174 X-Sequence-Number: 21487 Quoting John DeSoi : > > 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