PyObject *dict;
dict = PyDict_New();
+ if (!dict)
+ ereport(ERROR,
+ (errcode(ERRCODE_OUT_OF_MEMORY),
+ errmsg("out of memory")));
for (i = 0; i < count; i++)
{
ltree_level *curlevel;
list = PyList_New(in->numlevel);
+ if (!list)
+ ereport(ERROR,
+ (errcode(ERRCODE_OUT_OF_MEMORY),
+ errmsg("out of memory")));
curlevel = LTREE_FIRST(in);
for (i = 0; i < in->numlevel; i++)
Py_DECREF(ret->rows);
ret->rows = PyList_New(SPI_processed);
-
- PLy_input_setup_tuple(&cursor->result, SPI_tuptable->tupdesc,
- exec_ctx->curr_proc);
-
- for (i = 0; i < SPI_processed; i++)
+ if (!ret->rows)
{
- PyObject *row = PLy_input_from_tuple(&cursor->result,
- SPI_tuptable->vals[i],
- SPI_tuptable->tupdesc);
+ Py_DECREF(ret);
+ ret = NULL;
+ }
+ else
+ {
+ PLy_input_setup_tuple(&cursor->result, SPI_tuptable->tupdesc,
+ exec_ctx->curr_proc);
+
+ for (i = 0; i < SPI_processed; i++)
+ {
+ PyObject *row = PLy_input_from_tuple(&cursor->result,
+ SPI_tuptable->vals[i],
+ SPI_tuptable->tupdesc);
- PyList_SetItem(ret->rows, i, row);
+ PyList_SetItem(ret->rows, i, row);
+ }
}
}
PG_TRY();
{
args = PyList_New(proc->nargs);
+ if (!args)
+ return NULL;
+
for (i = 0; i < proc->nargs; i++)
{
PLyDatumToOb *arginfo = &proc->args[i];
{
pltdata = PyDict_New();
if (!pltdata)
- PLy_elog(ERROR, "could not create new dictionary while building trigger arguments");
+ return NULL;
pltname = PyString_FromString(tdata->tg_trigger->tgname);
PyDict_SetItemString(pltdata, "name", pltname);
PyObject *pltarg;
pltargs = PyList_New(tdata->tg_trigger->tgnargs);
+ if (!pltargs)
+ {
+ Py_DECREF(pltdata);
+ return NULL;
+ }
for (i = 0; i < tdata->tg_trigger->tgnargs; i++)
{
pltarg = PyString_FromString(tdata->tg_trigger->tgargs[i]);
PLy_interp_globals = PyModule_GetDict(mainmod);
PLy_interp_safe_globals = PyDict_New();
if (PLy_interp_safe_globals == NULL)
- PLy_elog(ERROR, "could not create globals");
+ PLy_elog(ERROR, NULL);
PyDict_SetItemString(PLy_interp_globals, "GD", PLy_interp_safe_globals);
Py_DECREF(mainmod);
if (PLy_interp_globals == NULL || PyErr_Occurred())
exc = PyErr_NewException(name, base, dict);
if (exc == NULL)
- PLy_elog(ERROR, "could not create exception \"%s\"", name);
+ PLy_elog(ERROR, NULL);
/*
* PyModule_AddObject does not add a refcount to the object, for some odd
PyObject *dict = PyDict_New();
if (dict == NULL)
- PLy_elog(ERROR, "could not generate SPI exceptions");
+ PLy_elog(ERROR, NULL);
sqlstate = PyString_FromString(unpack_sql_state(exception_map[i].sqlstate));
if (sqlstate == NULL)
* all functions
*/
proc->statics = PyDict_New();
+ if (!proc->statics)
+ PLy_elog(ERROR, NULL);
PyDict_SetItemString(proc->globals, "SD", proc->statics);
/*
ob->nrows = PyInt_FromLong(-1);
ob->rows = PyList_New(0);
ob->tupdesc = NULL;
+ if (!ob->rows)
+ {
+ Py_DECREF(ob);
+ return NULL;
+ }
return (PyObject *) ob;
}
}
list = PyList_New(ob->tupdesc->natts);
+ if (!list)
+ return NULL;
for (i = 0; i < ob->tupdesc->natts; i++)
{
Form_pg_attribute attr = TupleDescAttr(ob->tupdesc, i);
}
list = PyList_New(ob->tupdesc->natts);
+ if (!list)
+ return NULL;
for (i = 0; i < ob->tupdesc->natts; i++)
{
Form_pg_attribute attr = TupleDescAttr(ob->tupdesc, i);
}
list = PyList_New(ob->tupdesc->natts);
+ if (!list)
+ return NULL;
for (i = 0; i < ob->tupdesc->natts; i++)
{
Form_pg_attribute attr = TupleDescAttr(ob->tupdesc, i);
volatile MemoryContext oldcontext;
result = (PLyResultObject *) PLy_result_new();
+ if (!result)
+ return NULL;
Py_DECREF(result->status);
result->status = PyInt_FromLong(status);
Py_DECREF(result->rows);
result->rows = PyList_New(rows);
-
- PLy_input_setup_tuple(&ininfo, tuptable->tupdesc,
- exec_ctx->curr_proc);
-
- for (i = 0; i < rows; i++)
+ if (!result->rows)
{
- PyObject *row = PLy_input_from_tuple(&ininfo,
- tuptable->vals[i],
- tuptable->tupdesc);
+ Py_DECREF(result);
+ result = NULL;
+ }
+ else
+ {
+ PLy_input_setup_tuple(&ininfo, tuptable->tupdesc,
+ exec_ctx->curr_proc);
+
+ for (i = 0; i < rows; i++)
+ {
+ PyObject *row = PLy_input_from_tuple(&ininfo,
+ tuptable->vals[i],
+ tuptable->tupdesc);
- PyList_SetItem(result->rows, i, row);
+ PyList_SetItem(result->rows, i, row);
+ }
}
}
PyObject *list;
list = PyList_New(dims[dim]);
+ if (!list)
+ return NULL;
if (dim < ndim - 1)
{
dict = PyDict_New();
if (dict == NULL)
- PLy_elog(ERROR, "could not create new dictionary");
+ return NULL;
PG_TRY();
{