Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Y5FXy-0000E5-5N for pgsql-general@arkaria.postgresql.org; Sun, 28 Dec 2014 15:14:22 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Y5FXw-00054o-Vl for pgsql-general@arkaria.postgresql.org; Sun, 28 Dec 2014 15:14:21 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Y5FXv-00054i-K7 for pgsql-general@postgresql.org; Sun, 28 Dec 2014 15:14:19 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by makus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Y5FXs-0007kK-08 for pgsql-general@postgresql.org; Sun, 28 Dec 2014 15:14:17 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id E8E21203DC for ; Sun, 28 Dec 2014 10:14:13 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute6.internal (MEProxy); Sun, 28 Dec 2014 10:14:13 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=aklaver.com; h= x-sasl-enc:message-id:date:from:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; s=mesmtp; bh=/Li44FEMoEOFu8IHjPY3HMzewCs=; b=IQJzO5wcjL0gzj+Ans MgOm2b9ZMhZPur5/QCK2rKKIbGYTw5A3VUo8P+TfeY4idXoeXw7+j6aXQsN48qAJ yFXiOr1ltnlkAL5hXhYzyZHf2ueXPZPtdv8bIkkxC5EPd6d01OSObuNcSZbCIAfK 9xteJUzUjtaCiI0xzspFjY0ag= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=x-sasl-enc:message-id:date:from :mime-version:to:subject:references:in-reply-to:content-type :content-transfer-encoding; s=smtpout; bh=/Li44FEMoEOFu8IHjPY3HM zewCs=; b=uV5oSj0AFkBB41A8H4ly/dXldpL5hvfD8I/1XraC38iAeN3AWLHb2/ BShGALeT77d87Cdn1hOM2Kr6UEuJ3pbD0mh4x2n+K3wr97BLSB+NSPghGhafJ12b B0axFnO80EqoP8eg2GthX3XvL32BOCoc1z0xAeGrNXV3ubBTohJKc= X-Sasl-enc: k0rbSqQAb+fKnM0M3/MuKHXFt0GFCYKalDrOEPjXqLHb 1419779653 Received: from [192.168.1.2] (unknown [174.21.251.95]) by mail.messagingengine.com (Postfix) with ESMTPA id 69357C00287; Sun, 28 Dec 2014 10:14:13 -0500 (EST) Message-ID: <54A01E44.9050105@aklaver.com> Date: Sun, 28 Dec 2014 07:14:12 -0800 From: Adrian Klaver User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Viktor Shitkovskiy , pgsql-general@postgresql.org Subject: Re: Rollback on include error in psql References: In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org On 12/28/2014 12:02 AM, Viktor Shitkovskiy wrote: > Hello. > > I'm trying to execute an sql script file in a single transation. The > file contains includes for some other scripts which in my example create > some tables. It looks like this: > \include ../tables/table1.cre > \include ../tables/table2.cre > ... > \include ../tables/table10.cre > > I'm executing it using psql: > psql -X --set AUTOCOMMIT=off --set ON_ERROR_STOP=on -e > --single-transaction -d my_db -f my_script.sql > > The problem is that errors with the include meta command do not cause a > transactiopn rollback. e.g. if some of tableX.cre files is missing, any > changes before its include will be commited. However, if there's some > SQL syntax error, everyting works as expected. > > Is it possible to somehow handle include related errors and rollback the > active transcation? > Where is the \include coming from? What is in the tableX.cre files? So if I am following you want a complete rollback on non-SQL or SQL errors, correct? > I'm using PostgreSQL 9.2.1. > > P.S. Initially I asked this question at dba.stackexchange.com > : > http://dba.stackexchange.com/questions/87040/rollback-on-include-error-in-psql -- Adrian Klaver adrian.klaver@aklaver.com -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general