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

Commitc02f1ea

Browse files
committed
Well, I finally solved the linking problem
that kept me from making perl secure.Attached is uuencoded tarball to add PL/perlto postgresql.Things I know don't work.-- triggers-- SPIThe README file has a _VERY_ short tutorial.Mark Hollomon
1 parentd242b64 commitc02f1ea

File tree

3 files changed

+2329
-0
lines changed

3 files changed

+2329
-0
lines changed

‎src/pl/plperl/Makefile.pl

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
use DynaLoader;
2+
use Config;
3+
use ExtUtils::Embed;
4+
5+
#
6+
# massage the ld options
7+
#
8+
my$ldopts= ldopts();
9+
chomp($ldopts);
10+
11+
#
12+
# get the location of the Opcode module
13+
#
14+
my$opcode='';
15+
{
16+
17+
$modname='Opcode';
18+
19+
my$dir;
20+
foreach (@INC) {
21+
if (-d"$_/auto/$modname") {
22+
$dir="$_/auto/$modname";
23+
last;
24+
}
25+
}
26+
27+
if (defined$dir) {
28+
$opcode= DynaLoader::dl_findfile("-L$dir",$modname);
29+
}
30+
31+
}
32+
33+
open(MAKEFILE,">Makefile");
34+
35+
print MAKEFILE<<_STATIC_;
36+
#-------------------------------------------------------------------------
37+
#
38+
# Makefile
39+
# Makefile for the plperl shared object
40+
#
41+
# AUTOGENERATED Makefile.pl
42+
#
43+
44+
#
45+
# Tell make where the postgresql sources live
46+
#
47+
SRCDIR=../../../src
48+
include \$(SRCDIR)/Makefile.global
49+
50+
51+
# use the same compiler as perl did
52+
CC=$Config{cc}
53+
54+
# get the compiler options that perl wants.
55+
CFLAGS+=@{[ccopts()]}
56+
# including the ones for dynamic loading
57+
CFLAGS+=$Config{cccdlflags}
58+
59+
# add the includes for postgreSQL
60+
CFLAGS+= -I\$(LIBPQDIR) -I\$(SRCDIR)/include
61+
62+
# For fmgr.h
63+
CFLAGS+= -I\$(SRCDIR)/backend
64+
65+
66+
# add the postgreSQL libraries
67+
LDADD+= -L\$(LIBPQDIR) -lpq
68+
69+
LDFLAGS+=$Config{lddlflags} \\
70+
$ldopts \\
71+
-lperl
72+
73+
#
74+
# DLOBJS is the dynamically-loaded object file.
75+
#
76+
DLOBJS= plperl\$(DLSUFFIX)
77+
78+
INFILES= \$(DLOBJS)
79+
80+
SHLIB_EXTRA_LIBS+=$opcode
81+
82+
#
83+
# plus exports files
84+
#
85+
ifdef EXPSUFF
86+
INFILES+= \$(DLOBJS:.o=\$(EXPSUFF))
87+
endif
88+
89+
%.so:%.o
90+
\$(CC) -o \$@ \$< \$(LDFLAGS) \$(SHLIB_EXTRA_LIBS) \$(LDADD)
91+
92+
93+
#
94+
# Build the shared lib
95+
#
96+
plperl: plperl.lo
97+
libtool \$(CC) -o plperl.so plperl.lo \$(SHLIB_EXTRA_LIBS) \$(LDADD) \$(LDFLAGS)
98+
99+
%.lo:%.c
100+
libtool \$(CC) -c \$(CFLAGS) \$<
101+
102+
103+
#
104+
# Clean
105+
#
106+
clean:
107+
rm -f \$(INFILES)*.o*.lo
108+
rm -rf.libs
109+
rm -f Makefile
110+
111+
dep depend:
112+
113+
_STATIC_

‎src/pl/plperl/README

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
>perl Makefile.pl
2+
>make
3+
4+
copy the resulting library somewhere that
5+
the postgresql backend can see it. assume
6+
that path is /usr/local/pgsql/modules/plperl.so
7+
8+
CREATE FUNCTION plperl_call_handler() RETURNS opaque
9+
AS '/usr/local/pgsql/modules/plperl.so' LANGUAGE 'C';
10+
11+
CREATE TRUSTED PROCEDURAL LANGUAGE 'plperl'
12+
HANDLER plperl_call_handler
13+
LANCOMPILER 'PL/Perl';
14+
15+
-- here is simple example
16+
CREATE FUNCTION addints(int4, int4) RETURNS int4 AS '
17+
return $_[0] + $_[1]
18+
' LANGUAGE 'plperl';
19+
20+
SELECT addints(3,4);
21+
22+
-- of course, you can pass tuples;
23+
CREATE TABLE twoints ( a integer, b integer);
24+
CREATE FUNCTION addtwoints(twoints) RETURNS integer AS '
25+
$tup = shift;
26+
return $tup->{"a"} + $tup->{"b"};
27+
' LANGUAGE 'plperl';
28+
29+
SELECT addtwoints(twoints) from twoints;
30+
31+
-- here is one that will fail. Creating the function
32+
-- will work, but using it will fail.
33+
CREATE FUNCTION badfunc() RETURNS int4 AS '
34+
open(TEMP, ">/tmp/badfile");
35+
print TEMP "Gotcha!\n";
36+
return 1;
37+
' LANGUAGE 'plperl';
38+
39+
SELECT badfunc();
40+
41+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp