PostgreSQL Source Code  git master
plpy_planobject.c File Reference
#include "postgres.h"
#include "plpy_cursorobject.h"
#include "plpy_elog.h"
#include "plpy_planobject.h"
#include "plpy_spi.h"
#include "plpython.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 [] = "Store a PostgreSQL plan"
 
static PyMethodDef PLy_plan_methods []
 
static PyTypeObject PLy_PlanType
 

Function Documentation

◆ is_PLyPlanObject()

bool is_PLyPlanObject ( PyObject *  ob)

Definition at line 66 of file plpy_planobject.c.

67 {
68  return ob->ob_type == &PLy_PlanType;
69 }
static PyTypeObject PLy_PlanType

References PLy_PlanType.

Referenced by PLy_spi_execute().

◆ PLy_plan_cursor()

static PyObject * PLy_plan_cursor ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 91 of file plpy_planobject.c.

92 {
93  PyObject *planargs = NULL;
94 
95  if (!PyArg_ParseTuple(args, "|O", &planargs))
96  return NULL;
97 
98  return PLy_cursor_plan(self, planargs);
99 }
PyObject * PLy_cursor_plan(PyObject *ob, PyObject *args)

References generate_unaccent_rules::args, and PLy_cursor_plan().

◆ PLy_plan_dealloc()

static void PLy_plan_dealloc ( PyObject *  arg)
static

Definition at line 72 of file plpy_planobject.c.

73 {
75 
76  if (ob->plan)
77  {
78  SPI_freeplan(ob->plan);
79  ob->plan = NULL;
80  }
81  if (ob->mcxt)
82  {
84  ob->mcxt = NULL;
85  }
86  arg->ob_type->tp_free(arg);
87 }
void MemoryContextDelete(MemoryContext context)
Definition: mcxt.c:454
void * arg
int SPI_freeplan(SPIPlanPtr plan)
Definition: spi.c:1022
PyObject_HEAD SPIPlanPtr plan
MemoryContext mcxt

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

◆ PLy_plan_execute()

static PyObject * PLy_plan_execute ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 103 of file plpy_planobject.c.

104 {
105  PyObject *list = NULL;
106  long limit = 0;
107 
108  if (!PyArg_ParseTuple(args, "|Ol", &list, &limit))
109  return NULL;
110 
111  return PLy_spi_execute_plan(self, list, limit);
112 }
PyObject * PLy_spi_execute_plan(PyObject *ob, PyObject *list, long limit)
Definition: plpy_spi.c:175

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

◆ PLy_plan_init_type()

void PLy_plan_init_type ( void  )

Definition at line 41 of file plpy_planobject.c.

42 {
43  if (PyType_Ready(&PLy_PlanType) < 0)
44  elog(ERROR, "could not initialize PLy_PlanType");
45 }
#define ERROR
Definition: elog.h:39
#define elog(elevel,...)
Definition: elog.h:224

References elog, ERROR, and PLy_PlanType.

Referenced by PLy_init_plpy().

◆ PLy_plan_new()

PyObject* PLy_plan_new ( void  )

Definition at line 48 of file plpy_planobject.c.

49 {
50  PLyPlanObject *ob;
51 
52  if ((ob = PyObject_New(PLyPlanObject, &PLy_PlanType)) == NULL)
53  return NULL;
54 
55  ob->plan = NULL;
56  ob->nargs = 0;
57  ob->types = NULL;
58  ob->values = NULL;
59  ob->args = NULL;
60  ob->mcxt = NULL;
61 
62  return (PyObject *) ob;
63 }
PLyObToDatum * args

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

Referenced by PLy_spi_prepare().

◆ PLy_plan_status()

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

Definition at line 116 of file plpy_planobject.c.

117 {
118  if (PyArg_ParseTuple(args, ":status"))
119  {
120  Py_INCREF(Py_True);
121  return Py_True;
122  /* return PyLong_FromLong(self->status); */
123  }
124  return NULL;
125 }

References generate_unaccent_rules::args.

Variable Documentation

◆ PLy_plan_doc

char PLy_plan_doc[] = "Store a PostgreSQL plan"
static

Definition at line 21 of file plpy_planobject.c.

◆ PLy_plan_methods

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_cursor(PyObject *self, PyObject *args)
static PyObject * PLy_plan_execute(PyObject *self, PyObject *args)

Definition at line 23 of file plpy_planobject.c.

◆ PLy_PlanType

PyTypeObject PLy_PlanType
static
Initial value:
= {
PyVarObject_HEAD_INIT(NULL, 0)
.tp_name = "PLyPlan",
.tp_basicsize = sizeof(PLyPlanObject),
.tp_dealloc = PLy_plan_dealloc,
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
.tp_doc = PLy_plan_doc,
.tp_methods = PLy_plan_methods,
}
static void PLy_plan_dealloc(PyObject *arg)
static char PLy_plan_doc[]
static PyMethodDef PLy_plan_methods[]
struct PLyPlanObject PLyPlanObject

Definition at line 30 of file plpy_planobject.c.

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