Permalink
Browse files

- Update all Copyright notices.

- New (undocumented) functions r_version(), plr_set_rhome(),
  and plr_unset_rhome().
- Use Rembedded.h if available
- If R_HOME environment variable is not defined, attempt to find it using
  pkg-config. (idea from Dirk Eddelbuettel)
- In any case, create define for default R_HOME based on pkg-config. Use
  the default R_HOME during R interpreter init if the environment variable
  is unset. (idea from Dirk Eddelbuettel)
- Use PGDLLIMPORT instead of DLLIMPORT is it is defined.
- Switch to Rf_isVectorList instead of IS_LIST for spi_execp argument test.
  Prior to R-2.4.0, the latter allows bad arguments to get past, causing
  a segfault in an R internal type coersion function. (found by Steve Singer)
- New spi cursor manupulation functions (patch courtesy of Steve Singer).
- Force R interpreter non-interactive mode. Fixes some cases that previously
  appeared to be hung postgres backends in certain errors occured in R
  (R was actually waiting for user input). On some platforms this situation
  caused segfaults instead. (found by Jie Zhang)
- When a plr function source is empty, plr tries to find a function by the
  same name within the R interpreter environment. If the function could not
  be found, it would cause a hang or segfault. This was not easily trapped
  in the R interpreter. Now, build and compile the equivalent plr source.
  This allows the R interpreter to trap the error properly when the function
  does not exist.
- PG_VERSION_NUM if available. (patch courtesy of Neal Conway)
- Plug memory leak in POP_PLERRCONTEXT. (patch courtesy of Steve Singer)
- Consolidated Makefile from plr-8.2.0.x, obsoleting Makefile.pgxs
  • Loading branch information...
1 parent 891c309 commit 748a174e00de3a9da01e930a37f8472cdaa75dbb jconway committed Sep 8, 2007
Showing with 2,253 additions and 151 deletions.
  1. +29 −2 Makefile
  2. +10 −2 README.plr
  3. +81 −10 doc/plr.sgml
  4. +868 −0 expected/plr.out.7.3
  5. +870 −0 expected/plr.out.7.4
  6. +8 −1 pg_backend_support.c
  7. +59 −95 pg_conversion.c
  8. +200 −3 pg_rsupport.c
  9. +35 −20 pg_userfuncs.c
  10. +44 −10 plr.c
  11. +17 −7 plr.h
  12. +18 −0 plr.sql.in
  13. +14 −1 sql/plr.sql
