Commit Graph

794 Commits

Author SHA1 Message Date
Daniele Varrazzo
e8286084e9 Free the GIL in blocking operations in V2 COPY FROM. 2010-04-07 23:52:53 +01:00
Daniele Varrazzo
aeec583ff1 Ensure running COPY in blocking mode. 2010-04-07 23:41:32 +01:00
Daniele Varrazzo
b114e25c31 Added some COPY tests. 2010-04-07 23:41:32 +01:00
Daniele Varrazzo
7e0dcfdda5 Added pq_set_non_blocking utility function. 2010-04-07 23:41:18 +01:00
Daniele Varrazzo
d339466c6a Speedup of the copy functions.
Python objects are evaluated only once outside the I/O loops.
2010-04-07 18:22:31 +01:00
Daniele Varrazzo
5a75d693a3 Dropped warnings when compiling on Python 2.5 2010-04-07 18:12:24 +01:00
Daniele Varrazzo
c75ddea895 Pass the async parameter to the connection only if nonzero.
This avoids breaking connection subclasses redefining '__init__' (at
least when used sync, which is good for most of the people).
2010-04-05 18:31:09 +01:00
Daniele Varrazzo
c486136df7 Delegate the destruction of the PGconn to the connection finalization.
This way we can have an usable connection before complete
initialization: this will be required to allow a Python callback to
interact with connect().
2010-04-05 18:19:37 +01:00
Federico Di Gregorio
012e2e3c72 Preparing 2.2.0 release candidate 1 2010-04-05 17:06:35 +02:00
Federico Di Gregorio
c1a24f4ca2 NOTIFYs fix and poll status changes
POLL_OK has been changed from 3 to 0 to let the user specify a short loop
just as "if not curs.poll()" instead of having to check for write and read
separately. For an example of this, see examples/notify.py.
2010-04-05 16:52:25 +02:00
Jan Urbański
e15bc9da05 Adapt the tests to recent changes
Some methods were forbidden in asynchronous mode, the isolation level
of an asynchronous connection is not always 0 and these changes
influenced expected test results.
2010-04-05 16:28:39 +02:00
Jan Urbański
31f60be000 Be a bit more explicit 2010-04-05 16:27:59 +02:00
Jan Urbański
58eb868db6 Avoid the possibility when curs_get_last_result would block
It was trying to get all pending results from the connection and if
the client sent many and anyone except the first one would not be
immediately available the loop in curs_get_last_result would call
PQgetResult blockingly.
Avoid that by calling PQisBusy every time and telling the client to
wait for more data if it returns 1.
2010-04-05 16:27:39 +02:00
Jan Urbański
25a609c9a7 Handle initial connection queries being sent partly
The CONN_STATUS_SENT_* statuses were not being handled at all, and
they indicate that a query has been sent, but not fully, so the client
should wait for the socket to become writable again and flush the output.
2010-04-05 16:25:17 +02:00
Jan Urbański
b99eac18f8 Make cursor.scroll() raise an exception in asynchronous mode
The exception is raised if an asynchronous query is in progress,
otherwise it will behave normally (since the data is already on the
client side).
2010-04-05 16:24:45 +02:00
Jan Urbański
727670c269 Make some methods raise an exception in asynchronous mode
The methods changed are connection.commit(), rollback(), reset(),
set_isolation_level(), set_client_encoding(), lobject(), cursor(str)
as well as cursor.execute() and cursor.callproc() if another query is
in progress and cursor.executemany(), cursor.copy_{from,to,expert)().
2010-04-05 16:23:44 +02:00
Jan Urbański
01799e9137 Make asynchronous connections produce asynchronous cursors by default
Drop the async kwarg from cursor.execute(), cursors created by
asynchronous connections will be asynchronous by default, ones created
by synchronous connections will be synchronous.

Mind that this might break third party subclasses of
psycopg2.extensions.cursor, if they try to chain to the superclass in
their execute() implementation and are passing the async kwarg. The
example cursors in psycopg2.extras have been fixed no to do that.
2010-04-05 11:41:32 +02:00
Jan Urbański
d8ab5ac8a1 Make asynchronous connections always use autocommit
Clients using async connections are expected to do their own
transaction management by sending (asynchronously) BEGIN and COMMIT
statements.
As a bonus, it allows to drop one step from the async connection
building, namely getting the default isolation level from the server.
2010-04-05 11:37:06 +02:00
Jan Urbański
062a9602ae Ref the async cursor before storing it in the connection 2010-04-05 11:36:09 +02:00
Jan Urbański
eb646f71fa Add tests for the asynchronous API 2010-04-05 11:32:03 +02:00
Jan Urbański
91ef0e09ed Change the API for asynchronous queries to use cursor.poll()
The isread() API was not safe, because the query might have not been
sent fully to the server after calling execute(). To make the async
API complete, a similar mechanism to async connections must be used.

