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 1jYoO3-0006kP-HC for pgsql-general@arkaria.postgresql.org; Wed, 13 May 2020 10:13:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jYoO0-0006kQ-SO for pgsql-general@arkaria.postgresql.org; Wed, 13 May 2020 10:13:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jYoO0-0006kI-Kn for pgsql-general@lists.postgresql.org; Wed, 13 May 2020 10:13:12 +0000 Received: from smh-06.1blu.de ([178.254.0.206]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jYoNs-0003on-Dt for pgsql-general@lists.postgresql.org; Wed, 13 May 2020 10:13:12 +0000 Received: from [172.16.29.5] (helo=sh4-5.1blu.de) by smh-06.1blu.de with esmtp (Exim 4.86_2) (envelope-from ) id 1jYoNp-0001tz-T2; Wed, 13 May 2020 12:13:02 +0200 Received: from ftp51246-2575596 by sh4-5.1blu.de with local (Exim 4.90_1) (envelope-from ) id 1jYoNp-0005VV-R0; Wed, 13 May 2020 12:13:01 +0200 Date: Wed, 13 May 2020 12:13:01 +0200 From: Matthias Apitz To: pgsql-general@lists.postgresql.org Subject: Re: ESQL/C: a ROLLBACK rolls back a COMMITED transaction Message-ID: <20200513101301.GC26063@sh4-5.1blu.de> Reply-To: Matthias Apitz References: <20200512145352.GA32335@sh4-5.1blu.de> <23100.1589298880@sss.pgh.pa.us> <20200512191429.GB32335@sh4-5.1blu.de> <9dbc6477-f9a2-b62a-e011-0983fe150741@aklaver.com> <20200512235207.GA3420@sh4-5.1blu.de> <20200513053405.GB26063@sh4-5.1blu.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200513053405.GB26063@sh4-5.1blu.de> X-Operating-System: FreeBSD 12.0-CURRENT r314251 (amd64) X-message-flag: Mails containing HTML will not be read! Please send only plain text. User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I finally can reproduce the issue with a small ESQL/C written program for that purpose. I could attach here the source, but even seeing its printouts, all is perhaps clear: the pgm does an INSERT, after this the row is there and can be seen with SELECT; than I CLOSE a non existing cursor, which rolls back the INSERTed data: ./embedded tstint: 11073 INSERT done SELECT done SELECT: tstint: 11073 tstchar25: [hello] CLOSE "foo_bar" done SQL error: cursor "foo_bar" does not exist on line 57 SQL error: current transaction is aborted, commands ignored until end of transaction block on line 61 SELECT done SELECT: tstint: 0 tstchar25: [] COMMIT done SELECT done SELECT: tstint: 0 tstchar25: [] ROLLBACK done SELECT done SELECT: tstint: 0 tstchar25: [] i.e. not the ROLLBACK removes the data, but the CLOSE of non existing CURSOR. We have in our huge application server and its DB-layer places where we close in advance a CURSOR to be sure that its CREATE will not cause any problem because it is existing. Until yesterday we thought that the raised -400 error, like [1471] [12.05.2020 15:48:50:477]: ecpg_check_PQresult on line 939: bad response - ERROR: cursor "adm_partab_seq" does not exist [1471] [12.05.2020 15:48:50:477]: raising sqlstate 34000 (sqlcode -400): cursor "adm_partab_seq" does not exist on line 939 could be overcome with the COMMIT without loosing the inserted data. Main question: How can we ask the PostgreSQL server if a CURSOR 'foo_bar' (still) does exist or not? Thanks matthias -- Matthias Apitz, ✉ guru@unixarea.de, http://www.unixarea.de/ +49-176-38902045 Public GnuPG key: http://www.unixarea.de/key.pub