View
@@ -1,8 +1,20 @@
# location of R library
+
+ifdef R_HOME
r_libdir1x = ${R_HOME}/bin
r_libdir2x = ${R_HOME}/lib
# location of R includes
r_includespec = ${R_HOME}/include
+else
+R_HOME := $(shell pkg-config --variable=rhome libR)
+r_libdir1x := $(shell pkg-config --variable=rlibdir libR)
+r_libdir2x := $(shell pkg-config --variable=rlibdir libR)
+r_includespec := $(shell pkg-config --variable=rincludedir libR)
+endif
+
+rhomedef := $(shell pkg-config --variable=rhome libR)
+
+ifneq (,${R_HOME})
MODULE_big := plr
PG_CPPFLAGS += -I$(r_includespec)
@@ -15,10 +27,15 @@ DOCS := README.plr
REGRESS := plr
EXTRA_CLEAN := doc/HTML.index expected/plr.out
+ifdef USE_PGXS
+PGXS := $(shell pg_config --pgxs)
+include $(PGXS)
+else
subdir = contrib/plr
top_builddir = ../..
include $(top_builddir)/src/Makefile.global
include $(top_srcdir)/contrib/contrib-global.mk
+endif
ifeq ($(PORTNAME), darwin)
DYSUFFIX = dylib
@@ -50,7 +67,7 @@ ifneq (,$(findstring yes, $(shared_libr)$(allow_nonpic_in_shlib)))
override CPPFLAGS := -I$(srcdir) -I$(r_includespec) $(CPPFLAGS)
override CPPFLAGS += -DPKGLIBDIR=\"$(pkglibdir)\" -DDLSUFFIX=\"$(DLSUFFIX)\"
-rpath :=
+override CPPFLAGS += -DR_HOME_DEFAULT=\"$(rhomedef)\"
installcheck: plrinstallcheck
@@ -70,4 +87,14 @@ all:
echo "*** the documentation for details."; \
echo ""
-endif # can't build
+endif # can't build - cannot find libR
+
+else # can't build - no R_HOME
+
+all:
+ @echo ""; \
+ echo "*** Cannot build PL/R because R_HOME cannot be found." ; \
+ echo "*** Refer to the documentation for details."; \
+ echo ""
+
+endif
View
@@ -2,7 +2,7 @@
* PL/R - PostgreSQL support for R as a
* procedural language (PL)
*
- * Copyright (c) 2003-2006 by Joseph E. Conway
+ * Copyright (c) 2003-2007 by Joseph E. Conway
* ALL RIGHTS RESERVED
*
* Joe Conway <mail@joeconway.com>
@@ -29,8 +29,16 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
+Version 0.1 (10 February, 2003):
+ - Initial release
-See http://www.joeconway.com/plr/ for release notes
+Version 0.2 (15 February, 2003):
+ - Incorporates fixes for lots of bugs and ommissions, in the code and
+ docs. Too many to mention, but faithfully recorded in cvs commit
+ messages.
+
+Version 0.5 (5 August, 2003) and afterward:
+ - See http://www.joeconway.com/plr/ for release notes and latest docs
Notes:
- R headers are required. Download and install R prior to building
View
@@ -3,7 +3,7 @@
<title>PL/R User's Guide - R Procedural Language</title>
<bookinfo>
<copyright>
- <year>2003-2006</year>
+ <year>2003</year>
<holder>Joseph E Conway</holder>
</copyright>
</bookinfo>
@@ -67,6 +67,14 @@
</programlisting>
</para>
+ <note>
+ <para>
+ 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>
+
<para>
You can use <literal>plr.sql</literal> (which is created in
<literal>contrib/plr</literal>) to create the language and support
@@ -106,24 +114,16 @@ CREATE LANGUAGE plr HANDLER plr_call_handler;
when it was configured, in order for the libR shared object library to be
available.
</para>
- </tip>
-
- <tip>
<para>
Additionally, libR must be findable by your runtime linker.
On Linux, this involves adding an entry in /etc/ld.so.conf for the
location of libR (typically $R_HOME/bin), and then running ldconfig.
Refer to <literal>man ldconfig</literal> or its equivalent for your system.
</para>
- </tip>
-
- <tip>
<para>
R_HOME must be defined in the environment of the user under which
PostgreSQL is started, <emphasis>before</emphasis> the postmaster
- is started. Otherwise PL/R will refuse to load. See plr_environ(),
- which allows examination of the environment available to the
- PostgreSQL postmaster process.
+ is started. Otherwise PL/R will refuse to load.
</para>
</tip>
@@ -790,6 +790,77 @@ select * from test_spi_execp('sp') as t(typeid oid, typename name);
</varlistentry>
<varlistentry>
+ <term>
+ <function>pg.spi.cursor_open</function>(
+ <type> character</type> <replaceable>cursor_name</replaceable>,
+ <type>external pointer</type> <replaceable>saved_plan</replaceable>,
+ <type>variable list</type> <replaceable>value_list</replaceable>)
+ </term>
+ <listitem>
+ <para>
+ Opens a cursor identified by cursor_name. The cursor can then be used to scroll through
+ the results of a query plan previously prepared by pg.spi.prepare. Any arguments to
+ the plan should be specified in argvalues similar to pg.spi.execp. Only read-only cursors
+ are supported at the moment.
+ <programlisting>
+plan <- pg.spi.prepare('SELECT * FROM pg_class');
+cursor_obj <- pg.spi.cursor_open('my_cursor',plan);
+ </programlisting>
+ </para>
+ <para>
+ Returns a cursor object that be be passed to <function>pg.spi.cursor_fetch</function>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <function>pg.spi.cursor_fetch</function>(
+ <type>external pointer</type> <replaceable>cursor</replaceable>,
+ <type>boolean</type> <replaceable>forward</replaceable>,
+ <type>integer</type> <replaceable>rows</replaceable>)
+ </term>
+ <listitem>
+ <para>
+ Fetches rows from the cursor object previosuly returned by <function>pg.spi.cursor_open
+ </function>. If forward is TRUE then the cursor is moved forward to
+ fetch at most the number of rows required by the rows parameter. If forward is
+ FALSE then the cursor is moved backrwards at most the number of rows specified.
+ </para>
+ <para>
+ rows indicates the maximum number of rows that should be returned.
+ </para>
+ <para>
+ <programlisting>
+plan <- pg.spi.prepare('SELECT * FROM pg_class');
+cursor_obj <- pg.spi.cursor_open('my_cursor',plan);
+data <- pg.spi.cursor_forward(cursor_obj,TRUE,10);
+ </programlisting>
+ </para>
+ <para>
+ Returns a data frame containing the results.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <function>pg.spi.cursor_close</function>(
+ <type>external pointer</type><replaceable>cursor</replaceable>)
+ </term>
+ <listitem>
+ <para>
+ Closes a cursor previously opened by <function>pg.spi.cursor_open</function>
+ <programlisting>
+plan <- pg.spi.prepare('SELECT * FROM pg_class');
+cursor_obj <- pg.spi.cursor_open('my_cursor',plan);
+pg.spi.cursor_close(cursor_obj);
+ </programlisting>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><function>pg.spi.lastoid</function>()</term>
<listitem>
<para>
Oops, something went wrong.

0 comments on commit 748a174

Please sign in to comment.