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 "plpy_util.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 (PLyPlanObject *self)
 
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 PyType_Slot PLyPlan_slots []
 
static PyType_Spec PLyPlan_spec
 
static PyTypeObject * PLy_PlanType
 

Function Documentation

◆ is_PLyPlanObject()

bool is_PLyPlanObject ( PyObject *  ob)

Definition at line 85 of file plpy_planobject.c.

86{
87 return ob->ob_type == PLy_PlanType;
88}
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 117 of file plpy_planobject.c.

118{
119 PyObject *planargs = NULL;
120
121 if (!PyArg_ParseTuple(args, "|O", &planargs))
122 return NULL;
123
124 return PLy_cursor_plan(self, planargs);
125}
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 ( PLyPlanObject self)
static

Definition at line 91 of file plpy_planobject.c.

92{
93#if PY_VERSION_HEX >= 0x03080000
94 PyTypeObject *tp = Py_TYPE(self);
95#endif
96
97 if (self->plan)
98 {
99 SPI_freeplan(self->plan);
100 self->plan = NULL;
101 }
102 if (self->mcxt)
103 {
105 self->mcxt = NULL;
106 }
107
108 PyObject_Free(self);
109#if PY_VERSION_HEX >= 0x03080000
110 /* This was not needed before Python 3.8 (Python issue 35810) */
111 Py_DECREF(tp);
112#endif
113}
void MemoryContextDelete(MemoryContext context)
Definition: mcxt.c:485
int SPI_freeplan(SPIPlanPtr plan)
Definition: spi.c:1026
PyObject_HEAD SPIPlanPtr plan
MemoryContext mcxt

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

◆ PLy_plan_execute()

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

Definition at line 129 of file plpy_planobject.c.

130{
131 PyObject *list = NULL;
132 long limit = 0;
133
134 if (!PyArg_ParseTuple(args, "|Ol", &list, &limit))
135 return NULL;
136
137 return PLy_spi_execute_plan(self, list, limit);
138}
PyObject * PLy_spi_execute_plan(PyObject *ob, PyObject *list, long limit)
Definition: plpy_spi.c:171

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

57{
58 PLy_PlanType = (PyTypeObject *) PyType_FromSpec(&PLyPlan_spec);
59 if (!PLy_PlanType)
60 elog(ERROR, "could not initialize PLy_PlanType");
61}
#define ERROR
Definition: elog.h:39
#define elog(elevel,...)
Definition: elog.h:225
static PyType_Spec PLyPlan_spec

References elog, ERROR, PLy_PlanType, and PLyPlan_spec.

Referenced by PLy_init_plpy().

◆ PLy_plan_new()

PyObject * PLy_plan_new ( void  )

Definition at line 64 of file plpy_planobject.c.

65{
66 PLyPlanObject *ob;
67
68 if ((ob = PyObject_New(PLyPlanObject, PLy_PlanType)) == NULL)
69 return NULL;
70#if PY_VERSION_HEX < 0x03080000
71 /* Workaround for Python issue 35810; no longer necessary in Python 3.8 */
72 Py_INCREF(PLy_PlanType);
73#endif
74
75 ob->plan = NULL;
76 ob->nargs = 0;
77 ob->types = NULL;
78 ob->args = NULL;
79 ob->mcxt = NULL;
80
81 return (PyObject *) ob;
82}
PLyObToDatum * args

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

Referenced by PLy_spi_prepare().

◆ PLy_plan_status()

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

Definition at line 142 of file plpy_planobject.c.

143{
144 if (PyArg_ParseTuple(args, ":status"))
145 {
146 Py_INCREF(Py_True);
147 return Py_True;
148 /* return PyLong_FromLong(self->status); */
149 }
150 return NULL;
151}

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

Definition at line 53 of file plpy_planobject.c.

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

◆ PLyPlan_slots

PyType_Slot PLyPlan_slots[]
static
Initial value:
=
{
{
Py_tp_dealloc, PLy_plan_dealloc
},
{
Py_tp_doc, (char *) PLy_plan_doc
},
{
Py_tp_methods, PLy_plan_methods
},
{
0, NULL
}
}
static void PLy_plan_dealloc(PLyPlanObject *self)
static char PLy_plan_doc[]
static PyMethodDef PLy_plan_methods[]

Definition at line 29 of file plpy_planobject.c.

◆ PLyPlan_spec

PyType_Spec PLyPlan_spec
static
Initial value:
=
{
.name = "PLyPlan",
.basicsize = sizeof(PLyPlanObject),
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
.slots = PLyPlan_slots,
}
static PyType_Slot PLyPlan_slots[]
struct PLyPlanObject PLyPlanObject

Definition at line 45 of file plpy_planobject.c.

Referenced by PLy_plan_init_type().