PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
plpy_planobject.c File Reference
#include "postgres.h"
#include "plpython.h"
#include "plpy_planobject.h"
#include "plpy_elog.h"
#include "utils/memutils.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 90 of file plpy_planobject.c.

References PLy_PlanType.

Referenced by PLy_spi_execute().

91 {
92  return ob->ob_type == &PLy_PlanType;
93 }
static PyTypeObject PLy_PlanType
static void PLy_plan_dealloc ( PyObject *  arg)
static

Definition at line 96 of file plpy_planobject.c.

References PLyPlanObject::mcxt, MemoryContextDelete(), NULL, PLyPlanObject::plan, and SPI_freeplan().

97 {
99 
100  if (ob->plan)
101  {
102  SPI_freeplan(ob->plan);
103  ob->plan = NULL;
104  }
105  if (ob->mcxt)
106  {
108  ob->mcxt = NULL;
109  }
110  arg->ob_type->tp_free(arg);
111 }
void MemoryContextDelete(MemoryContext context)
Definition: mcxt.c:200
PyObject_HEAD SPIPlanPtr plan
MemoryContext mcxt
#define NULL
Definition: c.h:226
int SPI_freeplan(SPIPlanPtr plan)
Definition: spi.c:608
void * arg
void PLy_plan_init_type ( void  )

Definition at line 65 of file plpy_planobject.c.

References elog, ERROR, and PLy_PlanType.

Referenced by PLy_init_plpy().

66 {
67  if (PyType_Ready(&PLy_PlanType) < 0)
68  elog(ERROR, "could not initialize PLy_PlanType");
69 }
#define ERROR
Definition: elog.h:43
static PyTypeObject PLy_PlanType
#define elog
Definition: elog.h:219
PyObject* PLy_plan_new ( void  )

Definition at line 72 of file plpy_planobject.c.

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

Referenced by PLy_spi_prepare().

73 {
74  PLyPlanObject *ob;
75 
76  if ((ob = PyObject_New(PLyPlanObject, &PLy_PlanType)) == NULL)
77  return NULL;
78 
79  ob->plan = NULL;
80  ob->nargs = 0;
81  ob->types = NULL;
82  ob->values = NULL;
83  ob->args = NULL;
84  ob->mcxt = NULL;
85 
86  return (PyObject *) ob;
87 }
PLyTypeInfo * args
static PyTypeObject PLy_PlanType
PyObject_HEAD SPIPlanPtr plan
MemoryContext mcxt
#define NULL
Definition: c.h:226
static PyObject * PLy_plan_status ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 115 of file plpy_planobject.c.

References NULL.

116 {
117  if (PyArg_ParseTuple(args, ":status"))
118  {
119  Py_INCREF(Py_True);
120  return Py_True;
121  /* return PyInt_FromLong(self->status); */
122  }
123  return NULL;
124 }
#define NULL
Definition: c.h:226

Variable Documentation

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

Definition at line 20 of file plpy_planobject.c.

PyMethodDef PLy_plan_methods[]
static
Initial value:
= {
{"status", PLy_plan_status, METH_VARARGS, NULL},
{NULL, NULL, 0, NULL}
}
static PyObject * PLy_plan_status(PyObject *self, PyObject *args)
#define NULL
Definition: c.h:226

Definition at line 24 of file plpy_planobject.c.

PyTypeObject PLy_PlanType
static

Definition at line 29 of file plpy_planobject.c.

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