Avoid direct cross-module links in hstore_plperl and ltree_plpython, too.
Just turning the crank on the project started in commit d51924be8. These cases turn out to be exact subsets of the boilerplate needed for hstore_plpython. Discussion: <2652.1475512158@sss.pgh.pa.us>
This commit is contained in:
parent
fc76259f5b
commit
eda04886c1
@ -23,20 +23,20 @@ include $(top_builddir)/src/Makefile.global
|
||||
include $(top_srcdir)/contrib/contrib-global.mk
|
||||
endif
|
||||
|
||||
# In configurations that forbid undefined symbols in libraries, link with each
|
||||
# dependency. This does preclude pgxs builds.
|
||||
# We must link libperl explicitly
|
||||
ifeq ($(PORTNAME), aix)
|
||||
rpathdir = $(pkglibdir):$(perl_archlibexp)/CORE
|
||||
SHLIB_LINK += ../hstore/libhstore.exp $(perl_embed_ldflags)
|
||||
endif
|
||||
SHLIB_LINK += $(perl_embed_ldflags)
|
||||
else
|
||||
ifeq ($(PORTNAME), win32)
|
||||
# these settings are the same as for plperl
|
||||
override CPPFLAGS += -DPLPERL_HAVE_UID_GID -Wno-comment
|
||||
SHLIB_LINK += ../hstore/libhstore.a $(sort $(wildcard ../../src/pl/plperl/libperl*.a))
|
||||
# ... see silliness in plperl Makefile ...
|
||||
SHLIB_LINK += $(sort $(wildcard ../../src/pl/plperl/libperl*.a))
|
||||
else
|
||||
rpathdir = $(perl_archlibexp)/CORE
|
||||
SHLIB_LINK += $(perl_embed_ldflags)
|
||||
endif
|
||||
|
||||
ifeq ($(PORTNAME), cygwin)
|
||||
SHLIB_LINK += -L../hstore -l hstore $(perl_embed_ldflags)
|
||||
endif
|
||||
|
||||
# As with plperl we need to make sure that the CORE directory is included
|
||||
|
@ -3,11 +3,6 @@
|
||||
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||
\echo Use "CREATE EXTENSION hstore_plperl" to load this file. \quit
|
||||
|
||||
-- make sure the prerequisite libraries are loaded
|
||||
LOAD 'plperl';
|
||||
SELECT NULL::hstore;
|
||||
|
||||
|
||||
CREATE FUNCTION hstore_to_plperl(val internal) RETURNS internal
|
||||
LANGUAGE C STRICT IMMUTABLE
|
||||
AS 'MODULE_PATHNAME';
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "postgres.h"
|
||||
|
||||
#undef _
|
||||
|
||||
#include "fmgr.h"
|
||||
#include "plperl.h"
|
||||
#include "plperl_helpers.h"
|
||||
@ -7,6 +9,58 @@
|
||||
|
||||
PG_MODULE_MAGIC;
|
||||
|
||||
extern void _PG_init(void);
|
||||
|
||||
/* Linkage to functions in hstore module */
|
||||
typedef HStore *(*hstoreUpgrade_t) (Datum orig);
|
||||
static hstoreUpgrade_t hstoreUpgrade_p;
|
||||
typedef int (*hstoreUniquePairs_t) (Pairs *a, int32 l, int32 *buflen);
|
||||
static hstoreUniquePairs_t hstoreUniquePairs_p;
|
||||
typedef HStore *(*hstorePairs_t) (Pairs *pairs, int32 pcount, int32 buflen);
|
||||
static hstorePairs_t hstorePairs_p;
|
||||
typedef size_t (*hstoreCheckKeyLen_t) (size_t len);
|
||||
static hstoreCheckKeyLen_t hstoreCheckKeyLen_p;
|
||||
typedef size_t (*hstoreCheckValLen_t) (size_t len);
|
||||
static hstoreCheckValLen_t hstoreCheckValLen_p;
|
||||
|
||||
|
||||
/*
|
||||
* Module initialize function: fetch function pointers for cross-module calls.
|
||||
*/
|
||||
void
|
||||
_PG_init(void)
|
||||
{
|
||||
/* Asserts verify that typedefs above match original declarations */
|
||||
AssertVariableIsOfType(&hstoreUpgrade, hstoreUpgrade_t);
|
||||
hstoreUpgrade_p = (hstoreUpgrade_t)
|
||||
load_external_function("$libdir/hstore", "hstoreUpgrade",
|
||||
true, NULL);
|
||||
AssertVariableIsOfType(&hstoreUniquePairs, hstoreUniquePairs_t);
|
||||
hstoreUniquePairs_p = (hstoreUniquePairs_t)
|
||||
load_external_function("$libdir/hstore", "hstoreUniquePairs",
|
||||
true, NULL);
|
||||
AssertVariableIsOfType(&hstorePairs, hstorePairs_t);
|
||||
hstorePairs_p = (hstorePairs_t)
|
||||
load_external_function("$libdir/hstore", "hstorePairs",
|
||||
true, NULL);
|
||||
AssertVariableIsOfType(&hstoreCheckKeyLen, hstoreCheckKeyLen_t);
|
||||
hstoreCheckKeyLen_p = (hstoreCheckKeyLen_t)
|
||||
load_external_function("$libdir/hstore", "hstoreCheckKeyLen",
|
||||
true, NULL);
|
||||
AssertVariableIsOfType(&hstoreCheckValLen, hstoreCheckValLen_t);
|
||||
hstoreCheckValLen_p = (hstoreCheckValLen_t)
|
||||
load_external_function("$libdir/hstore", "hstoreCheckValLen",
|
||||
true, NULL);
|
||||
}
|
||||
|
||||
|
||||
/* These defines must be after the module init function */
|
||||
#define hstoreUpgrade hstoreUpgrade_p
|
||||
#define hstoreUniquePairs hstoreUniquePairs_p
|
||||
#define hstorePairs hstorePairs_p
|
||||
#define hstoreCheckKeyLen hstoreCheckKeyLen_p
|
||||
#define hstoreCheckValLen hstoreCheckValLen_p
|
||||
|
||||
|
||||
PG_FUNCTION_INFO_V1(hstore_to_plperl);
|
||||
|
||||
|
@ -3,11 +3,6 @@
|
||||
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||
\echo Use "CREATE EXTENSION hstore_plperlu" to load this file. \quit
|
||||
|
||||
-- make sure the prerequisite libraries are loaded
|
||||
LOAD 'plperl';
|
||||
SELECT NULL::hstore;
|
||||
|
||||
|
||||
CREATE FUNCTION hstore_to_plperlu(val internal) RETURNS internal
|
||||
LANGUAGE C STRICT IMMUTABLE
|
||||
AS 'MODULE_PATHNAME', 'hstore_to_plperl';
|
||||
|
@ -4,7 +4,7 @@ MODULE_big = ltree_plpython$(python_majorversion)
|
||||
OBJS = ltree_plpython.o $(WIN32RES)
|
||||
PGFILEDESC = "ltree_plpython - ltree transform for plpython"
|
||||
|
||||
PG_CPPFLAGS = -I$(top_srcdir)/src/pl/plpython $(python_includespec) -I$(top_srcdir)/contrib/ltree
|
||||
PG_CPPFLAGS = -I$(top_srcdir)/src/pl/plpython $(python_includespec) -I$(top_srcdir)/contrib/ltree -DPLPYTHON_LIBNAME='"plpython$(python_majorversion)"'
|
||||
|
||||
EXTENSION = ltree_plpythonu ltree_plpython2u ltree_plpython3u
|
||||
DATA = ltree_plpythonu--1.0.sql ltree_plpython2u--1.0.sql ltree_plpython3u--1.0.sql
|
||||
@ -23,19 +23,18 @@ include $(top_builddir)/src/Makefile.global
|
||||
include $(top_srcdir)/contrib/contrib-global.mk
|
||||
endif
|
||||
|
||||
# In configurations that forbid undefined symbols in libraries, link with each
|
||||
# dependency. This does preclude pgxs builds.
|
||||
# We must link libpython explicitly
|
||||
ifeq ($(PORTNAME), aix)
|
||||
rpathdir = $(pkglibdir):$(python_libdir)
|
||||
SHLIB_LINK += $(python_libspec) $(python_additional_libs) $(sort $(wildcard ../../src/pl/plpython/libplpython*.exp))
|
||||
endif
|
||||
SHLIB_LINK += $(python_libspec) $(python_additional_libs)
|
||||
else
|
||||
ifeq ($(PORTNAME), win32)
|
||||
SHLIB_LINK += $(sort $(wildcard ../../src/pl/plpython/libpython*.a)) $(sort $(wildcard ../../src/pl/plpython/libplpython*.a))
|
||||
# ... see silliness in plpython Makefile ...
|
||||
SHLIB_LINK += $(sort $(wildcard ../../src/pl/plpython/libpython*.a))
|
||||
else
|
||||
rpathdir = $(python_libdir)
|
||||
SHLIB_LINK += $(python_libspec)
|
||||
endif
|
||||
|
||||
ifeq ($(PORTNAME), cygwin)
|
||||
SHLIB_LINK += -L../ltree -lltree -L../../src/pl/plpython \
|
||||
-lplpython$(python_majorversion) $(python_libspec)
|
||||
endif
|
||||
|
||||
REGRESS_OPTS += --load-extension=ltree
|
||||
|
@ -1,10 +1,39 @@
|
||||
#include "postgres.h"
|
||||
|
||||
#include "fmgr.h"
|
||||
#include "plpython.h"
|
||||
#include "ltree.h"
|
||||
|
||||
PG_MODULE_MAGIC;
|
||||
|
||||
extern void _PG_init(void);
|
||||
|
||||
/* Linkage to functions in plpython module */
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
typedef PyObject *(*PLyUnicode_FromStringAndSize_t) (const char *s, Py_ssize_t size);
|
||||
static PLyUnicode_FromStringAndSize_t PLyUnicode_FromStringAndSize_p;
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Module initialize function: fetch function pointers for cross-module calls.
|
||||
*/
|
||||
void
|
||||
_PG_init(void)
|
||||
{
|
||||
/* Asserts verify that typedefs above match original declarations */
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
AssertVariableIsOfType(&PLyUnicode_FromStringAndSize, PLyUnicode_FromStringAndSize_t);
|
||||
PLyUnicode_FromStringAndSize_p = (PLyUnicode_FromStringAndSize_t)
|
||||
load_external_function("$libdir/" PLPYTHON_LIBNAME, "PLyUnicode_FromStringAndSize",
|
||||
true, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* These defines must be after the module init function */
|
||||
#define PLyUnicode_FromStringAndSize PLyUnicode_FromStringAndSize_p
|
||||
|
||||
|
||||
PG_FUNCTION_INFO_V1(ltree_to_plpython);
|
||||
|
||||
|
@ -3,11 +3,6 @@
|
||||
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||
\echo Use "CREATE EXTENSION ltree_plpython2u" to load this file. \quit
|
||||
|
||||
-- make sure the prerequisite libraries are loaded
|
||||
LOAD 'plpython2';
|
||||
SELECT NULL::ltree;
|
||||
|
||||
|
||||
CREATE FUNCTION ltree_to_plpython2(val internal) RETURNS internal
|
||||
LANGUAGE C STRICT IMMUTABLE
|
||||
AS 'MODULE_PATHNAME', 'ltree_to_plpython';
|
||||
|
@ -3,11 +3,6 @@
|
||||
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||
\echo Use "CREATE EXTENSION ltree_plpython3u" to load this file. \quit
|
||||
|
||||
-- make sure the prerequisite libraries are loaded
|
||||
LOAD 'plpython3';
|
||||
SELECT NULL::ltree;
|
||||
|
||||
|
||||
CREATE FUNCTION ltree_to_plpython3(val internal) RETURNS internal
|
||||
LANGUAGE C STRICT IMMUTABLE
|
||||
AS 'MODULE_PATHNAME', 'ltree_to_plpython';
|
||||
|
@ -3,11 +3,6 @@
|
||||
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||
\echo Use "CREATE EXTENSION ltree_plpythonu" to load this file. \quit
|
||||
|
||||
-- make sure the prerequisite libraries are loaded
|
||||
LOAD 'plpython2'; -- change to plpython3 if that ever becomes the default
|
||||
SELECT NULL::ltree;
|
||||
|
||||
|
||||
CREATE FUNCTION ltree_to_plpython(val internal) RETURNS internal
|
||||
LANGUAGE C STRICT IMMUTABLE
|
||||
AS 'MODULE_PATHNAME';
|
||||
|
@ -480,10 +480,11 @@ sub mkvcbuild
|
||||
'plpython' . $pymajorver, 'src/pl/plpython',
|
||||
'hstore', 'contrib/hstore');
|
||||
$hstore_plpython->AddDefine('PLPYTHON_LIBNAME="plpython' . $pymajorver . '"');
|
||||
AddTransformModule(
|
||||
my $ltree_plpython = AddTransformModule(
|
||||
'ltree_plpython' . $pymajorver, 'contrib/ltree_plpython',
|
||||
'plpython' . $pymajorver, 'src/pl/plpython',
|
||||
'ltree', 'contrib/ltree');
|
||||
$ltree_plpython->AddDefine('PLPYTHON_LIBNAME="plpython' . $pymajorver . '"');
|
||||
}
|
||||
|
||||
if ($solution->{options}->{perl})
|
||||
|
Loading…
x
Reference in New Issue
Block a user