Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Y5KkN-0005Xb-BX for pgsql-general@arkaria.postgresql.org; Sun, 28 Dec 2014 20:47:31 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Y5KkM-0006H5-Q6 for pgsql-general@arkaria.postgresql.org; Sun, 28 Dec 2014 20:47:30 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Y5KkK-0006EJ-Ek for pgsql-general@postgresql.org; Sun, 28 Dec 2014 20:47:28 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Y5KkG-0001Hm-W4 for pgsql-general@postgresql.org; Sun, 28 Dec 2014 20:47:27 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 0CAB220978 for ; Sun, 28 Dec 2014 15:47:22 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute2.internal (MEProxy); Sun, 28 Dec 2014 15:47:22 -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=Vyk9g9VYPRDYs0Qc6qgBi0hWgjA=; b=KEAJYJ9e3Ak3jyqYM6 ENnE75uvnLcpNW0P+eRL7V/V5+Wp3mng/kWG0WqW9J5THcrSvYLLpwGbnjdE9TRA FQjkQ4UIPmLcaNNG++ac2Kbc3onX6iFUH4RWL+J2BEPnkEgDelYZ5g/f3RwjSu2Z Te8X20Bjb9s9TO2XPYRy7TRhA= 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=Vyk9g9VYPRDYs0Qc6qgBi0 hWgjA=; b=kyWUGELv9djzo9ljr+hQ1CJsX7DCNRNWTiTIKHGhJx+xBcz+gjo8TV gLR3cxzwQs78jE2EcfPQB7uHgwPPRmEGYBMao5eTnIVql1lADKtKESx+IN2ZjTLl gZ6dV43z4hvjW7TROfexsvalEZjCdC9lHWTlz6sldjxYSUgGhwn7o= X-Sasl-enc: xgTup/P1y6vQT/HOOFjQt40QdGvq2ROC8laBhtAIWUKY 1419799641 Received: from [192.168.1.2] (unknown [174.21.251.95]) by mail.messagingengine.com (Postfix) with ESMTPA id 7C25568009D; Sun, 28 Dec 2014 15:47:21 -0500 (EST) Message-ID: <54A06C58.2020009@aklaver.com> Date: Sun, 28 Dec 2014 12:47:20 -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: <54A01E44.9050105@aklaver.com> 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 10:06 AM, Viktor Shitkovskiy wrote: > I include my own scripts. Each of them creates some table or makes some > changes to existing tables. It is hard to say where to go from here without more information. The options you are passing to psql all have caveats: AUTOCOMMIT When on (the default), each SQL command is automatically committed upon successful completion. To postpone commit in this mode, you must enter a BEGIN or START TRANSACTION SQL command. When off or unset, SQL commands are not committed until you explicitly issue COMMIT or END. The autocommit-off mode works by issuing an implicit BEGIN for you, just before any command that is not already in a transaction block and is not itself a BEGIN or other transaction-control command, nor a command that cannot be executed inside a transaction block (such as VACUUM). Note: In autocommit-off mode, you must explicitly abandon any failed transaction by entering ABORT or ROLLBACK. Also keep in mind that if you exit the session without committing, your work will be lost. --single-transaction When psql executes a script, adding this option wraps BEGIN/COMMIT around the script to execute it as a single transaction. This ensures that either all the commands complete successfully, or no changes are applied. If the script itself uses BEGIN, COMMIT, or ROLLBACK, this option will not have the desired effects. Also, if the script contains any command that cannot be executed inside a transaction block, specifying this option will cause that command (and hence the whole transaction) to fail. ON_ERROR_STOP By default, command processing continues after an error. When this variable is set, it will instead stop immediately. In interactive mode, psql will return to the command prompt; otherwise, psql will exit, returning error code 3 to distinguish this case from fatal error conditions, which are reported using error code 1. In either case, any currently running scripts (the top-level script, if any, and any other scripts which it may have in invoked) will be terminated immediately. If the top-level command string contained multiple SQL commands, processing will stop with the current command. Without information on what is going on in the individual scripts or the master script, it would be just a guessing game at this point. > Yes, I want a complete rollback. > > > 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 > > -- 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