forked from plv8/plv8
-
Notifications
You must be signed in to change notification settings - Fork 0
V8 Engine Javascript Procedural Language add-on for PostgreSQL
License
alessbelli/plv8
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A Procedural Language in JavaScript powered by V8 ================================================= plv8 is a shared library that provides a PostgreSQL procedural language powered by V8 JavaScript Engine. With this program you can write in JavaScript your function that is callable from SQL. REQUIREMENT ----------- plv8 is tested with: - PG: version 8.4, 9.0, 9.1 and 9.2dev (maybe older are allowed) - V8: version 3.6.2 - g++: version 4.5.1 Also all tools that PostgreSQL and V8 require to be built are required. INSTALL ------- Make sure V8 include files are in the system include directories, or you can place them in $(PLV8DIR)/../v8/include. Run make: # Build with CoffeeScript and LiveScript $ make ENABLE_COFFEE=1 ENABLE_LIVESCRIPT=1 $ sudo make install ENABLE_COFFEE=1 ENABLE_LIVESCRIPT=1 and create language via $ psql -c 'CREATE EXTENSION plv8' $ psql -c 'CREATE EXTENSION plls' $ psql -c 'CREATE EXTENSION plcoffee' in 9.1, or in the prior versions $ psql -f plv8.sql to create database objects. TEST ---- plv8 supports installcheck test. Make sure set custom_variable_classes = 'plv8' in your postgresql.conf and $ make installcheck EXAMPLE (LIVESCRIPT) -------------------- CREATE OR REPLACE FUNCTION plls_test(keys text[], vals text[]) RETURNS text AS $$ return JSON.stringify { [key, vals[idx]] for key, idx in keys } $$ LANGUAGE plls IMMUTABLE STRICT; SELECT plls_test(ARRAY['name', 'age'], ARRAY['Tom', '29']); plls_test --------------------------- {"name":"Tom","age":"29"} (1 row) EXAMPLE (JAVASCRIPT) -------------------- CREATE OR REPLACE FUNCTION plv8_test(keys text[], vals text[]) RETURNS text AS $$ var o = {}; for(var i=0; i<keys.length; i++){ o[keys[i]] = vals[i]; } return JSON.stringify(o); $$ LANGUAGE plv8 IMMUTABLE STRICT; SELECT plv8_test(ARRAY['name', 'age'], ARRAY['Tom', '29']); plv8_test --------------------------- {"name":"Tom","age":"29"} (1 row) NOTES ----- plv8 is hosted at Google Project Hosting http://code.google.com/p/plv8js/ and distributed by PGXN. For more detail, see http://pgxn.org/dist/plv8/doc/plv8.html
About
V8 Engine Javascript Procedural Language add-on for PostgreSQL
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published
Languages
- C++ 77.3%
- PLpgSQL 15.9%
- Dockerfile 1.7%
- CSS 1.5%
- Makefile 1.5%
- Shell 0.7%
- Other 1.4%