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

66 {
67  return ob->ob_type == &PLy_PlanType;
68 }
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 90 of file plpy_planobject.c.

91 {
92  PyObject *planargs = NULL;
93 
94  if (!PyArg_ParseTuple(args, "|O", &planargs))
95  return NULL;
96 
97  return PLy_cursor_plan(self, planargs);
98 }
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 71 of file plpy_planobject.c.

72 {
74 
75  if (ob->plan)
76  {
77  SPI_freeplan(ob->plan);
78  ob->plan = NULL;
79  }
80  if (ob->mcxt)
81  {
83  ob->mcxt = NULL;
84  }
85  arg->ob_type->tp_free(arg);
86 }
void MemoryContextDelete(MemoryContext context)
Definition: mcxt.c:454
void * arg
int SPI_freeplan(SPIPlanPtr plan)
Definition: spi.c:1025
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 102 of file plpy_planobject.c.

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

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 40 of file plpy_planobject.c.

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

References elog, ERROR, and PLy_PlanType.

Referenced by PLy_init_plpy().

◆ PLy_plan_new()

PyObject* PLy_plan_new ( void  )

Definition at line 47 of file plpy_planobject.c.

48 {
49  PLyPlanObject *ob;
50 
51  if ((ob = PyObject_New(PLyPlanObject, &PLy_PlanType)) == NULL)
52  return NULL;
53 
54  ob->plan = NULL;
55  ob->nargs = 0;
56  ob->types = NULL;
57  ob->values = NULL;
58  ob->args = NULL;
59  ob->mcxt = NULL;
60 
61  return (PyObject *) ob;
62 }
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 115 of file plpy_planobject.c.

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

References generate_unaccent_rules::args.

Variable Documentation

◆ PLy_plan_doc

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

Definition at line 20 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 22 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 29 of file plpy_planobject.c.

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