Skip to content

Instantly share code, notes, and snippets.

@3manuek
Last active November 17, 2015 04:26
Show Gist options
  • Save 3manuek/32e4fc62c6ebad998b8f to your computer and use it in GitHub Desktop.
Save 3manuek/32e4fc62c6ebad998b8f to your computer and use it in GitHub Desktop.
Installing PLR
70 wget https://ftp.postgresql.org/pub/source/v9.4.5/postgresql-9.4.5.tar.gz
71 tar xzf postgresql-9.4.5.tar.gz
73 cd postgresql-9.4.5/
75 ./configure --help
76 apt-cache search libzip
77 apt-get install libzip-dev libzip2
79 apt-cache search libxmls
80 apt-get install libxmlsec1-dev
./configure --enable-profiling --enable-cassert --enable-depend CFLAGS="-fno-omit-frame-pointer" --enable-R-shlib --prefix=/opt/postgres_plr
84 make && make install
control.sh is on bash_scripts repo.
su postgres -c 'bin/initdb -D data'
./control.sh start
bin/createdb -Upostgres sandbox
bin/psql -Upostgres sandbox < /root/PLR_INSTALL/postgresql-9.4.5/contrib/plr/plr.sql
CREATE OR REPLACE FUNCTION r_max (integer, integer) RETURNS integer AS '
if (arg1 > arg2)
return(arg1)
else
return(arg2)
' LANGUAGE 'plr' STRICT;
CREATE OR REPLACE FUNCTION r_max_pl(param1 int, param2 int)
RETURNS integer AS $$
BEGIN
IF param1 > param2 THEN
RETURN param1;
ELSE
RETURN param2;
END IF;
END;
$$ LANGUAGE plpgsql STRICT;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment