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_cursorobject.h"
#include "plpy_elog.h"
#include "plpy_spi.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_cursor (PyObject *self, PyObject *args)
 
static PyObject * PLy_plan_execute (PyObject *self, PyObject *args)
 
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 96 of file plpy_planobject.c.

References PLy_PlanType.

Referenced by PLy_spi_execute().

97 {
98  return ob->ob_type == &PLy_PlanType;
99 }
static PyTypeObject PLy_PlanType
static PyObject * PLy_plan_cursor ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 121 of file plpy_planobject.c.

References NULL, and PLy_cursor_plan().

122 {
123  PyObject *planargs = NULL;
124 
125  if (!PyArg_ParseTuple(args, "|O", &planargs))
126  return NULL;
127 
128  return PLy_cursor_plan(self, planargs);
129 }
#define NULL
Definition: c.h:229
PyObject * PLy_cursor_plan(PyObject *ob, PyObject *args)
static void PLy_plan_dealloc ( PyObject *  arg)
static

Definition at line 102 of file plpy_planobject.c.

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

103 {
104  PLyPlanObject *ob = (PLyPlanObject *) arg;
105 
106  if (ob->plan)
107  {
108  SPI_freeplan(ob->plan);
109  ob->plan = NULL;
110  }
111  if (ob->mcxt)
112  {
114  ob->mcxt = NULL;
115  }
116  arg->ob_type->tp_free(arg);
117 }
void MemoryContextDelete(MemoryContext context)
Definition: mcxt.c:200
PyObject_HEAD SPIPlanPtr plan
MemoryContext mcxt
#define NULL
Definition: c.h:229
int SPI_freeplan(SPIPlanPtr plan)
Definition: spi.c:609
void * arg
static PyObject * PLy_plan_execute ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 133 of file plpy_planobject.c.

References sort-test::list, NULL, and PLy_spi_execute_plan().

134 {
135  PyObject *list = NULL;
136  long limit = 0;
137 
138  if (!PyArg_ParseTuple(args, "|Ol", &list, &limit))
139  return NULL;
140 
141  return PLy_spi_execute_plan(self, list, limit);
142 }
PyObject * PLy_spi_execute_plan(PyObject *ob, PyObject *list, long limit)
Definition: plpy_spi.c:196
#define NULL
Definition: c.h:229
tuple list
Definition: sort-test.py:11
void PLy_plan_init_type ( void  )

Definition at line 71 of file plpy_planobject.c.

References elog, ERROR, and PLy_PlanType.

Referenced by PLy_init_plpy().

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

Definition at line 78 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().

79 {
80  PLyPlanObject *ob;
81 
82  if ((ob = PyObject_New(PLyPlanObject, &PLy_PlanType)) == NULL)
83  return NULL;
84 
85  ob->plan = NULL;
86  ob->nargs = 0;
87  ob->types = NULL;
88  ob->values = NULL;
89  ob->args = NULL;
90  ob->mcxt = NULL;
91 
92  return (PyObject *) ob;
93 }
PLyTypeInfo * args
static PyTypeObject PLy_PlanType
PyObject_HEAD SPIPlanPtr plan
MemoryContext mcxt
#define NULL
Definition: c.h:229
static PyObject * PLy_plan_status ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 146 of file plpy_planobject.c.

References NULL.

147 {
148  if (PyArg_ParseTuple(args, ":status"))
149  {
150  Py_INCREF(Py_True);
151  return Py_True;
152  /* return PyInt_FromLong(self->status); */
153  }
154  return NULL;
155 }
#define NULL
Definition: c.h:229

Variable Documentation

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

Definition at line 24 of file plpy_planobject.c.

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

Definition at line 28 of file plpy_planobject.c.

PyTypeObject PLy_PlanType
static

Definition at line 35 of file plpy_planobject.c.

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