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 1neHNr-0006jE-4m for pgsql-admin@arkaria.postgresql.org; Tue, 12 Apr 2022 14:20:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1neHNq-00013J-0C for pgsql-admin@arkaria.postgresql.org; Tue, 12 Apr 2022 14:20:42 +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 1neHNp-000139-Lp for pgsql-admin@lists.postgresql.org; Tue, 12 Apr 2022 14:20:41 +0000 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1neHNj-0005gz-4O for pgsql-admin@lists.postgresql.org; Tue, 12 Apr 2022 14:20:40 +0000 Received: by mail-pl1-x629.google.com with SMTP id q3so5663277plg.3 for ; Tue, 12 Apr 2022 07:20:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=uQCw18NaNc8KnWxd4QaWITVPwqSy4MQSKNCVXihCQhg=; b=oYMUQWeXSLk+pRop90FeqHdObrFaMu6/Xg5RUJ5c6SUb2l0XVy6FLQ52VhoGEJfmzB QiyatYYa/BuYKM3RHeHkbaH+4GIP+s8dTDJyQQj4YCREy4NzlDSa7ITD1vYCTknTlJFa r0C+O3Xz8o8dkpZvGJ2MTHtSdWdCtVnUh7cvEqCQOOAAspyKxMxVa8+wvTEBGV5Y103r T7fTSOIthOYvnQQpKf8nB1v7RN5q3w5RYhBJs4owsSZaWZ0v1Z/TqgTMWcQd8Hf3A1ZV iCJwyqPmTCuT3jSXi4ubLSPkvUFsLyDCXzpDOqL/Jom7ibM78Vp0ZgzdMVTY9QY8IbfC CLiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=uQCw18NaNc8KnWxd4QaWITVPwqSy4MQSKNCVXihCQhg=; b=0nooFWInghLGbxYdTt6c01JW42LZsnZo5fC3tLgl54MCxEm6spjqt/4FFPZCZb4LZc D9nkIED0sHkKxVmZR1Zyro/lGuLdxpfv/b1XluLr4fRq1wR8hrkjY0ZRjNDcr/jluQEt 5OW5WGvPlXkzKwcdIygu9+kTyaF35YgP+ovpQ2jDZfM/wyAn2eIiEKvXyD2n1DMqalEt P4jzrHXAubr42Taxk17+AC8aS7WShbYYdAY8d9BQS8vGG5JJsqf6Pyb/C5KX4wf8RBz6 XA8ONnDFEI1LOlCfd/txPVjIcMgkDd3O/V1c6qgxpGAvUmG1IpfBlhKcD1I1v+5pmAEJ h2rQ== X-Gm-Message-State: AOAM533ZyPdRbUvyJ+iYDUzvs3SC7ugYxt0OObgzKhYr+BYZzLhEVtML 0WlbIPwJzbYPL+LUEkNuSXg= X-Google-Smtp-Source: ABdhPJzlGej/o+twJUXMy5Y4cERkhCLUwLdX6hBUIGrQbzfU0oMFDYfHEkaEgCumappkz/46cHggFg== X-Received: by 2002:a17:903:2306:b0:154:92f:67c3 with SMTP id d6-20020a170903230600b00154092f67c3mr38789830plh.157.1649773234190; Tue, 12 Apr 2022 07:20:34 -0700 (PDT) Received: from jrouhaud (2001-b011-1005-f552-4db2-857c-d861-75db.dynamic-ip6.hinet.net. [2001:b011:1005:f552:4db2:857c:d861:75db]) by smtp.gmail.com with ESMTPSA id k27-20020aa79d1b000000b005059ad6b943sm12259610pfp.166.2022.04.12.07.20.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 07:20:33 -0700 (PDT) Date: Tue, 12 Apr 2022 22:20:28 +0800 From: Julien Rouhaud To: Mladen Gogala Cc: pgsql-admin@lists.postgresql.org Subject: Re: set autocommit only for select statements Message-ID: References: <548f2ed6-3209-705d-09e2-a5afbc6fb71c@quadratum-braccas.com> <6bfd5d91-bb06-1b56-f4f8-cc8f90307a35@jakobs.com> <37b5b251-83f8-56bc-579d-882daaa4fc47@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <37b5b251-83f8-56bc-579d-882daaa4fc47@gmail.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Apr 12, 2022 at 08:00:35AM -0400, Mladen Gogala wrote: > On 4/12/22 02:31, Holger Jakobs wrote: > > What you write about psql sending a COMMIT statement after each > > statement is wrong. It may be true for other database systems. > > > > PostgreSQL as a server commits each statement automatically unless the > > client has started a transaction with BEGIN or START TRANSACTION > > statements. > > > > This can be proved easily by not using psql as a client, but some > > programming language. > > > > Regards, > > If what you are saying was true, then autocommit would be a database mode, > not a tool mode. It isn't a database mode. Q.E.D. That's actually mostly true. Postgres will start an implicit transaction for every query (or multiple queries) outside a transaction and will implicitly commit it after a successful execution. The only difference is there you won't see a BEGIN / COMMIT anywhere, but the same underlying code will be executed.