Dropped large object support when psycopg is in green mode.

Async mode and large object are not compatible, albeit I haven't found
an authoritative source yet.
This commit is contained in:
Daniele Varrazzo 2010-05-09 20:34:02 +01:00
parent 2596cf7125
commit e29424a230
5 changed files with 13 additions and 8 deletions

View File

@ -435,6 +435,9 @@ callback (using `!select()` to block) is provided as
:ref:`COPY commands <copy>` are currently not supported when a wait callback :ref:`COPY commands <copy>` are currently not supported when a wait callback
is registered, but they will be probably implemented in a future release. is registered, but they will be probably implemented in a future release.
:ref:`Large objects <large-objects>` are not supported either: they are
not compatible with asynchronous connections.
.. testcode:: .. testcode::
:hide: :hide:

View File

@ -39,6 +39,7 @@
#include "psycopg/cursor.h" #include "psycopg/cursor.h"
#include "psycopg/pqpath.h" #include "psycopg/pqpath.h"
#include "psycopg/lobject.h" #include "psycopg/lobject.h"
#include "psycopg/green.h"
/** DBAPI methods **/ /** DBAPI methods **/
@ -314,6 +315,7 @@ psyco_conn_lobject(connectionObject *self, PyObject *args, PyObject *keywds)
EXC_IF_CONN_CLOSED(self); EXC_IF_CONN_CLOSED(self);
EXC_IF_CONN_ASYNC(self, lobject); EXC_IF_CONN_ASYNC(self, lobject);
EXC_IF_GREEN(lobject);
Dprintf("psyco_conn_lobject: new lobject for connection at %p", self); Dprintf("psyco_conn_lobject: new lobject for connection at %p", self);
Dprintf("psyco_conn_lobject: parameters: oid = %d, mode = %s", Dprintf("psyco_conn_lobject: parameters: oid = %d, mode = %s",

View File

@ -113,12 +113,6 @@ if ((self)->conn->async_cursor != NULL) { \
"while an asynchronous query is underway"); \ "while an asynchronous query is underway"); \
return NULL; } return NULL; }
#define EXC_IF_GREEN(cmd) \
if (psyco_green()) { \
PyErr_SetString(PyExc_NotImplementedError, #cmd " cannot be used " \
"with an asynchronous callback (yet)."); \
return NULL; }
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -62,6 +62,12 @@ HIDDEN int psyco_green(void);
HIDDEN int psyco_wait(connectionObject *conn); HIDDEN int psyco_wait(connectionObject *conn);
HIDDEN PGresult *psyco_exec_green(connectionObject *conn, const char *command); HIDDEN PGresult *psyco_exec_green(connectionObject *conn, const char *command);
#define EXC_IF_GREEN(cmd) \
if (psyco_green()) { \
PyErr_SetString(ProgrammingError, #cmd " cannot be used " \
"with an asynchronous callback."); \
return NULL; }
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -50,13 +50,13 @@ def test_suite():
suite.addTest(test_transaction.test_suite()) suite.addTest(test_transaction.test_suite())
suite.addTest(types_basic.test_suite()) suite.addTest(types_basic.test_suite())
suite.addTest(types_extras.test_suite()) suite.addTest(types_extras.test_suite())
suite.addTest(test_lobject.test_suite())
if not green: if not green:
suite.addTest(test_lobject.test_suite())
suite.addTest(test_copy.test_suite()) suite.addTest(test_copy.test_suite())
else: else:
import warnings import warnings
warnings.warn("copy not implemented in green mode: skipping tests") warnings.warn("copy/lobjects not implemented in green mode: skipping tests")
suite.addTest(test_notify.test_suite()) suite.addTest(test_notify.test_suite())
suite.addTest(test_async.test_suite()) suite.addTest(test_async.test_suite())