From e29424a23037ebbd06358905982beff675ba6255 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Sun, 9 May 2010 20:34:02 +0100 Subject: [PATCH] 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. --- doc/src/advanced.rst | 3 +++ psycopg/connection_type.c | 2 ++ psycopg/cursor.h | 6 ------ psycopg/green.h | 6 ++++++ tests/__init__.py | 4 ++-- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/doc/src/advanced.rst b/doc/src/advanced.rst index 856808af..12a7ddcf 100644 --- a/doc/src/advanced.rst +++ b/doc/src/advanced.rst @@ -435,6 +435,9 @@ callback (using `!select()` to block) is provided as :ref:`COPY commands ` are currently not supported when a wait callback is registered, but they will be probably implemented in a future release. + :ref:`Large objects ` are not supported either: they are + not compatible with asynchronous connections. + .. testcode:: :hide: diff --git a/psycopg/connection_type.c b/psycopg/connection_type.c index af4d5e64..3e4bbddb 100644 --- a/psycopg/connection_type.c +++ b/psycopg/connection_type.c @@ -39,6 +39,7 @@ #include "psycopg/cursor.h" #include "psycopg/pqpath.h" #include "psycopg/lobject.h" +#include "psycopg/green.h" /** DBAPI methods **/ @@ -314,6 +315,7 @@ psyco_conn_lobject(connectionObject *self, PyObject *args, PyObject *keywds) EXC_IF_CONN_CLOSED(self); 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: parameters: oid = %d, mode = %s", diff --git a/psycopg/cursor.h b/psycopg/cursor.h index 6fff4ae3..96ca2b7c 100644 --- a/psycopg/cursor.h +++ b/psycopg/cursor.h @@ -113,12 +113,6 @@ if ((self)->conn->async_cursor != NULL) { \ "while an asynchronous query is underway"); \ 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 } #endif diff --git a/psycopg/green.h b/psycopg/green.h index 6466ae7c..5b6769df 100644 --- a/psycopg/green.h +++ b/psycopg/green.h @@ -62,6 +62,12 @@ HIDDEN int psyco_green(void); HIDDEN int psyco_wait(connectionObject *conn); 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 } #endif diff --git a/tests/__init__.py b/tests/__init__.py index eeeb5087..2b1ab226 100755 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -50,13 +50,13 @@ def test_suite(): suite.addTest(test_transaction.test_suite()) suite.addTest(types_basic.test_suite()) suite.addTest(types_extras.test_suite()) - suite.addTest(test_lobject.test_suite()) if not green: + suite.addTest(test_lobject.test_suite()) suite.addTest(test_copy.test_suite()) else: 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_async.test_suite())