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

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

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

71{
73
74 if (ob->plan)
75 {
76 SPI_freeplan(ob->plan);
77 ob->plan = NULL;
78 }
79 if (ob->mcxt)
80 {
82 ob->mcxt = NULL;
83 }
84 arg->ob_type->tp_free(arg);
85}
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 101 of file plpy_planobject.c.

102{
103 PyObject *list = NULL;
104 long limit = 0;
105
106 if (!PyArg_ParseTuple(args, "|Ol", &list, &limit))
107 return NULL;
108
109 return PLy_spi_execute_plan(self, list, limit);
110}
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 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->args = NULL;
58 ob->mcxt = NULL;
59
60 return (PyObject *) ob;
61}
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 114 of file plpy_planobject.c.

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

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().