Re: PerformPortalClose warning in 7.3 - Mailing list pgsql-general

From Gerhard Haering
Subject Re: PerformPortalClose warning in 7.3
Date
Msg-id slrnb0cp0i.aji.haering_postgresql@lilith.my-fqdn.de
Whole thread Raw
In response to Re: [PERFORM] CLUSTER command  (Jean-Luc Lachance <jllachan@nsd.ca>)
Responses Re: PerformPortalClose warning in 7.3  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Michael Engelhart wrote in gmane.comp.db.postgresql.general:
> Hi -
> I've been running PostgreSQL 7.3 on Mac OS X 10.2 since it was released
> and it's been running fine.  I'm using pyPgSQL 2.3 for client side
> programming which also was working great until tonight.   Now whenever
> I do any query of any type, I get warnings like this:
>
> WARNING:  PerformPortalClose: portal "pgsql_00179f10" not found
>
> It "appears" that everything is still working the way it was but it's a
> bit discomforting to have these  show up on my screen while running my
> applications.
>
> Anyone that can explain this?
>
> Here's a tiny bit of Python sample code that I used to make sure it
> wasn't my other code causing the problems
>
> from pyPgSQL import PgSQL
>
> dbname = "template1"
> conn = PgSQL.connect(database=dbname)
> cursor = conn.cursor()
> sql = "SELECT now()";
> cursor.execute(sql)
> res = cursor.fetchall()
> for i in res:
>     print i
> cursor.close()
> conn.commit()

Actually, pyPgSQL is using PostgreSQL portals behind your back. This
is a feature!

To show this, we use the undocumented, but very handy toggleShowQuery
flag. The effect is that we can see what SQL pyPgSQL sends to the
backend using libpq (the lines staring with QUERY: below):

#v+
gerhard@gargamel:~$ python
Python 2.2.2 (#1, Nov 30 2002, 23:19:58)
[GCC 2.95.4 20020320 [FreeBSD]] on freebsd4
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyPgSQL import PgSQL
>>> con = PgSQL.connect()
>>> con.conn.toggleShowQuery
'On'
>>> cursor = con.cursor()
QUERY: BEGIN WORK
>>> cursor.execute("select * from test")
QUERY: DECLARE "PgSQL_0811F1EC" CURSOR FOR select * from test
QUERY: FETCH 1 FROM "PgSQL_0811F1EC"
QUERY: SELECT typname, -1 , typelem FROM pg_type WHERE oid = 23
QUERY: SELECT typname, -1 , typelem FROM pg_type WHERE oid = 1043
>>> result = cursor.fetchmany(5)
QUERY: FETCH 4 FROM "PgSQL_0811F1EC"
>>> result
[[None, 'A'], [None, 'B'], [None, 'C'], [None, 'F'], [None, 'F']]
>>> con.commit()
QUERY: CLOSE PgSQL_0811F1EC
QUERY: COMMIT WORK
>>>
#v-

This gives me a warning like this:

#v+
WARNING:  PerformPortalClose: portal "pgsql_0811f1ec" not found
#v-

As far as I can see, the SQL pyPgSQL emits is perfectly ok. But I'd be
glad to hear a clarification.

> strangely if I remove the last 2 lines (cursor.close() and
> conn.commit()) I don't get the errors.
>
> Also I don't notice that I don't have this problem with psql command
> line either.   Is this the Python API causing this?

If you use the same SQL statements using portals in psql, you get the
same warning (obviously). I just tried.

Gerhard (pyPgSQL developer)
--
Favourite database:             http://www.postgresql.org/
Favourite programming language: http://www.python.org/
Combine the two:                http://pypgsql.sf.net/
Embedded database for Python:   http://pysqlite.sf.net/

pgsql-general by date:

Previous
From: Scott Lamb
Date:
Subject: Re: ident auth not working on 7.3.1
Next
From: Tom Lane
Date:
Subject: Re: