PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
ltree_plpython.c
Go to the documentation of this file.
1 #include "postgres.h"
2 #include "fmgr.h"
3 #include "plpython.h"
4 #include "ltree.h"
5 
7 
8 
10 
11 Datum
13 {
14  ltree *in = PG_GETARG_LTREE(0);
15  int i;
16  PyObject *list;
17  ltree_level *curlevel;
18 
19  list = PyList_New(in->numlevel);
20 
21  curlevel = LTREE_FIRST(in);
22  for (i = 0; i < in->numlevel; i++)
23  {
24  PyList_SetItem(list, i, PyString_FromStringAndSize(curlevel->name, curlevel->len));
25  curlevel = LEVEL_NEXT(curlevel);
26  }
27 
28  PG_FREE_IF_COPY(in, 0);
29 
30  return PointerGetDatum(list);
31 }
char name[FLEXIBLE_ARRAY_MEMBER]
Definition: ltree.h:13
uint16 len
Definition: ltree.h:12
#define PointerGetDatum(X)
Definition: postgres.h:564
#define PG_GETARG_LTREE(x)
Definition: ltree.h:168
Datum ltree_to_plpython(PG_FUNCTION_ARGS)
#define LEVEL_NEXT(x)
Definition: ltree.h:17
Definition: ltree.h:19
uint16 numlevel
Definition: ltree.h:22
uintptr_t Datum
Definition: postgres.h:374
#define PG_FREE_IF_COPY(ptr, n)
Definition: fmgr.h:216
PG_FUNCTION_INFO_V1(ltree_to_plpython)
tuple list
Definition: sort-test.py:11
#define LTREE_FIRST(x)
Definition: ltree.h:27
int i
#define PG_FUNCTION_ARGS
Definition: fmgr.h:150
PG_MODULE_MAGIC
Definition: ltree_plpython.c:6