Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

reversed order of db notices

#9

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.

Reported by Psycopg website · November 9th, 2010 @ 10:50 AM

State: resolved
Milestone: release-2.3.0
Assigned to: nobody

Activity

  1. Daniele Varrazzo
    Daniele Varrazzo
    • 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.

    November 9th, 2010 @ 12:01 PM

  2. Marko Kreen
    Marko Kreen

    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.

    November 9th, 2010 @ 12:21 PM

  3. Daniele Varrazzo
    Daniele Varrazzo

    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'.
    

    November 9th, 2010 @ 12:39 PM

  4. Daniele Varrazzo
    Daniele Varrazzo
    • State changed from open to resolved
    • Milestone set to release-2.3.0

    Fixed in my branch, thank you.

    November 11th, 2010 @ 11:56 AM