Header And Logo

PostgreSQL
| The world's most advanced open source database.

Functions | Variables

plpy_planobject.c File Reference

#include "postgres.h"
#include "plpython.h"
#include "plpy_planobject.h"
#include "plpy_elog.h"
Include dependency graph for plpy_planobject.c:

Go to the source code of this file.

Functions

static void PLy_plan_dealloc (PyObject *arg)
static PyObject * PLy_plan_status (PyObject *self, PyObject *args)
void PLy_plan_init_type (void)
PyObject * PLy_plan_new (void)
bool is_PLyPlanObject (PyObject *ob)

Variables

static char PLy_plan_doc []
static PyMethodDef PLy_plan_methods []
static PyTypeObject PLy_PlanType

Function Documentation

bool is_PLyPlanObject ( PyObject *  ob  ) 

Definition at line 88 of file plpy_planobject.c.

References PLy_PlanType.

Referenced by PLy_spi_execute().

{
    return ob->ob_type == &PLy_PlanType;
}

static void PLy_plan_dealloc ( PyObject *  arg  )  [static]

Definition at line 94 of file plpy_planobject.c.

References PLyPlanObject::args, i, PLyPlanObject::nargs, PLyPlanObject::plan, PLy_free(), PLy_typeinfo_dealloc(), SPI_freeplan(), PLyPlanObject::types, and PLyPlanObject::values.

{
    PLyPlanObject *ob = (PLyPlanObject *) arg;

    if (ob->plan)
        SPI_freeplan(ob->plan);
    if (ob->types)
        PLy_free(ob->types);
    if (ob->values)
        PLy_free(ob->values);
    if (ob->args)
    {
        int         i;

        for (i = 0; i < ob->nargs; i++)
            PLy_typeinfo_dealloc(&ob->args[i]);
        PLy_free(ob->args);
    }

    arg->ob_type->tp_free(arg);
}

void PLy_plan_init_type ( void   ) 

Definition at line 64 of file plpy_planobject.c.

References elog, ERROR, and PLy_PlanType.

Referenced by PLy_init_plpy().

{
    if (PyType_Ready(&PLy_PlanType) < 0)
        elog(ERROR, "could not initialize PLy_PlanType");
}

PyObject* PLy_plan_new ( void   ) 

Definition at line 71 of file plpy_planobject.c.

References PLyPlanObject::args, PLyPlanObject::nargs, NULL, PLyPlanObject::plan, PLy_PlanType, PLyPlanObject::types, and PLyPlanObject::values.

Referenced by PLy_spi_prepare().

{
    PLyPlanObject *ob;

    if ((ob = PyObject_New(PLyPlanObject, &PLy_PlanType)) == NULL)
        return NULL;

    ob->plan = NULL;
    ob->nargs = 0;
    ob->types = NULL;
    ob->values = NULL;
    ob->args = NULL;

    return (PyObject *) ob;
}

static PyObject * PLy_plan_status ( PyObject *  self,
PyObject *  args 
) [static]

Definition at line 118 of file plpy_planobject.c.

References PLy_exc_error, and PLy_exception_set().

{
    if (PyArg_ParseTuple(args, ""))
    {
        Py_INCREF(Py_True);
        return Py_True;
        /* return PyInt_FromLong(self->status); */
    }
    PLy_exception_set(PLy_exc_error, "plan.status takes no arguments");
    return NULL;
}


Variable Documentation

char PLy_plan_doc[] [static]
Initial value:
 {
    "Store a PostgreSQL plan"
}

Definition at line 19 of file plpy_planobject.c.

PyMethodDef PLy_plan_methods[] [static]
Initial value:
 {
    {"status", PLy_plan_status, METH_VARARGS, NULL},
    {NULL, NULL, 0, NULL}
}

Definition at line 23 of file plpy_planobject.c.

PyTypeObject PLy_PlanType [static]

Definition at line 28 of file plpy_planobject.c.

Referenced by is_PLyPlanObject(), PLy_plan_init_type(), and PLy_plan_new().