Skip to content

Commit

Permalink
Cherrypick - https://github.com/postgres-plr/plr - master - Commits o…
Browse files Browse the repository at this point in the history
…n Aug 2, 2024 - EXCEPT buildPLR.yml
  • Loading branch information
AndreMikulec committed Aug 4, 2024
1 parent 626bf07 commit 198166f
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 8 deletions.
93 changes: 93 additions & 0 deletions Makefile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# location of R library

ifdef R_HOME
r_libdir1x = ${R_HOME}/bin${R_ARCH}
r_libdir2x = ${R_HOME}/lib${R_ARCH}
# location of R includes
r_includespec = -I${R_HOME}/include
rhomedef = ${R_HOME}
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 --cflags-only-I libR)
rhomedef := $(shell pkg-config --variable=rhome libR)
endif

ifneq (,${R_HOME})

EXTENSION = plr
MODULE_big = plr
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 = plr--8.4.7.sql plr--unpackaged--8.4.7.sql plr--8.3.0.18--8.4.sql plr--8.4.1--8.4.2.sql plr--8.4.3--8.4.4.sql \
plr--8.4--8.4.1.sql plr--8.4.2--8.4.3.sql plr--8.4.4--8.4.5.sql plr--8.4.5--8.4.6.sql plr--8.4.6--8.4.7.sql
REGRESS = plr bad_fun opt_window do out_args plr_transaction opt_window_frame

ifdef USE_PGXS
ifndef PG_CONFIG
PG_CONFIG := pg_config
endif
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
DLPREFIX = libR
else
ifeq ($(PORTNAME), win32)
DLPREFIX = R
else
DLPREFIX = libR
endif
endif

# we can only build PL/R if libR is available
# 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_libdir1x)/$(DLPREFIX)*$(DLSUFFIX)*)$(wildcard $(r_libdir2x)/$(DLPREFIX)*$(DLSUFFIX)*))
shared_libr = yes;
endif
else
ifneq (,$(wildcard $(r_libdir1x)/$(DLPREFIX)*$(DYSUFFIX)*)$(wildcard $(r_libdir2x)/$(DLPREFIX)*$(DYSUFFIX)*))
shared_libr = yes
endif
endif

# If we don't have a shared library and the platform doesn't allow it
# to work without, we have to skip it.
ifneq (,$(findstring yes, $(shared_libr)$(allow_nonpic_in_shlib)))

override CPPFLAGS := -I"$(srcdir)" -I"$(r_includespec)" $(CPPFLAGS)
override CPPFLAGS += -DPKGLIBDIR=\"$(pkglibdir)\" -DDLSUFFIX=\"$(DLSUFFIX)\"
override CPPFLAGS += -DR_HOME_DEFAULT=\"$(rhomedef)\"

else # can't build

all:
@echo ""; \
echo "*** Cannot build PL/R because libR is not a shared library." ; \
echo "*** You might have to rebuild your R installation. Refer to"; \
echo "*** the documentation for details."; \
echo ""

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
2 changes: 1 addition & 1 deletion _meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project('plr', 'c',
version : '8_4_6',
version : '8_4_7',
license : 'GNU Public License Version 2',
)

Expand Down
5 changes: 3 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,16 @@ plr = shared_module('plr',
contrib_targets += plr

install_data(
'plr--unpackaged--8.4.6.sql',
'plr--unpackaged--8.4.7.sql',
'plr--8.3.0.18--8.4.sql',
'plr--8.4.1--8.4.2.sql',
'plr--8.4.3--8.4.4.sql',
'plr--8.4--8.4.1.sql',
'plr--8.4.2--8.4.3.sql',
'plr--8.4.4--8.4.5.sql',
'plr--8.4.5--8.4.6.sql',
'plr--8.4.6.sql',
'plr--8.4.6--8.4.7.sql',
'plr--8.4.7.sql',
'plr.control',
kwargs: contrib_data_args,
)
Expand Down
6 changes: 3 additions & 3 deletions pg_conversion.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ SEXP
pg_window_frame_get_r(WindowObject winobj, int argno, plr_function* function)
{
char buf[256];
SEXP result, v, names, row_names;
SEXP result, v, names = R_NilValue, row_names;
int64 i, num_frame_row = 0;
int j, nc = 1, nc_effective = 1, df_colnum = 0;
Datum dvalue;
Expand All @@ -346,11 +346,11 @@ pg_window_frame_get_r(WindowObject winobj, int argno, plr_function* function)
Oid element_type = function->arg_typid[argno];
FmgrInfo out_func = function->arg_out_func[argno];
/* for tuple arguments */
HeapTuple tuple;
HeapTuple tuple = NULL;
HeapTupleHeader tuple_hdr;
Oid tupType;
int32 tupTypmod;
TupleDesc tupdesc;
TupleDesc tupdesc = NULL;
/* for array arguments */
Oid typelem = function->arg_elem[argno];
int16 typlen;
Expand Down
4 changes: 4 additions & 0 deletions plr--8.4.6--8.4.7.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- no changes to the sql files.

-- complain if script is sourced in psql, rather than via ALTER EXTENSION
\echo Use "ALTER EXTENSION plr UPDATE to '8.4.7'" to load this file. \quit
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion plr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1625,7 +1625,7 @@ plr_convertargs(plr_function *function, Datum *arg, bool *argnull, FunctionCallI
int c = 0;
SEXP rargs,
t,
el;
el = R_NilValue;

#ifdef HAVE_WINDOW_FUNCTIONS
if (function->iswindow)
Expand Down
2 changes: 1 addition & 1 deletion plr.control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# plr extension
comment = 'load R interpreter and execute R script from within a database'
default_version = '8.4.6'
default_version = '8.4.7'
module_pathname = '$libdir/plr'
relocatable = true

0 comments on commit 198166f

Please sign in to comment.