Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g97g0-0004uk-5c for psycopg@arkaria.postgresql.org; Sun, 07 Oct 2018 11:56:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g97fw-00028u-QO for psycopg@arkaria.postgresql.org; Sun, 07 Oct 2018 11:56:44 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g97fw-00028g-Le for psycopg@lists.postgresql.org; Sun, 07 Oct 2018 11:56:44 +0000 Received: from mail.dndg.it ([178.32.136.2]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g97ft-0007jN-Gj for psycopg@lists.postgresql.org; Sun, 07 Oct 2018 11:56:43 +0000 Received: from [192.168.1.100] (93-36-167-113.ip61.fastwebnet.it [93.36.167.113]) by mail.dndg.it (Postfix) with ESMTPSA id EE5FBA02C4 for ; Sun, 7 Oct 2018 12:02:03 +0000 (UTC) Subject: Re: Integration of Psycopg with XTA To: psycopg@lists.postgresql.org References: <1005537726.6324310.1538685211791@mail.yahoo.com> <602182297.6960405.1538755378178@mail.yahoo.com> From: Federico Di Gregorio Organization: DNDG srl Message-ID: <618fbba4-0f31-2e44-8517-a158cccbef0d@dndg.it> Date: Sun, 7 Oct 2018 13:56:37 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <602182297.6960405.1538755378178@mail.yahoo.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=0.0 required=5.0 tests=ALL_TRUSTED,SURBL_BLOCKED, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 10/05/2018 06:02 PM, Christian Ferrari wrote: > In a previous mail I stated something like "the name of the method > doesn't matter"... > ... after better thinking I realized a decent name might be better than > other ones... > Let me say: > > get_native_conn() > get_native_connection() > > might be better than "get_/something/_pgconn" because the same type of > method could be useful for other databases in the future... > More or less all the databases use a "native connection", only > PostgreSQL uses "PGconn connection". After some more checking I discovered that it isn't possible to "invalidate" a PyCapsule so there is no way to tell if the pointer inside it is still a valid libpq connection. The current code (feel free to pull) adds a new method get_native_connection() that raise an exception if called on a closed connection. I better like a method here because it gives the idea that you need to call it every time you want a Capsule to pass to the target C API. I also added some docs and a dumb test. https://github.com/fogzot/psycopg2/tree/feature-expose-pgconn @Daniele, if Christian reports no problems I'll merge this later for 2.8. federico -- Federico Di Gregorio federico.digregorio@dndg.it DNDG srl http://dndg.it Io non sono romantica. La candelina sul tavolo mi vede e si spegne. -- sisterconfusion