[DB-SIG] Porting a Postgres Python library to Ingres?

hme@informatik.uni-rostock.de hme@informatik.uni-rostock.de
Thu, 28 Mar 2002 19:49:14 +0100


Hello Hamish,

You (Hamish Lawson) wrote:
[...]
> > I'll let You know by email.
> 
> Thank you.
> 
> > > I think it may need some development in other areas.
> > 
> > Which other areas You are refering to?  Maybe I'm working on it?  Due
> > to heavy workload (book project) I didn't published a new version but
> > there were several bug fixes, enhancements ... in the last year.
> 
> I wasn't sure if you were still developing ingmod, which is why I was
> looking at other options. There were a couple of issues I had found.
> 
> The MAXCURSPERSESSION limit appears to be a limit on how many cursors
> can get allocated, not just a limit on how many can be open at the same
> time; that is, successively allocating and then closing a cursor will
> cause the limit to be exceed after MAXCURSPERSESSION times. See listing
> 1 below.

That's right.

> Under Python 2.2 (including 2.2.1c2), attempting to iterate through
> cursor.description sometimes causes a "tuple index out of range" error.

Another user of ingmod reported that too.

> One such occasion is running the ingtest.py script that comes with
> ingmod; see listing 2 below. Might this be related to the new iterator
> protocol introduced in Python 2.2?

Yes, You are right.  Since I didn't compile ingmod under 2.2, I was not
aware of that up to now.

> > AFAIK, even UCB Ingres and UCB Postgres didn't share any piece of code.
> 
> I thought it possible that they might not share much actual code, but do
> you also think that the application programming interface is different
> too?
> 
> Regards,
> Hamish
> 
> 
> ---------
> LISTING 1
> --------- 
> >>> import ingmod
> >>> conn = ingmod.connect('iidbdb')
> >>> for i in range(20):
> ...     cursor = conn.cursor()
> ...     cursor.execute("select * from ingres_access_requests")
> ...     cursor.close()
> ...     print i
> ...
> 0
> 1
> 2
> 3
> 4
> 5
> 6
> 7
> 8
> 9
> 10
> 11
> 12
> 13
> 14
> 15
> Traceback (most recent call last):
>   File "<stdin>", line 2, in ?
> ingmod.OperationalError: max # of cursors per session reached
> ---------

I have to re-design the cursor allocation to fix that, but it is not an
expensive job.

> LISTING 2
> --------- 
> ...
> ('attver_dropped', <type 'int'>, None, 2, None, None, 0)
> ('attval_from', <type 'int'>, None, 2, None, None, 0)
> ('attfree', <type 'str'>, None, 24, None, None, 0)
> Traceback (most recent call last):
>   File "ingtest.py", line 86, in ?
>     for t in cu.description:
> IndexError: tuple index out of range

I had just a look at the new Python interface today.  You are right,
it causes this IndexError.

Thanks for Your hints and comments

Wish You a peaceful ``Osterfest''

Holger

-- 
Holger Meyer, Uni of Rostock, Dpt. of CS, DB Research Group
hm at IEEE.org, http://wwwdb.informatik.uni-rostock.de/