Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k2tF6-0004cr-Lq for pgsql-general@arkaria.postgresql.org; Tue, 04 Aug 2020 09:28:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k2tF5-0004TR-JJ for pgsql-general@arkaria.postgresql.org; Tue, 04 Aug 2020 09:28:19 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k2tF5-0004TK-Az for pgsql-general@lists.postgresql.org; Tue, 04 Aug 2020 09:28:19 +0000 Received: from mout.gmx.net ([212.227.17.21]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k2tF2-00046X-C9 for pgsql-general@lists.postgresql.org; Tue, 04 Aug 2020 09:28:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1596533294; bh=Du70rfawI4s+qrk2rzl12sNukeKHRpMMQU2zrWDUcDE=; h=X-UI-Sender-Class:Subject:To:References:From:Date:In-Reply-To; b=e0Lytr0HaxsKOv5XZuWhQPjwixgA2cuGQ6UcpmH4Sk8tkwvypw7OxDYyIPCvHKwfh dH2ca1ZpAa2esdDl5HceFOfp6KPIMltuG9W/01tzVe1HJ7cVja8goHEoewbtAO60WK yw7nnaBJGBatj9TpNX6K5XKtgR4qo0Ss8Yq2ksvo= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [10.1.32.111] ([185.40.248.10]) by mail.gmx.com (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MA7GM-1jsOZg0rQA-00BfJ1 for ; Tue, 04 Aug 2020 11:28:14 +0200 Subject: Re: PostgreSQL transaction aborted on SQL error To: pgsql-general@lists.postgresql.org References: From: Thomas Kellerer Message-ID: <72725856-943d-2ad0-905f-aad2ea242f2f@gmx.net> Date: Tue, 4 Aug 2020 11:28:13 +0200 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:2WRl23091VvNUpqCKBy4BZLpsPOn6Je0vGvpa1CqAi/FU3RmQka AwAlKT8XvVbYcG7iZ5BBBdbwHvL5GXia0JnBb8VespaJaFg8R3KsTF701RC48jiwMjsGkwX jWytuRPPglAXYGfGEbUdYYW91gUInjcED24WvlGhiR9wsZ1p9X6MpupGIK1KAPCfOchFn2V onymopJQPRM2VjML6y3mg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:mKZWU/Eotus=:BNj1YG/yJHGWRIVngkUtJg 56k/uVhmo6wNKYyt17MeVbbULxEK05NXn03IUMtQJHqhh1IO4jyYozjnB8yr+0GeeaJLpNJHE MzpmRZLZaXqYWnkZEJL10aniDlmlNBwYjkChf85GvmB40ZnTeDYnNuRVmBh8RX9l9w7tVXCoW ukSZobPBzdBchWaGsdlwrj/cOfsFop3t+vEdeyt5m9C6n614UkBrOeBip1c8iutMtNh1wxHTa xToi2pcr29dOSHhXL8KE2hy5TvcZs9cd6L/mtEoj53acOe1iakH0kV8BRNz7cXMqiL+cy1f23 4X5fpj9VMxsK30Iuw2q1c+PpAyGZAwqWx5kd9cs9bdxErE3iPCiQB66JffL6l2m+dh0eciSIv jReWDX2eVVtQcDm6ml7qNvY8lrbEbAMfYry6eYNOUtJ7UBCarc+++ll4++jwMQ2nGQSviwFSN /6CXFzfM6g80lqd2SH6WWiLS15TBOxstcllNMIEaVyy0oZO0pThH8LyRC84/mhqdLMh1jvBFY MGShFwelrhic4MVVyambH5sZHapjWEUAZTo0o2PT9JaIt7YqExuCNOEJYJAs6KCEgA3MS62Rm pQl8ZspqwS3a+QBibId0c/rtrmQ6N8fCKC/j+UG0AnLuQK2+4nBT9bySCIQYT/txMB7iZrkKe oMBTcux5qcGXqszUxHIEL3jZ7F2uzDUEH9p0LZm8Hoqw1mHE547fqHjIXt8lCpf50cJSJiOqQ R+63h+1D+bKlUiZXMljpLYQT5gH+1aAaXt7iYcbEA7ICgoWimjwfGSmvClcUDyhPuL3/W1B0q nf10bXPaGhWYjNtFASt5W86Rid0t4jHuwyri3K5QQQsqlru1KWzmvTxFOZiduFoa/UQUH/Wau PDV4LbeI0NIrjMKOJTHyPVWBYSb4QuG180LcziWoVkI+fWQPt9sml6FR/jK0p2q72ijbIIDmW OP3YBmdfnxNFXjaEmePcQ6IZ2g4k0Bswv9KgyhZACBqXQ2xvOt2UKSp4PeEWgJgCi4Wn8NzDT aRVupA5SGmGpti2neUTMBSqa/eZt/je87PdjxR0B4qahj9z6xFCoO525m9T2eZD6/cKy0kyEq rq1SbitZ1rWpYT/i31VfDk5rfa/wLt8beflV0xXhs2wR0fH8jQ9lCUnAxsidDxkTNGZDnGve5 PjS4XhJKmOsHLKo9PX+rF2Fng8I6iFCJB+4MDeUhPK5xAMsmxyEWSG2pEAcfP4O2+OgJhbzDa 0Q2n+T1LQMP9EIkuW List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Urko Lekuona schrieb am 04.08.2020 um 10:44: > First time writing here, I hope this is the right place to ask this > kind of question. I've been working with PostgreSQL for a while now > but i've just found out that PostgreSQL marks my transaction for > ROLLBACK and even stops the execution of the transaction if an error > occurs. Which is exactly how a transaction is defined: Either all statements are successful or none. > If you run it, you'd see that when the unique key constraint is > violated, my transaction is stopped You can use INSERT ON CONFLICT DOT NOTHING to avoid that. > make it work like other RDBMS do, where if a statement failed, the > transaction could continue Which completely violates the idea of a transaction. The choices you have are: * use auto-commit * make sure your inserts don't throw an error * use manual savepoints around each statement (don't forget DDL statements= !) Thomas