diff options
| author | Jan UrbaĆski <wulczer@wulczer.org> | 2010-03-31 01:50:21 +0200 |
|---|---|---|
| committer | Federico Di Gregorio <fog@initd.org> | 2010-04-05 16:23:44 +0200 |
| commit | 727670c26906c1f61b08ee5686953d36a8fae170 (patch) | |
| tree | 1b7a722463ad7c94b184d4865b6c84c89bc34822 /psycopg/cursor.h | |
| parent | 01799e9137077e56220425faa245fdf5ac3a30e9 (diff) | |
| download | psycopg2-727670c26906c1f61b08ee5686953d36a8fae170.tar.gz | |
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)().
Diffstat (limited to 'psycopg/cursor.h')
| -rw-r--r-- | psycopg/cursor.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/psycopg/cursor.h b/psycopg/cursor.h index bcfc81f..a2293a0 100644 --- a/psycopg/cursor.h +++ b/psycopg/cursor.h @@ -106,6 +106,17 @@ if ((self)->mark != (self)->conn->mark) { \ PyErr_SetString(ProgrammingError, "named cursor isn't valid anymore"); \ return NULL; } +#define EXC_IF_CURS_ASYNC(self, cmd) if ((self)->conn->async == 1) { \ + PyErr_SetString(ProgrammingError, #cmd " cannot be used " \ + "in asynchronous mode"); \ + return NULL; } + +#define EXC_IF_ASYNC_IN_PROGRESS(self, cmd) \ +if ((self)->conn->async_cursor != NULL) { \ + PyErr_SetString(ProgrammingError, #cmd " cannot be used " \ + "while an asynchronous query is underway"); \ + return NULL; } + #ifdef __cplusplus } #endif |
