Permalink
Browse files

Adjust for PostgreSQL 8.0.0 and R-2.0.1, including docs. Specifically

mention pgxs build.
  • Loading branch information...
1 parent da58776 commit 0b0ddea19417ddef78ae73d25e8a46762cd684c3 jconway committed Dec 1, 2004
Showing with 47 additions and 35 deletions.
  1. +5 −4 Makefile
  2. +5 −4 Makefile.pgxs
  3. +21 −10 doc/plr.sgml
  4. +0 −3 pg_rsupport.c
  5. +6 −6 plr.c
  6. +10 −8 plr.h
View
@@ -1,5 +1,6 @@
# location of R library
-r_libdir = ${R_HOME}/bin
+r_libdir1x = ${R_HOME}/bin
+r_libdir2x = ${R_HOME}/lib
# location of R includes
r_includespec = ${R_HOME}/include
@@ -15,11 +16,11 @@ include $(top_builddir)/src/Makefile.global
# Since there is no official way to determine this,
# we see if there is a file that is named like a shared library.
ifneq ($(PORTNAME), darwin)
-ifneq (,$(wildcard $(r_libdir)/libR*$(DLSUFFIX)*))
+ifneq (,$(wildcard $(r_libdir1x)/libR*$(DLSUFFIX)*)$(wildcard $(r_libdir2x)/libR*$(DLSUFFIX)*))
shared_libr = yes;
endif
else
-ifneq (,$(wildcard $(r_libdir)/libR*$(DYSUFFIX)*))
+ifneq (,$(wildcard $(r_libdir1x)/libR*$(DYSUFFIX)*)$(wildcard $(r_libdir2x)/libR*$(DYSUFFIX)*))
shared_libr = yes
endif
endif
@@ -36,7 +37,7 @@ MODULE_big := plr
PG_CPPFLAGS += -I$(r_includespec)
SRCS += plr.c pg_conversion.c pg_backend_support.c pg_userfuncs.c pg_rsupport.c
OBJS := $(SRCS:.c=.o)
-SHLIB_LINK += -L$(r_libdir) -lR
+SHLIB_LINK += -L$(r_libdir1x) -L$(r_libdir2x) -lR
DATA_built := plr.sql
DOCS := README.plr
View
@@ -1,5 +1,6 @@
# location of R library
-r_libdir = ${R_HOME}/bin
+r_libdir1x = ${R_HOME}/bin
+r_libdir2x = ${R_HOME}/lib
# location of R includes
r_includespec = ${R_HOME}/include
@@ -11,11 +12,11 @@ endif
# Since there is no official way to determine this,
# we see if there is a file that is named like a shared library.
ifneq ($(PORTNAME), darwin)
-ifneq (,$(wildcard $(r_libdir)/libR*$(DLSUFFIX)*))
+ifneq (,$(wildcard $(r_libdir1x)/libR*$(DLSUFFIX)*)$(wildcard $(r_libdir2x)/libR*$(DLSUFFIX)*))
shared_libr = yes;
endif
else
-ifneq (,$(wildcard $(r_libdir)/libR*$(DYSUFFIX)*))
+ifneq (,$(wildcard $(r_libdir1x)/libR*$(DYSUFFIX)*)$(wildcard $(r_libdir2x)/libR*$(DYSUFFIX)*))
shared_libr = yes
endif
endif
@@ -32,7 +33,7 @@ MODULE_big := plr
PG_CPPFLAGS += -I$(r_includespec)
SRCS += plr.c pg_conversion.c pg_backend_support.c pg_userfuncs.c pg_rsupport.c
OBJS := $(SRCS:.c=.o)
-SHLIB_LINK += -L$(r_libdir) -lR
+SHLIB_LINK += -L$(r_libdir1x) -L$(r_libdir2x) -lR
DATA_built := plr.sql
DOCS := README.plr
View
@@ -55,11 +55,23 @@
</programlisting>
</para>
+ <para>
+ As of PostgreSQL 8.0.0, PL/R can also be built without the PostgreSQL source
+ tree. Untar PL/R whereever you prefer. The shared object for the R call handler
+ is built and installed in the PostgreSQL library directory via the following
+ commands (starting from <literal>/path/to/plr</literal>):
+ <programlisting>
+ cd plr
+ make -f Makefile.pgxs
+ make -f Makefile.pgxs install
+ </programlisting>
+ </para>
+
<note>
<para>
- PL/R should build cleanly with PostgreSQL 7.3.x, and 7.4beta. It was
- initially developed using libR from R 1.6.2 under Red Hat 7.3 & 8.0. PL/R
- has also passed its regression test with R 1.7.1 under Red Hat 7.3, 8.0, & 9.
+ PL/R should build cleanly with PostgreSQL 7.3.x, 7.4.x, and 8.0.x. and
+ R 1.6.2 and newer. The current release passed its regression test with
+ R 2.0.1 under Fedora Core 2.
</para>
</note>
@@ -90,8 +102,8 @@ CREATE LANGUAGE plr HANDLER plr_call_handler;
<tip>
<para>
- In addition to the documentation, the <literal>plr.out</literal> file
- in <literal>plr/expected</literal> is a good source of usage examples.
+ In addition to the documentation, the <literal>plr.out.*</literal> files
+ in <literal>plr/expected</literal> are a good source of usage examples.
</para>
</tip>
@@ -150,11 +162,10 @@ CREATE OR REPLACE FUNCTION r_max (integer, integer) RETURNS integer AS '
' LANGUAGE 'plr' STRICT;
</programlisting>
- Starting with PostgreSQL 7.5 (or whatever the next major release after 7.4
- ends up being called), arguments may be explicitly named when creating a
- function. If an argument is explicitly named at function creation time,
- that name will be available to your R script in place of the usual
- <literal>argN</literal> variable. For example:
+ Starting with PostgreSQL 8.0, arguments may be explicitly named when
+ creating a function. If an argument is explicitly named at function
+ creation time, that name will be available to your R script in place
+ of the usual <literal>argN</literal> variable. For example:
<programlisting>
CREATE OR REPLACE FUNCTION sd(vals float8[]) RETURNS float AS '
View
@@ -135,7 +135,6 @@ plr_SPI_exec(SEXP rsql)
SEXP result = NULL;
MemoryContext oldcontext;
PREPARE_PG_TRY;
- ERRORCONTEXTCALLBACK;
/* set up error context */
PUSH_PLERRCONTEXT(rsupport_error_callback, "pg.spi.exec");
@@ -272,7 +271,6 @@ plr_SPI_prepare(SEXP rsql, SEXP rargtypes)
SEXP result;
MemoryContext oldcontext;
PREPARE_PG_TRY;
- ERRORCONTEXTCALLBACK;
/* set up error context */
PUSH_PLERRCONTEXT(rsupport_error_callback, "pg.spi.prepare");
@@ -468,7 +466,6 @@ plr_SPI_execp(SEXP rsaved_plan, SEXP rargvalues)
SEXP result = NULL;
MemoryContext oldcontext;
PREPARE_PG_TRY;
- ERRORCONTEXTCALLBACK;
/* set up error context */
PUSH_PLERRCONTEXT(rsupport_error_callback, "pg.spi.execp");
View
12 plr.c
@@ -33,9 +33,9 @@
#include "plr.h"
#include "storage/ipc.h"
-#ifdef PG_VERSION_75_COMPAT
+#ifdef PG_VERSION_80_COMPAT
#include "utils/typcache.h"
-#endif /* PG_VERSION_75_COMPAT */
+#endif /* PG_VERSION_80_COMPAT */
/*
* Global data
@@ -120,9 +120,9 @@ static SEXP plr_parse_func_body(const char *body);
static SEXP plr_convertargs(plr_function *function, Datum *arg, bool *argnull);
static void plr_error_callback(void *arg);
-#ifdef PG_VERSION_75_COMPAT
+#ifdef PG_VERSION_80_COMPAT
static char **fetchArgNames(HeapTuple procTup, int nargs);
-#endif /* PG_VERSION_75_COMPAT */
+#endif /* PG_VERSION_80_COMPAT */
/*
* plr_call_handler - This is the only visible function
@@ -1335,7 +1335,7 @@ plr_error_callback(void *arg)
errcontext("In PL/R function %s", (char *) arg);
}
-#ifdef PG_VERSION_75_COMPAT
+#ifdef PG_VERSION_80_COMPAT
/*
* Fetch the argument names, if any, from the proargnames field of the
* pg_proc tuple. Results are palloc'd.
@@ -1374,4 +1374,4 @@ fetchArgNames(HeapTuple procTup, int nargs)
return result;
}
-#endif /* PG_VERSION_75_COMPAT */
+#endif /* PG_VERSION_80_COMPAT */
View
18 plr.h
@@ -83,7 +83,7 @@
#elif (CATALOG_VERSION_NO <= 200310211)
#define PG_VERSION_74_COMPAT
#else
-#define PG_VERSION_75_COMPAT
+#define PG_VERSION_80_COMPAT
#endif
#ifdef DEBUGPROTECT
@@ -262,12 +262,12 @@ typedef enum IOFuncSelector
#else
/*************************************************************************
- * working with postgres 7.4 or 7.5 compatible sources
+ * working with postgres 7.4 or 8.0 compatible sources
*************************************************************************/
#ifdef PG_VERSION_74_COMPAT
#define TUPLESTORE_BEGIN_HEAP tuplestore_begin_heap(true, false, SortMem)
-#else /* 7.5 or greater */
+#else /* 8.0 or greater */
#define TUPLESTORE_BEGIN_HEAP tuplestore_begin_heap(true, false, work_mem)
#endif /* PG_VERSION_74_COMPAT */
@@ -279,9 +279,9 @@ typedef enum IOFuncSelector
#endif /* PG_VERSION_73_COMPAT */
-#ifdef PG_VERSION_75_COMPAT
+#ifdef PG_VERSION_80_COMPAT
/*************************************************************************
- * working with postgres 7.5 compatible sources
+ * working with postgres 8.0 compatible sources
*************************************************************************/
#define PLR_CLEANUP \
plr_cleanup(int code, Datum arg)
@@ -372,7 +372,8 @@ typedef enum IOFuncSelector
if (argnames) \
pfree(argnames); \
} while (0)
-#define PREPARE_PG_TRY
+#define PREPARE_PG_TRY \
+ ERRORCONTEXTCALLBACK
#define PLR_PG_CATCH() \
PG_CATCH(); \
{ \
@@ -385,7 +386,7 @@ typedef enum IOFuncSelector
PG_END_TRY()
#else
/*************************************************************************
- * working with earlier than postgres 7.5 compatible sources
+ * working with earlier than postgres 8.0 compatible sources
*************************************************************************/
#define PLR_CLEANUP \
plr_cleanup(void)
@@ -437,6 +438,7 @@ typedef enum IOFuncSelector
} while (0)
#define FREE_ARG_NAMES
#define PREPARE_PG_TRY \
+ ERRORCONTEXTCALLBACK; \
sigjmp_buf save_restart
#define PG_TRY() \
do { \
@@ -451,7 +453,7 @@ typedef enum IOFuncSelector
#define PLR_PG_CATCH()
#define PLR_PG_END_TRY() \
memcpy(&Warn_restart, &save_restart, sizeof(Warn_restart))
-#endif /* PG_VERSION_75_COMPAT */
+#endif /* PG_VERSION_80_COMPAT */
/*
* structs

0 comments on commit 0b0ddea

Please sign in to comment.