Skip to content

Latest commit

 

History

History
42 lines (25 loc) · 1.33 KB

README.md

File metadata and controls

42 lines (25 loc) · 1.33 KB

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