0001-Fix-PLPython-metadata-access-when-there-is-no-result.patch
application/octet-stream
Filename: 0001-Fix-PLPython-metadata-access-when-there-is-no-result.patch
Type: application/octet-stream
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch 0001
Subject: Fix PLPython metadata access when there is no result
| File | + | − |
|---|---|---|
| src/pl/plpython/plpy_resultobject.c | 16 | 0 |
From 09fadb56135d87551d06fd17ba83cb945d157fe7 Mon Sep 17 00:00:00 2001
From: Jean-Baptiste Quenot <jbq@caraldi.com>
Date: Fri, 10 Feb 2012 15:41:54 +0100
Subject: [PATCH] Fix PLPython metadata access when there is no result
---
src/pl/plpython/plpy_resultobject.c | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/src/pl/plpython/plpy_resultobject.c b/src/pl/plpython/plpy_resultobject.c
index b25e808..4259642 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,11 @@ PLy_result_colnames(PyObject *self, PyObject *unused)
PyObject *list;
int i;
+ if (! ob->tupdesc) {
+ PLy_exception_set(PLy_exc_error, "no result fetched");
+ 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 +151,11 @@ PLy_result_coltypes(PyObject *self, PyObject *unused)
PyObject *list;
int i;
+ if (! ob->tupdesc) {
+ PLy_exception_set(PLy_exc_error, "no result fetched");
+ 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 +170,11 @@ PLy_result_coltypmods(PyObject *self, PyObject *unused)
PyObject *list;
int i;
+ if (! ob->tupdesc) {
+ PLy_exception_set(PLy_exc_error, "no result fetched");
+ 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));
--
1.7.4.1