PostgreSQL Source Code git master
Loading...
Searching...
No Matches
ltree_plpython.c
Go to the documentation of this file.
1#include "postgres.h"
2
3#include "fmgr.h"
4#include "ltree/ltree.h"
5#include "plpy_util.h"
6
8 .name = "ltree_plpython",
9 .version = PG_VERSION
10);
11
12/* Linkage to functions in plpython module */
13typedef PyObject *(*PLyUnicode_FromStringAndSize_t) (const char *s, Py_ssize_t size);
15
16/* Static asserts verify that typedefs above match original declarations */
18
19
20/*
21 * Module initialize function: fetch function pointers for cross-module calls.
22 */
23void
25{
27 load_external_function("$libdir/" PLPYTHON_LIBNAME, "PLyUnicode_FromStringAndSize",
28 true, NULL);
29}
30
31
32/* These defines must be after the module init function */
33#define PLyUnicode_FromStringAndSize PLyUnicode_FromStringAndSize_p
34
35
37
40{
41 ltree *in = PG_GETARG_LTREE_P(0);
42 int i;
43 PyObject *list;
45
46 list = PyList_New(in->numlevel);
47 if (!list)
50 errmsg("out of memory")));
51
53 for (i = 0; i < in->numlevel; i++)
54 {
57 }
58
59 PG_FREE_IF_COPY(in, 0);
60
61 return PointerGetDatum(list);
62}
#define StaticAssertVariableIsOfType(varname, typename)
Definition c.h:974
void * load_external_function(const char *filename, const char *funcname, bool signalNotFound, void **filehandle)
Definition dfmgr.c:95
int errcode(int sqlerrcode)
Definition elog.c:863
int errmsg(const char *fmt,...)
Definition elog.c:1080
#define ERROR
Definition elog.h:39
#define ereport(elevel,...)
Definition elog.h:150
#define PG_FREE_IF_COPY(ptr, n)
Definition fmgr.h:260
#define PG_MODULE_MAGIC_EXT(...)
Definition fmgr.h:540
#define PG_FUNCTION_INFO_V1(funcname)
Definition fmgr.h:417
#define PG_FUNCTION_ARGS
Definition fmgr.h:193
int i
Definition isn.c:77
#define LTREE_FIRST(x)
Definition ltree.h:51
#define LEVEL_NEXT(x)
Definition ltree.h:40
#define PG_GETARG_LTREE_P(n)
Definition ltree.h:221
#define PLyUnicode_FromStringAndSize
void _PG_init(void)
PyObject *(* PLyUnicode_FromStringAndSize_t)(const char *s, Py_ssize_t size)
static PLyUnicode_FromStringAndSize_t PLyUnicode_FromStringAndSize_p
Datum ltree_to_plpython(PG_FUNCTION_ARGS)
static Datum PointerGetDatum(const void *X)
Definition postgres.h:352
uint64_t Datum
Definition postgres.h:70
static int fb(int x)
Definition ltree.h:43
uint16 numlevel
Definition ltree.h:45
const char * name