From c82fe1984b51f53ce7a4ad6853815bc9554fa390 Mon Sep 17 00:00:00 2001 From: Mikhail Titov Date: Tue, 4 Jun 2019 12:16:44 -0500 Subject: [PATCH] Use 8.4 in plr.control (#61) * Use 8.4 in plr.control * Remove unused testing files Those were to be used with PG < 9.x --- Makefile | 1 - expected/plr.out | 7 +-- plr--8.4.sql | 2 - plr.control | 2 +- plr.sql.in | 114 ----------------------------------------------- plr.vcxproj | 1 - sql/plr.sql | 9 +--- testplr.bat | 12 ----- 8 files changed, 5 insertions(+), 143 deletions(-) delete mode 100755 plr.sql.in delete mode 100644 testplr.bat diff --git a/Makefile b/Makefile index a6e8df64..492925d5 100755 --- a/Makefile +++ b/Makefile @@ -22,7 +22,6 @@ PG_CPPFLAGS += $(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_libdir1x) -L$(r_libdir2x) -lR -DATA_built = plr.sql DATA = plr--8.4.sql plr--8.3.0.18--8.4.sql plr--unpackaged--8.4.sql REGRESS = plr bad_fun opt_window do out_args diff --git a/expected/plr.out b/expected/plr.out index 4ab3cbf9..5529b3fa 100755 --- a/expected/plr.out +++ b/expected/plr.out @@ -1,8 +1,5 @@ --- --- first, define the language and functions. Turn off echoing so that expected file --- does not depend on contents of plr.sql. --- -\set ECHO none +-- install extension +create extension plr; -- make sure we get the notices set client_min_messages to notice; -- check version diff --git a/plr--8.4.sql b/plr--8.4.sql index 483d3d87..0a44e804 100644 --- a/plr--8.4.sql +++ b/plr--8.4.sql @@ -1,5 +1,3 @@ --- keep this in sync with the plr.sql.in legacy install file - CREATE FUNCTION plr_call_handler() RETURNS LANGUAGE_HANDLER AS 'MODULE_PATHNAME' LANGUAGE C; diff --git a/plr.control b/plr.control index f4c64195..7ae7c280 100644 --- a/plr.control +++ b/plr.control @@ -1,5 +1,5 @@ # plr extension comment = 'load R interpreter and execute R script from within a database' -default_version = '8.5' +default_version = '8.4' module_pathname = '$libdir/plr' relocatable = true diff --git a/plr.sql.in b/plr.sql.in deleted file mode 100755 index ee06710c..00000000 --- a/plr.sql.in +++ /dev/null @@ -1,114 +0,0 @@ --- keep this in sync with the plr--X.Y.Z.N.sql extension install file - -CREATE FUNCTION plr_call_handler() -RETURNS LANGUAGE_HANDLER -AS 'MODULE_PATHNAME' LANGUAGE C; - -CREATE FUNCTION plr_inline_handler(internal) -RETURNS VOID -AS 'MODULE_PATHNAME' LANGUAGE C STRICT; - -CREATE FUNCTION plr_validator(oid) -RETURNS VOID -AS 'MODULE_PATHNAME' LANGUAGE C STRICT; - -CREATE LANGUAGE plr -HANDLER plr_call_handler -INLINE plr_inline_handler -VALIDATOR plr_validator; - -CREATE OR REPLACE FUNCTION plr_version () -RETURNS text -AS 'MODULE_PATHNAME','plr_version' -LANGUAGE C; - -CREATE OR REPLACE FUNCTION reload_plr_modules () -RETURNS text -AS 'MODULE_PATHNAME','reload_plr_modules' -LANGUAGE C; - -CREATE OR REPLACE FUNCTION install_rcmd (text) -RETURNS text -AS 'MODULE_PATHNAME','install_rcmd' -LANGUAGE C STRICT; -REVOKE EXECUTE ON FUNCTION install_rcmd (text) FROM PUBLIC; - -CREATE OR REPLACE FUNCTION plr_singleton_array (float8) -RETURNS float8[] -AS 'MODULE_PATHNAME','plr_array' -LANGUAGE C STRICT; - -CREATE OR REPLACE FUNCTION plr_array_push (_float8, float8) -RETURNS float8[] -AS 'MODULE_PATHNAME','plr_array_push' -LANGUAGE C STRICT; - -CREATE OR REPLACE FUNCTION plr_array_accum (_float8, float8) -RETURNS float8[] -AS 'MODULE_PATHNAME','plr_array_accum' -LANGUAGE C; - -CREATE TYPE plr_environ_type AS (name text, value text); -CREATE OR REPLACE FUNCTION plr_environ () -RETURNS SETOF plr_environ_type -AS 'MODULE_PATHNAME','plr_environ' -LANGUAGE C; - -REVOKE EXECUTE ON FUNCTION plr_environ() FROM PUBLIC; - -CREATE TYPE r_typename AS (typename text, typeoid oid); -CREATE OR REPLACE FUNCTION r_typenames() -RETURNS SETOF r_typename AS ' - within(data.frame( - typename = ls(name = .GlobalEnv, pat = "OID"), - stringsAsFactors = FALSE - ), - { - typeoid <- sapply(typename, get) - }) -' language 'plr'; - -CREATE OR REPLACE FUNCTION load_r_typenames() -RETURNS text AS ' - sql <- "select upper(typname::text) || ''OID'' as typename, oid from pg_catalog.pg_type where typtype = ''b'' order by typname" - rs <- pg.spi.exec(sql) - for(i in 1:nrow(rs)) - { - typobj <- rs[i,1] - typval <- rs[i,2] - if (substr(typobj,1,1) == "_") - typobj <- paste("ARRAYOF", substr(typobj,2,nchar(typobj)), sep="") - assign(typobj, typval, .GlobalEnv) - } - return("OK") -' language 'plr'; - -CREATE TYPE r_version_type AS (name text, value text); -CREATE OR REPLACE FUNCTION r_version() -RETURNS setof r_version_type as ' - cbind(names(version),unlist(version)) -' language 'plr'; - -CREATE OR REPLACE FUNCTION plr_set_rhome (text) -RETURNS text -AS 'MODULE_PATHNAME','plr_set_rhome' -LANGUAGE C STRICT; -REVOKE EXECUTE ON FUNCTION plr_set_rhome (text) FROM PUBLIC; - -CREATE OR REPLACE FUNCTION plr_unset_rhome () -RETURNS text -AS 'MODULE_PATHNAME','plr_unset_rhome' -LANGUAGE C; -REVOKE EXECUTE ON FUNCTION plr_unset_rhome () FROM PUBLIC; - -CREATE OR REPLACE FUNCTION plr_set_display (text) -RETURNS text -AS 'MODULE_PATHNAME','plr_set_display' -LANGUAGE C STRICT; -REVOKE EXECUTE ON FUNCTION plr_set_display (text) FROM PUBLIC; - -CREATE OR REPLACE FUNCTION plr_get_raw (bytea) -RETURNS bytea -AS 'MODULE_PATHNAME','plr_get_raw' -LANGUAGE C STRICT; - diff --git a/plr.vcxproj b/plr.vcxproj index 37ab5a51..7dae9806 100644 --- a/plr.vcxproj +++ b/plr.vcxproj @@ -82,7 +82,6 @@ $(mingw)$(PlatformArchitecture)\bin\gendef.exe - "$(R_HOME)\bin\$(rbin)\R.dll" > R$(PlatformTarget).def lib /def:R$(PlatformTarget).def /out:R$(PlatformTarget).lib /MACHINE:$(PlatformTarget) if "%CI%"=="" ( if not exist data "$(pgroot)\bin\initdb" -D data ) -if not exist plr.sql "$(sed)" -e "s#MODULE_PATHNAME#$libdir/plr#" plr.sql.in > plr.sql R$(PlatformTarget).lib Generate R import library diff --git a/sql/plr.sql b/sql/plr.sql index 7218cd1a..727f38ef 100755 --- a/sql/plr.sql +++ b/sql/plr.sql @@ -1,10 +1,5 @@ --- --- first, define the language and functions. Turn off echoing so that expected file --- does not depend on contents of plr.sql. --- -\set ECHO none -\i plr.sql -\set ECHO all +-- install extension +create extension plr; -- make sure we get the notices set client_min_messages to notice; diff --git a/testplr.bat b/testplr.bat deleted file mode 100644 index c233f3ba..00000000 --- a/testplr.bat +++ /dev/null @@ -1,12 +0,0 @@ -cd c:\projects\postgresql\src\tools\msvc -perl install.pl c:\pgsql -pushd c:\pgsql -bin\initdb -D data -bin\pg_ctl -D data -l logfile start -popd -pushd c:\projects\postgresql\src\pl\plr -cp plr.control c:\pgsql\share\extension -cp plr--8.3.0.17.sql c:\pgsql\share\extension -..\..\..\Release\pg_regress\pg_regress --bindir=c:\pgsql\bin --dbname=pl_regression plr - -