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 DC87952884 for ; Fri, 20 May 2005 15:36:44 -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 58389-01 for ; Fri, 20 May 2005 18:36:36 +0000 (GMT) Received: from a2s1.a2webhosting.com (host-180.a2webhosting.com [69.39.89.180]) by svr1.postgresql.org (Postfix) with ESMTP id A09415284C for ; Fri, 20 May 2005 15:36:34 -0300 (ADT) Received: from user-1120qbs.dsl.mindspring.com ([66.32.105.124] helo=[192.168.1.10]) by a2s1.a2webhosting.com with esmtpsa (TLSv1:RC4-SHA:128) (Exim 4.50) id 1DZCMj-0003ZM-Cu; Fri, 20 May 2005 14:36:57 -0400 In-Reply-To: <428E1CE2.2050605@kencast.com> References: <428E1CE2.2050605@kencast.com> Mime-Version: 1.0 (Apple Message framework v619.2) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <5b3405142791217e121ed0e38f790ac9@pgedit.com> Content-Transfer-Encoding: 7bit Cc: "'pgsql-sql@postgresql.org'" From: John DeSoi Subject: Re: How do I quit in the middle of a SQL script? Date: Fri, 20 May 2005 14:36:53 -0400 To: Wei Weng X-Mailer: Apple Mail (2.619.2) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - a2s1.a2webhosting.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] X-AntiAbuse: Sender Address Domain - pgedit.com X-Source: X-Source-Args: X-Source-Dir: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/170 X-Sequence-Number: 21483 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