Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1100b37

Browse files
committed
Minor adjustments to UDF source code and file system structure
1 parent 2915b5d commit 1100b37

9 files changed

Lines changed: 39 additions & 207 deletions

File tree

extra/mysqludfsys/linux/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
LIBDIR=/usr/lib
22

33
install:
4-
gcc -Wall -I/usr/include/mysql -O1 -shared src/lib_mysqludf_sys.c -o so/lib_mysqludf_sys.so
5-
strip -sx so/lib_mysqludf_sys.so
6-
sudo cp -f so/lib_mysqludf_sys.so $(LIBDIR)/lib_mysqludf_sys.so
4+
gcc -Wall -I/usr/include/mysql -O1 -shared lib_mysqludf_sys.c -o lib_mysqludf_sys.so
5+
strip -sx lib_mysqludf_sys.so
6+
sudo cp -f lib_mysqludf_sys.so $(LIBDIR)/lib_mysqludf_sys.so
File renamed without changes.
-9.34 KB
Binary file not shown.
Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
LIBDIR=/tmp
22

3-
8.2:
4-
gcc -Wall -I/usr/include/postgresql/8.2/server -O1 -shared src/8.2/lib_postgresqludf_sys.c -o so/8.2/lib_postgresqludf_sys.so
5-
strip -sx so/8.2/lib_postgresqludf_sys.so
6-
cp -f so/8.2/lib_postgresqludf_sys.so $(LIBDIR)/lib_postgresqludf_sys.so
3+
8.4:
4+
gcc -Wall -I/usr/include/postgresql/8.4/server -O1 -shared lib_postgresqludf_sys.c -o lib_postgresqludf_sys.so
5+
strip -sx lib_postgresqludf_sys.so
6+
cp -f lib_postgresqludf_sys.so $(LIBDIR)/lib_postgresqludf_sys.so
77

88
8.3:
9-
gcc -Wall -I/usr/include/postgresql/8.3/server -O1 -shared src/8.3/lib_postgresqludf_sys.c -o so/8.3/lib_postgresqludf_sys.so
10-
strip -sx so/8.3/lib_postgresqludf_sys.so
11-
cp -f so/8.3/lib_postgresqludf_sys.so $(LIBDIR)/lib_postgresqludf_sys.so
9+
gcc -Wall -I/usr/include/postgresql/8.3/server -O1 -shared lib_postgresqludf_sys.c -o lib_postgresqludf_sys.so
10+
strip -sx lib_postgresqludf_sys.so
11+
cp -f lib_postgresqludf_sys.so $(LIBDIR)/lib_postgresqludf_sys.so
12+
13+
8.2:
14+
gcc -Wall -I/usr/include/postgresql/8.2/server -O1 -shared lib_postgresqludf_sys.c -o lib_postgresqludf_sys.so
15+
strip -sx lib_postgresqludf_sys.so
16+
cp -f lib_postgresqludf_sys.so $(LIBDIR)/lib_postgresqludf_sys.so

extra/postgresqludfsys/linux/install.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2020

2121
# Adapt the following settings to your environment
22+
USER="postgres"
23+
PORT="5434"
24+
VERSION="8.4"
2225
#PORT="5433"
26+
#VERSION="8.3"
27+
#PORT="5432"
2328
#VERSION="8.2"
24-
PORT="5432"
25-
VERSION="8.3"
26-
USER="postgres"
2729

2830
echo "Compiling the PostgreSQL UDF"
2931
make ${VERSION}
@@ -34,8 +36,10 @@ if test $? -ne 0; then
3436

3537
if test "${VERSION}" == "8.2"; then
3638
echo "apt-get install postgresql-server-dev-8.2"
37-
else
39+
else if test "${VERSION}" == "8.3"; then
3840
echo "apt-get install postgresql-server-dev-8.3"
41+
else if test "${VERSION}" == "8.4"; then
42+
echo "apt-get install postgresql-server-dev-8.4"
3943
fi
4044

4145
exit 1

extra/postgresqludfsys/linux/src/8.3/lib_postgresqludf_sys.c renamed to extra/postgresqludfsys/linux/lib_postgresqludf_sys.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ PG_MODULE_MAGIC;
4747
#endif
4848

4949
PG_FUNCTION_INFO_V1(sys_exec);
50+
#ifdef PGDLLIMPORT
5051
extern PGDLLIMPORT Datum sys_exec(PG_FUNCTION_ARGS) {
52+
#else
53+
extern DLLIMPORT Datum sys_exec(PG_FUNCTION_ARGS) {
54+
#endif
5155
text *argv0 = PG_GETARG_TEXT_P(0);
5256
int32 argv0_size;
5357
int32 result = 0;
@@ -72,7 +76,11 @@ extern PGDLLIMPORT Datum sys_exec(PG_FUNCTION_ARGS) {
7276
}
7377

7478
PG_FUNCTION_INFO_V1(sys_eval);
79+
#ifdef PGDLLIMPORT
7580
extern PGDLLIMPORT Datum sys_eval(PG_FUNCTION_ARGS) {
81+
#else
82+
extern DLLIMPORT Datum sys_eval(PG_FUNCTION_ARGS) {
83+
#endif
7684
text *argv0 = PG_GETARG_TEXT_P(0);
7785
text *result_text;
7886
int32 argv0_size;
@@ -112,15 +120,22 @@ extern PGDLLIMPORT Datum sys_eval(PG_FUNCTION_ARGS) {
112120
}
113121

114122
result_text = (text *)malloc(VARHDRSZ + strlen(result));
115-
//VARATT_SIZEP(result_text) = strlen(result) + VARHDRSZ;
123+
#ifdef SET_VARSIZE
116124
SET_VARSIZE(result_text, VARHDRSZ + strlen(result));
125+
#else
126+
VARATT_SIZEP(result_text) = strlen(result) + VARHDRSZ;
127+
#endif
117128
memcpy(VARDATA(result_text), result, strlen(result));
118129

119130
PG_RETURN_POINTER(result_text);
120131
}
121132

122133
PG_FUNCTION_INFO_V1(sys_bineval);
134+
#ifdef PGDLLIMPORT
123135
extern PGDLLIMPORT Datum sys_bineval(PG_FUNCTION_ARGS) {
136+
#else
137+
extern DLLIMPORT Datum sys_bineval(PG_FUNCTION_ARGS) {
138+
#endif
124139
text *argv0 = PG_GETARG_TEXT_P(0);
125140
int32 argv0_size;
126141
size_t len;
-5.34 KB
Binary file not shown.
-5.34 KB
Binary file not shown.

extra/postgresqludfsys/linux/src/8.2/lib_postgresqludf_sys.c

Lines changed: 0 additions & 192 deletions
This file was deleted.

0 commit comments

Comments
 (0)