Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteda0488

Browse files
committed
Avoid direct cross-module links in hstore_plperl and ltree_plpython, too.
Just turning the crank on the project started in commitd51924b.These cases turn out to be exact subsets of the boilerplate neededfor hstore_plpython.Discussion: <2652.1475512158@sss.pgh.pa.us>
1 parentfc76259 commiteda0488

File tree

10 files changed

+102
-44
lines changed

10 files changed

+102
-44
lines changed

‎contrib/hstore_plperl/Makefile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@ include $(top_builddir)/src/Makefile.global
2323
include$(top_srcdir)/contrib/contrib-global.mk
2424
endif
2525

26-
# In configurations that forbid undefined symbols in libraries, link with each
27-
# dependency. This does preclude pgxs builds.
26+
# We must link libperl explicitly
2827
ifeq ($(PORTNAME), aix)
2928
rpathdir =$(pkglibdir):$(perl_archlibexp)/CORE
30-
SHLIB_LINK +=../hstore/libhstore.exp$(perl_embed_ldflags)
31-
endif
29+
SHLIB_LINK +=$(perl_embed_ldflags)
30+
else
3231
ifeq ($(PORTNAME), win32)
3332
# these settings are the same as for plperl
3433
overrideCPPFLAGS += -DPLPERL_HAVE_UID_GID -Wno-comment
35-
SHLIB_LINK += ../hstore/libhstore.a$(sort$(wildcard ../../src/pl/plperl/libperl*.a))
34+
# ... see silliness in plperl Makefile ...
35+
SHLIB_LINK +=$(sort$(wildcard ../../src/pl/plperl/libperl*.a))
36+
else
37+
rpathdir =$(perl_archlibexp)/CORE
38+
SHLIB_LINK +=$(perl_embed_ldflags)
3639
endif
37-
38-
ifeq ($(PORTNAME), cygwin)
39-
SHLIB_LINK += -L../hstore -l hstore$(perl_embed_ldflags)
4040
endif
4141

4242
# As with plperl we need to make sure that the CORE directory is included

‎contrib/hstore_plperl/hstore_plperl--1.0.sql

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
44
\echo Use"CREATE EXTENSION hstore_plperl" to load this file. \quit
55

6-
-- make sure the prerequisite libraries are loaded
7-
LOAD'plperl';
8-
SELECTNULL::hstore;
9-
10-
116
CREATEFUNCTIONhstore_to_plperl(val internal) RETURNS internal
127
LANGUAGE C STRICT IMMUTABLE
138
AS'MODULE_PATHNAME';

‎contrib/hstore_plperl/hstore_plperl.c

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,66 @@
11
#include"postgres.h"
2+
23
#undef _
4+
35
#include"fmgr.h"
46
#include"plperl.h"
57
#include"plperl_helpers.h"
68
#include"hstore.h"
79

810
PG_MODULE_MAGIC;
911

12+
externvoid_PG_init(void);
13+
14+
/* Linkage to functions in hstore module */
15+
typedefHStore*(*hstoreUpgrade_t) (Datumorig);
16+
statichstoreUpgrade_thstoreUpgrade_p;
17+
typedefint (*hstoreUniquePairs_t) (Pairs*a,int32l,int32*buflen);
18+
statichstoreUniquePairs_thstoreUniquePairs_p;
19+
typedefHStore*(*hstorePairs_t) (Pairs*pairs,int32pcount,int32buflen);
20+
statichstorePairs_thstorePairs_p;
21+
typedefsize_t (*hstoreCheckKeyLen_t) (size_tlen);
22+
statichstoreCheckKeyLen_thstoreCheckKeyLen_p;
23+
typedefsize_t (*hstoreCheckValLen_t) (size_tlen);
24+
statichstoreCheckValLen_thstoreCheckValLen_p;
25+
26+
27+
/*
28+
* Module initialize function: fetch function pointers for cross-module calls.
29+
*/
30+
void
31+
_PG_init(void)
32+
{
33+
/* Asserts verify that typedefs above match original declarations */
34+
AssertVariableIsOfType(&hstoreUpgrade,hstoreUpgrade_t);
35+
hstoreUpgrade_p= (hstoreUpgrade_t)
36+
load_external_function("$libdir/hstore","hstoreUpgrade",
37+
true,NULL);
38+
AssertVariableIsOfType(&hstoreUniquePairs,hstoreUniquePairs_t);
39+
hstoreUniquePairs_p= (hstoreUniquePairs_t)
40+
load_external_function("$libdir/hstore","hstoreUniquePairs",
41+
true,NULL);
42+
AssertVariableIsOfType(&hstorePairs,hstorePairs_t);
43+
hstorePairs_p= (hstorePairs_t)
44+
load_external_function("$libdir/hstore","hstorePairs",
45+
true,NULL);
46+
AssertVariableIsOfType(&hstoreCheckKeyLen,hstoreCheckKeyLen_t);
47+
hstoreCheckKeyLen_p= (hstoreCheckKeyLen_t)
48+
load_external_function("$libdir/hstore","hstoreCheckKeyLen",
49+
true,NULL);
50+
AssertVariableIsOfType(&hstoreCheckValLen,hstoreCheckValLen_t);
51+
hstoreCheckValLen_p= (hstoreCheckValLen_t)
52+
load_external_function("$libdir/hstore","hstoreCheckValLen",
53+
true,NULL);
54+
}
55+
56+
57+
/* These defines must be after the module init function */
58+
#definehstoreUpgrade hstoreUpgrade_p
59+
#definehstoreUniquePairs hstoreUniquePairs_p
60+
#definehstorePairs hstorePairs_p
61+
#definehstoreCheckKeyLen hstoreCheckKeyLen_p
62+
#definehstoreCheckValLen hstoreCheckValLen_p
63+
1064

1165
PG_FUNCTION_INFO_V1(hstore_to_plperl);
1266

‎contrib/hstore_plperl/hstore_plperlu--1.0.sql

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
44
\echo Use"CREATE EXTENSION hstore_plperlu" to load this file. \quit
55

6-
-- make sure the prerequisite libraries are loaded
7-
LOAD'plperl';
8-
SELECTNULL::hstore;
9-
10-
116
CREATEFUNCTIONhstore_to_plperlu(val internal) RETURNS internal
127
LANGUAGE C STRICT IMMUTABLE
138
AS'MODULE_PATHNAME','hstore_to_plperl';

‎contrib/ltree_plpython/Makefile

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ MODULE_big = ltree_plpython$(python_majorversion)
44
OBJS = ltree_plpython.o$(WIN32RES)
55
PGFILEDESC = "ltree_plpython - ltree transform for plpython"
66

7-
PG_CPPFLAGS = -I$(top_srcdir)/src/pl/plpython$(python_includespec) -I$(top_srcdir)/contrib/ltree
7+
PG_CPPFLAGS = -I$(top_srcdir)/src/pl/plpython$(python_includespec) -I$(top_srcdir)/contrib/ltree -DPLPYTHON_LIBNAME='"plpython$(python_majorversion)"'
88

99
EXTENSION = ltree_plpythonu ltree_plpython2u ltree_plpython3u
1010
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
2323
include$(top_srcdir)/contrib/contrib-global.mk
2424
endif
2525

26-
# In configurations that forbid undefined symbols in libraries, link with each
27-
# dependency. This does preclude pgxs builds.
26+
# We must link libpython explicitly
2827
ifeq ($(PORTNAME), aix)
2928
rpathdir =$(pkglibdir):$(python_libdir)
30-
SHLIB_LINK +=$(python_libspec)$(python_additional_libs)$(sort$(wildcard ../../src/pl/plpython/libplpython*.exp))
31-
endif
29+
SHLIB_LINK +=$(python_libspec)$(python_additional_libs)
30+
else
3231
ifeq ($(PORTNAME), win32)
33-
SHLIB_LINK +=$(sort$(wildcard ../../src/pl/plpython/libpython*.a))$(sort$(wildcard ../../src/pl/plpython/libplpython*.a))
32+
# ... see silliness in plpython Makefile ...
33+
SHLIB_LINK +=$(sort$(wildcard ../../src/pl/plpython/libpython*.a))
34+
else
35+
rpathdir =$(python_libdir)
36+
SHLIB_LINK +=$(python_libspec)
3437
endif
35-
36-
ifeq ($(PORTNAME), cygwin)
37-
SHLIB_LINK += -L../ltree -lltree -L../../src/pl/plpython\
38-
-lplpython$(python_majorversion)$(python_libspec)
3938
endif
4039

