summaryrefslogtreecommitdiff
path: root/psycopg/cursor.h
diff options
context:
space:
mode:
Diffstat (limited to 'psycopg/cursor.h')
-rw-r--r--psycopg/cursor.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/psycopg/cursor.h b/psycopg/cursor.h
index 96ab6dd..5aab172 100644
--- a/psycopg/cursor.h
+++ b/psycopg/cursor.h
@@ -46,6 +46,7 @@ typedef struct {
long int columns; /* number of columns fetched from the db */
long int arraysize; /* how many rows should fetchmany() return */
long int row; /* the row counter for fetch*() operations */
+ long int mark; /* transaction marker, copied from conn */
PyObject *description; /* read-only attribute: sequence of 7-item
sequences.*/
@@ -65,9 +66,11 @@ typedef struct {
PyObject *tuple_factory; /* factory for result tuples */
PyObject *tzinfo_factory; /* factory for tzinfo objects */
+ PyObject *query; /* last query executed */
+
char *qattr; /* quoting attr, used when quoting strings */
char *notice; /* a notice from the backend */
- char *query; /* last query executed */
+ char *name; /* this cursor name */
PyObject *string_types; /* a set of typecasters for string types */
PyObject *binary_types; /* a set of typecasters for binary types */
@@ -83,10 +86,16 @@ if ((self)->closed || ((self)->conn && (self)->conn->closed)) { \
PyErr_SetString(InterfaceError, "cursor already closed"); \
return NULL; }
-#define EXC_IF_NO_TUPLES(self) if ((self)->notuples) { \
+#define EXC_IF_NO_TUPLES(self) \
+if ((self)->notuples && (self)->name == NULL) { \
PyErr_SetString(ProgrammingError, "no results to fetch"); \
return NULL; }
+#define EXC_IF_NO_MARK(self) \
+if ((self)->mark != (self)->conn->mark) { \
+ PyErr_SetString(ProgrammingError, "named cursor isn't valid anymore"); \
+ return NULL; }
+
#ifdef __cplusplus
}
#endif