PostgreSQL Source Code
git master
Main Page
Namespaces
Data Structures
Files
File List
Globals
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
6
PG_MODULE_MAGIC
;
7
8
9
PG_FUNCTION_INFO_V1
(
ltree_to_plpython
);
10
11
Datum
12
ltree_to_plpython
(
PG_FUNCTION_ARGS
)
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
}
ltree_level::name
char name[FLEXIBLE_ARRAY_MEMBER]
Definition:
ltree.h:13
ltree_level::len
uint16 len
Definition:
ltree.h:12
PointerGetDatum
#define PointerGetDatum(X)
Definition:
postgres.h:564
PG_GETARG_LTREE
#define PG_GETARG_LTREE(x)
Definition:
ltree.h:168
plpython.h
ltree.h
ltree_to_plpython
Datum ltree_to_plpython(PG_FUNCTION_ARGS)
Definition:
ltree_plpython.c:12
LEVEL_NEXT
#define LEVEL_NEXT(x)
Definition:
ltree.h:17
ltree
Definition:
ltree.h:19
ltree_level
Definition:
ltree.h:10
ltree::numlevel
uint16 numlevel
Definition:
ltree.h:22
postgres.h
Datum
uintptr_t Datum
Definition:
postgres.h:374
PG_FREE_IF_COPY
#define PG_FREE_IF_COPY(ptr, n)
Definition:
fmgr.h:216
PG_FUNCTION_INFO_V1
PG_FUNCTION_INFO_V1(ltree_to_plpython)
sort-test.list
tuple list
Definition:
sort-test.py:11
LTREE_FIRST
#define LTREE_FIRST(x)
Definition:
ltree.h:27
i
int i
Definition:
preproc-comment.c:23
PG_FUNCTION_ARGS
#define PG_FUNCTION_ARGS
Definition:
fmgr.h:150
PG_MODULE_MAGIC
PG_MODULE_MAGIC
Definition:
ltree_plpython.c:6
fmgr.h
contrib
ltree_plpython
ltree_plpython.c
Generated on Sat Jun 4 2016 04:14:51 for PostgreSQL Source Code by
1.8.8