Skip to content
JVM procedural language. Execute code in any JVM from PostgreSQL
C Java PLpgSQL Other
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
expected
plj-java
sql
src
testserialization
.gitignore
BSD LICENSE
Makefile
README.md
pljvm--1.0.0.sql
pljvm.control
pljvm.md

README.md

PL/JVM

This is an implementation of a trusted language execution engine that executes code in any JVM via an RPC mechanism

Requirements

Any JVM based language

Building PL/JVM Language

  1. Make and install it: make clean && make && make install

Running the tests

From plj-java run maven exec:java Then from the main dir run make installcheck

Examples

There are a number of examples in the tests which demonstrate how this works

How it works

From the PostgreSQL process when the function is called all of the arguments are encoded and sent to the JVM along with the java class name and method. For example the function defined as:

 CREATE OR REPLACE FUNCTION pljvm_add(i int2, j int2) RETURNS int2 AS $$
org.postgresql.plj.test.Int.add
$$ LANGUAGE pljvm;

defines a function pljvm_add which takes two small ints as arguments and returns a small int. The java classname is org.postgresql.plj.test.Int and the method is add.

public Short add(Short a, Short b) { return (short)(a+b); }

On the JVM side there is a process running a netty pipeline which decodes the call requests; instantiates the class and calls the method in question and then encodes the call response back to the PostgreSQL process.

The library takes care of serializing and deserializing the arguments and the return values

You can’t perform that action at this time.