Closed psycoteam closed 14 years ago
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.
Originally submitted by: 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.
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'.
Fixed in my branch, thank you.
Originally submitted by: marko kreen
Originally submitted as number 9 - http://psycopg.lighthouseapp.com/projects/62710/tickets/9
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.