summaryrefslogtreecommitdiff
path: root/src/pl/plpython/plpy_resultobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pl/plpython/plpy_resultobject.c')
-rw-r--r--src/pl/plpython/plpy_resultobject.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/pl/plpython/plpy_resultobject.c b/src/pl/plpython/plpy_resultobject.c
index b25e8083b9e..fcf8074228d 100644
--- a/src/pl/plpython/plpy_resultobject.c
+++ b/src/pl/plpython/plpy_resultobject.c
@@ -9,6 +9,7 @@
#include "plpython.h"
#include "plpy_resultobject.h"
+#include "plpy_elog.h"
static void PLy_result_dealloc(PyObject *arg);
@@ -131,6 +132,12 @@ PLy_result_colnames(PyObject *self, PyObject *unused)
PyObject *list;
int i;
+ if (!ob->tupdesc)
+ {
+ PLy_exception_set(PLy_exc_error, "command did not produce a result set");
+ return NULL;
+ }
+
list = PyList_New(ob->tupdesc->natts);
for (i = 0; i < ob->tupdesc->natts; i++)
PyList_SET_ITEM(list, i, PyString_FromString(NameStr(ob->tupdesc->attrs[i]->attname)));
@@ -145,6 +152,12 @@ PLy_result_coltypes(PyObject *self, PyObject *unused)
PyObject *list;
int i;
+ if (!ob->tupdesc)
+ {
+ PLy_exception_set(PLy_exc_error, "command did not produce a result set");
+ return NULL;
+ }
+
list = PyList_New(ob->tupdesc->natts);
for (i = 0; i < ob->tupdesc->natts; i++)
PyList_SET_ITEM(list, i, PyInt_FromLong(ob->tupdesc->attrs[i]->atttypid));
@@ -159,6 +172,12 @@ PLy_result_coltypmods(PyObject *self, PyObject *unused)
PyObject *list;
int i;
+ if (!ob->tupdesc)
+ {
+ PLy_exception_set(PLy_exc_error, "command did not produce a result set");
+ return NULL;
+ }
+
list = PyList_New(ob->tupdesc->natts);
for (i = 0; i < ob->tupdesc->natts; i++)
PyList_SET_ITEM(list, i, PyInt_FromLong(ob->tupdesc->attrs[i]->atttypmod));