The cursor now has a poll() method that you would use identically to
the poll() method of the connection class.
2010-04-05 11:31:50 +02:00
Jan Urbański
9b259a8a54 Disallow some methods depending on the connection's sync/async mode 2010-04-05 11:31:37 +02:00
Federico Di Gregorio
34317dc4c3 Support asynchronous connection building
After calling psycopg2.connect(dsn, async=True) you can poll the
connection that will tell you whether its file descriptor should be
waited on to become writable or readable or that the connection
attempt has succeeded.

Edited commit by Jan to not expose internal state in extensions.py.
2010-04-05 11:30:03 +02:00
Jan Urbański
1f6ffbba0f Block and clear the result of asynchronous queries where necessary
Remove the big loop in pq_fetch with the select() call, among
others. Code paths that don't support asynchronous queries should now
be adequately guarded.
2010-04-05 11:28:20 +02:00
Federico Di Gregorio
3d2c315049 Checks for pointers should be explicit, i.e., (ptr != NULL) 2010-04-05 11:27:34 +02:00
Jan Urbański
cc37fd1ea9 Add curs_get_last_result, a function to get the last result from a connection 2010-04-05 11:24:57 +02:00
Jan Urbański
75a0299a48 Add pq_flush, a function to flush the output buffer 2010-04-05 11:07:53 +02:00
Federico Di Gregorio
3f2c1f6489 /me does not like empty for loops 2010-04-05 11:07:19 +02:00
Jan Urbański
53748443d8 Make pq_clear_async clear the whole pending result and export it 2010-04-05 11:01:44 +02:00
Jan Urbański
e0d789466a Support large objects truncating.
The lobject.truncate(len=0) method will be available if psycopg2 has
been built against libpq from 8.3 or later (which is when the lobject
truncating support has been introduced).
2010-03-29 09:19:35 +02:00
Federico Di Gregorio
0edd520593 Preparing release 2.0.14 (final) 2010-03-13 21:15:50 +01:00
Federico Di Gregorio
b5373bd90a Merge remote branch 'piro/python2' into python2 2010-03-12 17:37:04 +01:00
Federico Di Gregorio
21a6a64fd1 Changed setup.py to detect PostgreSQL "alpha" versions 2010-03-11 22:42:00 +01:00
Daniele Varrazzo
99620c1454 A bunch of typo fixed in the docs 2010-03-03 18:43:24 +01:00
Federico Di Gregorio
855674faf1 Fixed Python 2.4 segfault related to decimal implementation 2010-02-28 20:52:03 +01:00
Daniele Varrazzo
17a4cc9f67 All the docs todo points dropped: todo list removed. 2010-02-26 01:10:15 +00:00
Daniele Varrazzo
140e6ad4f2 Added notes about stuff changed in ver. 2.0.14. 2010-02-26 01:09:08 +00:00
Daniele Varrazzo
97ced0d4f1 Use the default role for cross referencing Python objects. 2010-02-26 00:49:19 +00:00
Daniele Varrazzo
4412826556 Added documentation for the 'pool' module. 2010-02-26 00:46:23 +00:00
Federico Di Gregorio
3636bc4201 Release candidate 1 2010-02-22 19:45:48 +01:00
Federico Di Gregorio
b99f2d5f8e Added a couple more questions to the FAQ 2010-02-22 19:38:47 +01:00
Federico Di Gregorio
6733c64412 Varrazzo has two "r"! 2010-02-22 09:09:44 +01:00
Federico Di Gregorio
1b3e16e6fe MANIFEST.in does not prune docs/html/_sources anymore 2010-02-22 09:06:28 +01:00
Federico Di Gregorio
b46035c222 Merge remote branch 'remotes/piro/python2' into python2 2010-02-22 09:05:40 +01:00
Federico Di Gregorio
fd6d3185b4 Preparing release 2.0.14 2010-02-21 01:26:43 +01:00
Federico Di Gregorio
4712ad1550 Added documentation to project 2010-02-21 01:09:40 +01:00
Federico Di Gregorio
192034dc38 Fixed problem with decimal.Decimal conversions 2010-02-21 01:04:00 +01:00
Daniele Varrazzo
50f5daef8b Added FAQ section to the documentation. 2010-02-18 04:12:49 +00:00
Daniele Varrazzo
29feed31b6 Cleaned up parameters style from the docs. 2010-02-18 04:12:46 +00:00
Daniele Varrazzo
a320f25a2a Completed documentation for errorcodes module. 2010-02-16 00:38:44 +00:00