Skip to content

Commit 3f44e3d

Browse files
committed
Transforms for jsonb to PL/Python
Add a new contrib module jsonb_plpython that provide a transform between jsonb and PL/Python. jsonb values are converted to appropriate Python types such as dicts and lists, and vice versa. Author: Anthony Bykov <a.bykov@postgrespro.ru> Reviewed-by: Aleksander Alekseev <a.alekseev@postgrespro.ru> Reviewed-by: Nikita Glukhov <n.gluhov@postgrespro.ru>
1 parent a437551 commit 3f44e3d

13 files changed

+1155
-2
lines changed

contrib/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ ALWAYS_SUBDIRS += hstore_plperl
8181
endif
8282

8383
ifeq ($(with_python),yes)
84-
SUBDIRS += hstore_plpython ltree_plpython
84+
SUBDIRS += hstore_plpython jsonb_plpython ltree_plpython
8585
else
86-
ALWAYS_SUBDIRS += hstore_plpython ltree_plpython
86+
ALWAYS_SUBDIRS += hstore_plpython jsonb_plpython ltree_plpython
8787
endif
8888

8989
# Missing:

contrib/jsonb_plpython/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Generated subdirectories
2+
/expected/python3/
3+
/log/
4+
/results/
5+
/sql/python3/
6+
/tmp_check/

contrib/jsonb_plpython/Makefile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# contrib/jsonb_plpython/Makefile
2+
3+
MODULE_big = jsonb_plpython$(python_majorversion)
4+
OBJS = jsonb_plpython.o $(WIN32RES)
5+
PGFILEDESC = "jsonb_plpython - transform between jsonb and plpythonu"
6+
7+
PG_CPPFLAGS = -I$(top_srcdir)/src/pl/plpython $(python_includespec) -DPLPYTHON_LIBNAME='"plpython$(python_majorversion)"'
8+
9+
EXTENSION = jsonb_plpythonu jsonb_plpython2u jsonb_plpython3u
10+
DATA = jsonb_plpythonu--1.0.sql jsonb_plpython2u--1.0.sql jsonb_plpython3u--1.0.sql
11+
12+
REGRESS = jsonb_plpython
13+
REGRESS_PLPYTHON3_MANGLE := $(REGRESS)
14+
15+
ifdef USE_PGXS
16+
PG_CONFIG = pg_config
17+
PGXS := $(shell $(PG_CONFIG) --pgxs)
18+
include $(PGXS)
19+
else
20+
subdir = contrib/jsonb_plpython
21+
top_builddir = ../..
22+
include $(top_builddir)/src/Makefile.global
23+
include $(top_srcdir)/contrib/contrib-global.mk
24+
endif
25+
26+
# We must link libpython explicitly
27+
ifeq ($(PORTNAME), win32)
28+
# ... see silliness in plpython Makefile ...
29+
SHLIB_LINK += $(sort $(wildcard ../../src/pl/plpython/libpython*.a))
30+
else
31+
rpathdir = $(python_libdir)
32+
SHLIB_LINK += $(python_libspec) $(python_additional_libs)
33+
endif
34+
35+
ifeq ($(python_majorversion),2)
36+
REGRESS_OPTS += --load-extension=plpythonu --load-extension=jsonb_plpythonu
37+
endif
38+
39+
include $(top_srcdir)/src/pl/plpython/regress-python3-mangle.mk

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy