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 1g9C8S-00027g-T2 for psycopg@arkaria.postgresql.org; Sun, 07 Oct 2018 16:42:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g9C8R-0001Pa-5x for psycopg@arkaria.postgresql.org; Sun, 07 Oct 2018 16:42:27 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g9C8Q-0001PR-Et for psycopg@lists.postgresql.org; Sun, 07 Oct 2018 16:42:27 +0000 Received: from sonic309-25.consmr.mail.ir2.yahoo.com ([77.238.179.83]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g9C8I-0005Dw-QF for psycopg@lists.postgresql.org; Sun, 07 Oct 2018 16:42:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1538930535; bh=CfRrys+2ytChJ1Ir4L3cayAilChG4OQgwue5rg4RMAc=; h=Date:From:Reply-To:To:In-Reply-To:References:Subject:From:Subject; b=SzXfExexK7PpzJEjp5X3uz1OoZvFcysPdxb+jan6AL7N92q3Q7kS2xamOrUEU3E0PEMzoYHzfxdWDxThEf8VuXjCBOmkEcjD/GHUU/kBGMbsDzJjFq09OLbeNTP33tJUBnUC5OLczFqly0snZaUNUmzbVSur/3uY6w/5ibqfumXvz5EK3NhpKkxuPESn2BvFOMniziiCbyq4xMWA5jcRL2fp1QcUr7pwAqgJ3K7XckzopI1tPEICq5vDEK/eM15PUYYF0O4PmFSQWwF5gnnwuExLRAmKl4MFAtgsmQBLmm8i1eu0oHfFx4jwA677j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wSnNPN5wG1FlY3RpDAbO hsEnNIH8PxGA7AHTmQlmw6Qnb56IlJdKvOtaF0z3JVcvJz31Q98SvL9eFdEKz4qVlcBVgYXT0fMb ikga1UUzclQ-- Received: from sonic.gate.mail.ne1.yahoo.com by sonic309.consmr.mail.ir2.yahoo.com with HTTP; Sun, 7 Oct 2018 16:42:15 +0000 Date: Sun, 7 Oct 2018 16:42:10 +0000 (UTC) From: Christian Ferrari Reply-To: Christian Ferrari To: psycopg@lists.postgresql.org Message-ID: <634068058.7859603.1538930530793@mail.yahoo.com> In-Reply-To: <618fbba4-0f31-2e44-8517-a158cccbef0d@dndg.it> References: <1005537726.6324310.1538685211791@mail.yahoo.com> <602182297.6960405.1538755378178@mail.yahoo.com> <618fbba4-0f31-2e44-8517-a158cccbef0d@dndg.it> Subject: Re: Integration of Psycopg with XTA MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_7859602_69931624.1538930530790" X-Mailer: WebService/1.1.12512 YMailNorrin Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0 Content-Length: 10332 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------=_Part_7859602_69931624.1538930530790 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Federico,I've just tryed out commit https://github.com/fogzot/psycopg2/c= ommit/81addddaee2c690e925bb8f381e7bcb02ca97687 : get_native_connection() is= in the interface, but unfortunately it seems to work differently than the = old _raw_pgconn. Here's my code snippet: pgconn =3D rm1.get_native_connection()#pgconn =3D rm1._raw_pgconn=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 =C2=A0 xar1 =3D PostgresqlXaResource(pgconn, "PostgreSQL", "dbname=3Dtestdb") using get_native_connection(), I catch an error from XTA, the PGconn pointe= r is null. I have reversed back to commit https://github.com/fogzot/psycopg2/commit/cc= ae5cae34051d6640ec6cbce6d9313778c509d3 : _raw_pgconn works as before. Here's the code snippet: #pgconn =3D rm1.get_native_connection()=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0 pgconn =3D rm1._raw_pgconn xar1 =3D PostgresqlXaResource(pgconn, "PostgreSQL", "dbname=3Dtestdb") It works fine. Should "get_native_connection()" used differently than "_raw_pgconn" ? What= type of data are necessary to investigate the issue? Thanks in advanceKind RegardsCh.F. ------------------------------------------------------------- Good design can't stop bad implementation =20 Il domenica 7 ottobre 2018, 13:56:49 CEST, Federico Di Gregorio ha scritto: =20 =20 On 10/05/2018 06:02 PM, Christian Ferrari wrote: > In a previous mail I stated something like "the name of the method=20 > doesn't matter"... > ... after better thinking I realized a decent name might be better than= =20 > other ones... > Let me say: >=20 > get_native_conn() > get_native_connection() >=20 > might be better than "get_/something/_pgconn" because the same type of=20 > method could be useful for other databases in the future... > More or less all the databases use a "native connection", only=20 > PostgreSQL uses "PGconn connection". After some more checking I discovered that it isn't possible to=20 "invalidate" a PyCapsule so there is no way to tell if the pointer=20 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=20 a method here because it gives the idea that you need to call it every=20 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 --=20 Federico Di Gregorio=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 federico.digregorio@dndg.it DNDG srl=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 http://dndg.it =C2=A0 Io non sono romantica. La candelina sul tavolo mi vede e si spegne. =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 -- sisterconfusion =20 ------=_Part_7859602_69931624.1538930530790 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi Federico,
I've just tryed out commit https://github.com/fogzot/psycopg2/commit/81addddaee2c690e9= 25bb8f381e7bcb02ca97687 : get_native_connection() is in the interface, = but unfortunately it seems to work differently than the old _raw_pgconn.

Here's my code snippet:

pgconn =3D rm1.get_native_connection()
#pgconn =3D rm1._raw_pgconn       &nb= sp;            =             &nb= sp;            =           
xar1 =3D Postgre= sqlXaResource(pgconn, "PostgreSQL", "dbname=3Dtestdb")

u= sing get_native_connection(), I catch an error from XTA, the PGconn pointer= is null.

I have reversed back to commit https://github.com/fogzot/p= sycopg2/commit/ccae5cae34051d6640ec6cbce6d9313778c509d3 : _raw_pgconn w= orks as before.

Here's the code snippet:

#pgconn =3D rm1.get_native_connection()  &n= bsp;            = ;            &n= bsp;            = ;   
pgconn =3D rm1._raw_pgconn
xar1 =3D PostgresqlXaResour= ce(pgconn, "PostgreSQL", "dbname=3Dtestdb")

It works fin= e.

Should "get_native_connection()" used different= ly than "_raw_pgconn" ? What type of data are necessary to investigate the = issue?

Thanks in advance
Kind Regards
Ch.F.

-------------------------------------------------------------Good design can't stop bad implementati= on


=20
=20
Il domenica 7 ottobre 2018, 13:56:49 CEST, Federico Di = Gregorio <fog@dndg.it> ha scritto:


On 10/05/2018 06:02 PM, Christian Fer= rari wrote:
> In a previous mail I stated something li= ke "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 data= bases use a "native connection", only
> PostgreSQL us= es "PGconn connection".

After some mor= e checking I discovered that it isn't possible to
"inval= idate" 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 pa= ss to the target C API.

I also added s= ome docs and a dumb test.

https://github.com/fogzot/psycopg2/tre= e/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      &nbs= p;                     &n= bsp;                     = http://dndg.it

  Io non sono romantica. = La candelina sul tavolo mi vede e si spegne.
   = ;                     &nb= sp;                     &= nbsp;       -- sisterconfusion


------=_Part_7859602_69931624.1538930530790--