Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ilp6l-0001L1-T2 for pgsql-general@arkaria.postgresql.org; Mon, 30 Dec 2019 07:04:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ilp6i-0000gG-RJ for pgsql-general@arkaria.postgresql.org; Mon, 30 Dec 2019 07:04:52 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ilp6i-0000g9-E4 for pgsql-general@lists.postgresql.org; Mon, 30 Dec 2019 07:04:52 +0000 Received: from ms-10.1blu.de ([178.254.4.101]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ilp6b-00080O-KX for pgsql-general@lists.postgresql.org; Mon, 30 Dec 2019 07:04:51 +0000 Received: from [188.174.48.28] (helo=localhost.unixarea.de) by ms-10.1blu.de with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.86_2) (envelope-from ) id 1ilp6U-0006A9-Gd; Mon, 30 Dec 2019 08:04:38 +0100 Received: from localhost.my.domain (localhost [127.0.0.1]) by localhost.unixarea.de (8.15.2/8.14.9) with ESMTPS id xBU74aHN003391 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Mon, 30 Dec 2019 08:04:37 +0100 (CET) (envelope-from guru@unixarea.de) Received: (from guru@localhost) by localhost.my.domain (8.15.2/8.14.9/Submit) id xBU74aPf003390; Mon, 30 Dec 2019 08:04:36 +0100 (CET) (envelope-from guru@unixarea.de) X-Authentication-Warning: localhost.my.domain: guru set sender to guru@unixarea.de using -f Date: Mon, 30 Dec 2019 08:04:35 +0100 From: Matthias Apitz To: pgsql-general@lists.postgresql.org Subject: Re: testing in ESQL/C if a CUSROR "foo" is open? Message-ID: <20191230070435.GA3350@c720-r342378> Reply-To: Matthias Apitz References: <20191227055522.GA2995@c720-r342378> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20191227055522.GA2995@c720-r342378> X-Operating-System: FreeBSD 13.0-CURRENT r342378 (amd64) X-message-flag: Mails containing HTML will not be read! Please send only plain text. User-Agent: Mutt/1.11.1 (2018-12-01) X-Con-Id: 51246 X-Con-U: 0-guru X-Originating-IP: 188.174.48.28 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk El día viernes, diciembre 27, 2019 a las 06:55:22a. m. +0100, Matthias Apitz escribió: > > Hello, > > Is there any way (without looking up the name in table 'pg_cursors') to see if a > cursor "foo" is still open? > I found this hint about 'pg_cursors' in stackoverflow: https://stackoverflow.com/questions/51146931/postgres-finding-an-open-cursor-and-closing-it But did no see how to code this in ESQL/C, something like: EXEC SQL IF EXISTS(SELECT * FROM pg_cursors WHERE name = :cur) THEN CLOSE :cur; Which does not work. And, what concerns me as well is how expensive such test is before closing any cursor. matthias -- Matthias Apitz, ✉ guru@unixarea.de, http://www.unixarea.de/ +49-176-38902045 Public GnuPG key: http://www.unixarea.de/key.pub