Language Handler for executing Nim as a procedural language for postgresql
nimble install plnim@#head
nim c -d:release --app:lib -o:libplnim.so ~/.nimble/pkgs/plnim-#head/plnim
cp libplnim.so $(pg_config --pkglibdir)
This file contains information for building the language_handler for plnim using the libplnim.so file you created before.
psql [username] [dbname] -f ~/.nimble/pkgs/plnim-#head/plnim/sql/extension.sql
#CREATE FUNCTION
#CREATE LANGUAGE
#COMMENT
create or replace function add_one(integer) returns integer
language plnim
as
$$
result = $1 + 1
$$
;
The first time you execute your function, the language handler will emit the next message
select add_one(1);
WARNING: Need Compile to Dynlib
DETAIL: /var/lib/postgresql/{pg_version}/main/plnim/src/{function_name}.nim was created.
HINT: nim c -d:release --app:lib [filename]
[sudo] nim c -d:release --app:lib [filename]
Copy the produced dynlib file to /usr/lib
[sudo] cp lib{function_name}.so /usr/lib
select add_one(1);
add_one
---------
2
(1 row)