Place source tar file in contrib in the PostgreSQL source tree and untar it. The shared object for the R call handler is built and installed in the PostgreSQL library directory via the following commands (starting from /path/to/postgresql_source/contrib):
cd plr make make install
Note: 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.
You can use plr.sql (which is created in contrib/plr) to create the language and support functions in your database of choice:
psql mydatabase < plr.sql
Alternatively you can create the language manually using SQL commands:
CREATE FUNCTION plr_call_handler() RETURNS LANGUAGE_HANDLER AS '$libdir/plr' LANGUAGE C; CREATE LANGUAGE plr HANDLER plr_call_handler;
Tip: If a language is installed into template1, all subsequently created databases will have the language installed automatically.
Tip: In addition to the documentation, the plr.out file in plr/expected is a good source of usage examples.
Tip: R headers are required. Download and install R prior to building PL/R. R must have been built with the --enable-R-shlib option when it was configured, in order for the libR shared object library to be available.
Tip: R_HOME must be defined in the environment of the user under which PostgreSQL is started, before the postmaster is started. Otherwise PL/R will refuse to load.