4140
REGRESS_OPTS += --load-extension=ltree

‎contrib/ltree_plpython/ltree_plpython.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,39 @@
11
#include"postgres.h"
2+
23
#include"fmgr.h"
34
#include"plpython.h"
45
#include"ltree.h"
56

67
PG_MODULE_MAGIC;
78

9+
externvoid_PG_init(void);
10+
11+
/* Linkage to functions in plpython module */
12+
#ifPY_MAJOR_VERSION >=3
13+
typedefPyObject*(*PLyUnicode_FromStringAndSize_t) (constchar*s,Py_ssize_tsize);
14+
staticPLyUnicode_FromStringAndSize_tPLyUnicode_FromStringAndSize_p;
15+
#endif
16+
17+
18+
/*
19+
* Module initialize function: fetch function pointers for cross-module calls.
20+
*/
21+
void
22+
_PG_init(void)
23+
{
24+
/* Asserts verify that typedefs above match original declarations */
25+
#ifPY_MAJOR_VERSION >=3
26+
AssertVariableIsOfType(&PLyUnicode_FromStringAndSize,PLyUnicode_FromStringAndSize_t);
27+
PLyUnicode_FromStringAndSize_p= (PLyUnicode_FromStringAndSize_t)
28+
load_external_function("$libdir/"PLPYTHON_LIBNAME,"PLyUnicode_FromStringAndSize",
29+
true,NULL);
30+
#endif
31+
}
32+
33+
34+
/* These defines must be after the module init function */
35+
#definePLyUnicode_FromStringAndSize PLyUnicode_FromStringAndSize_p
36+
837

938
PG_FUNCTION_INFO_V1(ltree_to_plpython);
1039

‎contrib/ltree_plpython/ltree_plpython2u--1.0.sql

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
44
\echo Use"CREATE EXTENSION ltree_plpython2u" to load this file. \quit
55

6-
-- make sure the prerequisite libraries are loaded
7-
LOAD'plpython2';
8-
SELECTNULL::ltree;
9-
10-
116
CREATEFUNCTIONltree_to_plpython2(val internal) RETURNS internal
127
LANGUAGE C STRICT IMMUTABLE
138
AS'MODULE_PATHNAME','ltree_to_plpython';

‎contrib/ltree_plpython/ltree_plpython3u--1.0.sql

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
44
\echo Use"CREATE EXTENSION ltree_plpython3u" to load this file. \quit
55

6-
-- make sure the prerequisite libraries are loaded
7-
LOAD'plpython3';
8-
SELECTNULL::ltree;
9-
10-
116
CREATEFUNCTIONltree_to_plpython3(val internal) RETURNS internal
127
LANGUAGE C STRICT IMMUTABLE
138
AS'MODULE_PATHNAME','ltree_to_plpython';

‎contrib/ltree_plpython/ltree_plpythonu--1.0.sql

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
44
\echo Use"CREATE EXTENSION ltree_plpythonu" to load this file. \quit
55

6-
-- make sure the prerequisite libraries are loaded
7-
LOAD'plpython2';-- change to plpython3 if that ever becomes the default
8-
SELECTNULL::ltree;
9-
10-
116
CREATEFUNCTIONltree_to_plpython(val internal) RETURNS internal
127
LANGUAGE C STRICT IMMUTABLE
138
AS'MODULE_PATHNAME';

‎src/tools/msvc/Mkvcbuild.pm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,10 +480,11 @@ sub mkvcbuild
480480
'plpython' .$pymajorver,'src/pl/plpython',
481481
'hstore','contrib/hstore');
482482
$hstore_plpython->AddDefine('PLPYTHON_LIBNAME="plpython' .$pymajorver .'"');
483-
AddTransformModule(
483+
my$ltree_plpython =AddTransformModule(
484484
'ltree_plpython' .$pymajorver,'contrib/ltree_plpython',
485485
'plpython' .$pymajorver,'src/pl/plpython',
486486
'ltree','contrib/ltree');
487+
$ltree_plpython->AddDefine('PLPYTHON_LIBNAME="plpython' .$pymajorver .'"');
487488
}
488489

489490
if ($solution->{options}->{perl})

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp