some thoughts about server_side_cursors problems whith Postgres

Issue #431 resolved
Former user created an issue

I found difference in client|server cursors behaviour:[BR] client - side cursor fills cursor.description after execute(), and server-side cursor leave description 'None' after execute() until call of fetch...().[BR] I found it both on windows and linux, with postgres 8.1.2 and psycopg 2-2.0.51 (last stable version).[BR] SA looks in cursor description before calling fetch - see base.py line 562.

Comments (5)

  1. Mike Bayer repo owner

    how come i cant reproduce any error on my system ? is this a psycopg2/postgres version issue ? do you have an error case (and what versions of everything are you using) ?

  2. Former user Account Deleted

    I don't understand that. [BR] My system[BR] Windows XP sp1[BR] Python 2.4.3, downloaded windows installer[BR] Postgres 8.2.0, installed from win installer today (before - 8.1.2)[BR] Psycopg http://stickpeople.com/projects/python/win-psycopg/ psycopg2-2.0.6b1.win32-py2.4-pg8.2.1-release.exe - installed today (before - 2-2.0.51)[BR] SA - rev 2236 [BR] With both versions of Postgres and psycopg - same thing[BR]

    SA ERROR:
    KeyError: 0
    23-01 10:46:341: ERROR    0
    Traceback (most recent call last):
      File "D:\Work\Ballista\src\python\dcko\model.py", line 1508, in init
        link_table = Table('link',metadata,autoload=True)
      File "build\bdist.win32\egg\sqlalchemy\schema.py", line 143, in __call__
      File "build\bdist.win32\egg\sqlalchemy\engine\base.py", line 508, in reflecttable
      File "build\bdist.win32\egg\sqlalchemy\databases\postgres.py", line 357, in reflecttable
      File "build\bdist.win32\egg\sqlalchemy\engine\base.py", line 732, in __iter__
      File "build\bdist.win32\egg\sqlalchemy\engine\base.py", line 634, in _get_col
      File "build\bdist.win32\egg\sqlalchemy\engine\base.py", line 622, in _convert_key
    KeyError: 0
    

    SA reflection tests fail - no need to make new one.[BR] The problem is with cursor.description.[BR] I will append test of psycopg, which shows difference between local and server cursors. How this test works on your system?[BR] I fooled do_execute() whith fetching one record, scrolling cursor back and assigning description again. Reflection works, but it's very stupid and i got transaction error.

  3. Mike Bayer repo owner

    we have a new ResultProxy called PreFetchingResultProxy, used by oracle. since i dont want to pollute ResultProxy with "stay one step ahead" behavior, might want to implement another variant of ResultProxy that either prefetches the first row, or doesnt try to store cursor metadata until a row has been fetched. what happens if we "insert", and have no rows to fetch ?

  4. Mike Bayer repo owner

    i wasnt able to reproduce since my version of psycopg2 didnt actually do server side cursors. we have a patch pending and this ticket is now a dupe of #514.

  5. Log in to comment