Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dimensionsoftware/plv8js
A fork of plv8 intending to add commonjs require and updated livescript support
https://github.com/dimensionsoftware/plv8js
Last synced: about 2 months ago
JSON representation
A fork of plv8 intending to add commonjs require and updated livescript support
- Host: GitHub
- URL: https://github.com/dimensionsoftware/plv8js
- Owner: DimensionSoftware
- License: other
- Created: 2013-02-06T14:53:55.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2013-02-06T15:13:09.000Z (almost 12 years ago)
- Last Synced: 2024-04-09T14:26:02.833Z (9 months ago)
- Language: C++
- Size: 531 KB
- Stars: 1
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README
- Changelog: Changes
Awesome Lists containing this project
README
NOTE: This is a fork of PLV8. The official maintained package can be found at:
http://code.google.com/p/plv8js/wiki/PLV8
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.Changes From Official Version
------------------------------ Added CommonJS module system
- Added require()
- Added initialization scriptSystem-wide modules live in /usr/local/plv8/lib.
User modules live in /usr/local/plv8/plv8_modules.
REQUIREMENT
-----------plv8 is tested with:
- PG: version 8.4, 9.0, 9.1, 9.2 and 9.3dev (maybe older are allowed)
- V8: version 3.14.5
- g++: version 4.5.1Also all tools that PostgreSQL and V8 require to be built are required.
INSTALL
-------There are two ways to build plv8. The first is default `make`, which depends
on system-installed libv8 and plv8 will be dynamically link to it. The second
is `make static`, which will download v8 soure at a specific version and build
it, and statically link plv8 to it. PGXN install will use the former, while
you can do the latter manually if you have not installed v8 yet.Once you installed plv8 into your dabase, create language via
$ psql -c 'CREATE EXTENSION plv8'
$ psql -c 'CREATE EXTENSION plls'
$ psql -c 'CREATE EXTENSION plcoffee'in 9.1 or later, or in the prior versions
$ psql -f plv8.sql
to create database objects.
In mingw64, you may have difficulty in building plv8. If so, try to make
the following changes in Makefile.CUSTOM_CC = gcc
SHLIB_LINK := $(SHLIB_LINK) -lv8 -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic -lmFor more detail, please refer to http://code.google.com/p/plv8js/issues/detail?id=29
TEST
----plv8 supports installcheck test. Make sure set custom_variable_classes = 'plv8'
in your postgresql.conf (before 9.2) and run$ make installcheck
EXAMPLE (JAVASCRIPT)
--------------------CREATE OR REPLACE FUNCTION plv8_test(keys text[], vals text[])
RETURNS text AS $$
var o = {};
for(var i=0; i
o[key] = vals[idx]; return o), {}), {})
$$ LANGUAGE plcoffee IMMUTABLE STRICT;
SELECT plcoffee_test(ARRAY['name', 'age'], ARRAY['Tom', '29']);
plcoffee_test
---------------------------
{"name":"Tom","age":"29"}
(1 row)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)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