This project is archived and is in readonly mode.

#9 ✓resolved
Psycopg website

reversed order of db notices

Reported by Psycopg website | November 9th, 2010 @ 10:50 AM | in release-2.3.0

Submitted by: marko kreen

when one statement issues several notices,
they appear in reversed order in .notices list. the reason is that they are prepended to temporary singly linked list which is later walked sequentially.

fix would be to append them to the singly linked list.

Comments and changes to this ticket

  • Daniele Varrazzo

    Daniele Varrazzo November 9th, 2010 @ 12:01 PM

    • State changed from “new” to “open”

    You are right, and using conn.notifies.pop(0) (or insert(0) when adding items) is inefficient. Probably we should use collections.deque and appendleft() on our side so that pop() on the client side would work as expected.

    By the way there is a similar problem in conn.notices, which is a list whose max length is clipped to avoid unbounded growth (a problem we had with excessive warnings before we starting respecting the standard_conforming_strings setting).

    The problem is as usual with backward compatibility as deque doesn't support all the list interface (e.g. slicing, don't know what else). I don't expect to break much code though, and the gain would be huge.

  • Marko Kreen

    Marko Kreen November 9th, 2010 @ 12:21 PM

    Considering the notices are mostly debugging aid, I would not worry about efficiency too much.

    But the reordering problem makes it hard to do even debugging, which is bad.

    Note I was talking about this (temp) list:

    struct connectionObject_notice *notice_pending;

    not the Python array.

  • Daniele Varrazzo

    Daniele Varrazzo November 9th, 2010 @ 12:39 PM

    Uhm, I mixed notices and notifies: I think they both have the same efficiency problem.

    The temporary notice_pending can definitely be fixed, thank you for the report. I agree the notices in this example should be made available in the opposite order in the notices list.

    In [17]: cur.execute("select 'a\\a';\nselect 'b\\b'")
    In [20]: print '\n'.join(cnn.notices)
    WARNING:  nonstandard use of escape in a string literal
    LINE 2: select 'b\b'
    HINT:  Use the escape string syntax for escapes, e.g., E'\r\n'.
    WARNING:  nonstandard use of escape in a string literal
    LINE 1: select 'a\a';
    HINT:  Use the escape string syntax for escapes, e.g., E'\r\n'.
  • Daniele Varrazzo

    Daniele Varrazzo November 11th, 2010 @ 11:56 AM

    • State changed from “open” to “resolved”
    • Milestone set to release-2.3.0

    Fixed in my branch, thank you.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

<b>WARNING:</b> the informations in this tracker are archived. Please submit new tickets or comments to <a href="">the new tracker</a>.
Psycopg is the most used PostgreSQL adapter for the Python programming language. At the core it fully implements the Python DB API 2.0 specifications. Several extensions allow access to many of the features offered by PostgreSQL.

Shared Ticket Bins

People watching this ticket


Referenced by