Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1trg2p-007F8f-EE for pgsql-general@arkaria.postgresql.org; Mon, 10 Mar 2025 16:31:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1trg2n-00EzZL-Mi for pgsql-general@arkaria.postgresql.org; Mon, 10 Mar 2025 16:31:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1trg2n-00EzZ7-Ac for pgsql-general@lists.postgresql.org; Mon, 10 Mar 2025 16:31:57 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1trg2j-0024Lb-0g for pgsql-general@lists.postgresql.org; Mon, 10 Mar 2025 16:31:56 +0000 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-43cf06eabdaso17515825e9.2 for ; Mon, 10 Mar 2025 09:31:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1741624313; x=1742229113; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=bs1wdwxlgS461qLaM8/g9Wnd5STYu4a/quNorrCdqgM=; b=RzPB2I1cpKXJVQw+KJzKhj4VrgvRO7kSJGJ/r7xCqGAup0VDlyHiBRmyBrnxbhpylG K+P8TefHy2zYMwP884IhYcdHfM4Fwqm7+fOOIY+x8I5wsxYEBQv9+516UcY+FIHhy0Kx I8UYmGPwVnkkWTL58Z4LXAK6OJqE0ZwcRHyNp5waaiYfZmtd0j0UThruRa84pqQnLeuG gLlp5cNR1xXRkct6WTUpRqls5x2A3sFb1cr8P05ExDr8RKcOFA/mG9TMWWUkv9n30go4 E4jE6pm0dk0DHHNGIWmUN7K7j+KlcVv9vBkXmw75aR1IV2Cc6zJWB34QxKOIujk4O22v 8IpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741624313; x=1742229113; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=bs1wdwxlgS461qLaM8/g9Wnd5STYu4a/quNorrCdqgM=; b=cbialRF7ncQokf5HxatnMAWtaiZyB8WdyjQVZ8PxKZU9gD/eifNqXPxE+zdZ12vazr YEN5oeMqI4W/VnGC9sCTyRvE82/rXUaLrKROA5aeJKavk3TLynEysyogxf1RPqfTJMd/ GuHTgDeZknwuGPTsGQdp664qqckhAeTf0QM9XDa5dmT7XLK0XEd9pEYaWuvD4Vn/boY1 RBSmlXfqw23mgt9HUI06CkspM7lWv2xMXTTku8vfVY7bsgDatGmLK+3/yipgwYmMsryh c3RVi22yBtdl1JgufOXS4woQrrYAUBiTQkJJpGA1jQjQSmXEwGyYirAJ26XxDk3aEpQ5 2DjQ== X-Forwarded-Encrypted: i=1; AJvYcCWr1au9NjmFGs0QBE+tWjpA+FYnufQO48pUNaPVYm5TW1Mc9bb6y20szjsrPMfZcpa+1uESor9pS+S5Hac8@lists.postgresql.org X-Gm-Message-State: AOJu0YwQ7W2139XhYL3Yc1o8FBICjxWI9MnFLKvZ0gNXHEICADqVl6nK dGG5aH/t25IbS3mdy7SSlctsbHZ+gCNRMKO0nPluGfIugeDYs7pB6Z6n6ZDh/E4= X-Gm-Gg: ASbGnctooaUwvAclAxph9wSPhdbQrqZ81UkRXaLKsJ2zUZVzDubrzhiy6O+77iJt3Qy orXnE/0UyyhYQsgmry+SyyMVR+ZOjicQLQC7LSoZTKYdFf3Z8WC/uZ9oBtBqioSJ8FMObvAmfWl 3wymJpW5f6ohfXqR2HNq3ww5LbUTjIwdTsar8jpRteRyyZurml1hWvJAgGtJdkUjzACueItDDMR 8c+9tC6SJGR59hXu/xqgVzjOFZ0N1zajVZv8sRBI/ju0IMmxSxsyCIesmTvKWtJT5vus+PHB+vJ XGeIIIV33HxiOdJhG1l3HhwLhHxrxQq/jnMgLb8CMyAKNLp5nPYbfrKnB+h//AQ7Lw== X-Google-Smtp-Source: AGHT+IFpZvUMHqeQtksnOAg+Lzy2AOfJslF9z79M/Ax/KyLElZixvscmWWK0CQLHTnNRgJJNrtlgiw== X-Received: by 2002:a05:6000:2ac:b0:390:eb6f:46bf with SMTP id ffacd0b85a97d-39132d08dc1mr11320588f8f.5.1741624313220; Mon, 10 Mar 2025 09:31:53 -0700 (PDT) Received: from localhost.localdomain ([2001:871:260:1b24:b8d0:da60:28ff:a328]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3912c0195casm15731713f8f.53.2025.03.10.09.31.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Mar 2025 09:31:52 -0700 (PDT) Message-ID: Subject: Re: Big script execution From: Laurenz Albe To: Igor Korot , "pgsql-generallists.postgresql.org" Date: Mon, 10 Mar 2025 17:31:51 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.54.3 (3.54.3-1.fc41) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2025-03-10 at 16:42 -0500, Igor Korot wrote: > I am trying to execute a huge script (~40K lines) that will populate > my database. >=20 > The script starts with "BEGIN TRANSACTION" and will end > with "COMMIT". >=20 > however I'd like to rollback if there is an error encounter. >=20 > When I execute it from the Terminal I do use >=20 > -v ON_ERROR_STOP=3D1 >=20 > but I'd like to rolback the transaction so it starts a fresh every time. >=20 > Is there some kind of >=20 > ON ERROR ROLLBACK >=20 > command I can put inside the script? That happens automatically: if you are running the whole script in a single transaction, any error will make the whole transaction roll back. Yours, Laurenz Albe