Questions tagged [plv8]

A Javascript procedural language add-on for PostgreSQL

A procedural language add-on for PostgreSQL that embeds Google's v8 Javascript interpreter in the PostgreSQL RDBMS, allowing you to write native Javascript functions and stored procedures.

Project page: http://code.google.com/p/plv8js/

56 questions
3
votes
1 answer

Heroku hosted PostgreSQL and PLV8

Does anyone know if Heroku is supporting PLV8, yet? I watched a video from RailsConf 2012 where a member of the Heroku team talks here about how to use it with hstore, but I got the feeling this was what they do for internal projects. Google'ing…
David S
  • 12,967
  • 12
  • 55
  • 93
3
votes
1 answer

PostgreSQL function returning an arbitrary type

Is there any way to have a function in PostgreSQL return an arbitrary type? I am trying to use PLV8 to grab and compare fields from a JSON type in PostgreSQL 9.2. The following works: CREATE or replace FUNCTION jn (j json, key any ) RETURNS numeric…
Toby Hede
  • 36,755
  • 28
  • 133
  • 162
2
votes
1 answer

How do you return rows of JSON in a plv8 function in Postgres?

I'm having trouble wrapping my head around this context. Here's my first take at this using some of the built in functions: What I've tried so far SELECT json_build_object('id', MD5(c.id), 'firstName', c.first_name, 'lastName', c.last_name,…
Sean Lindo
  • 1,387
  • 16
  • 33
2
votes
2 answers

It's possible to call functions in another schema from within plv8 functions?

I'm trying to use plv8 to write postgres functions. Now I would like to use the pgcrypt library in a way like this: CREATE OR REPLACE FUNCTION v01.myfunction(arg json) RETURNS json AS $BODY$ var res; res = obj.crypt(arg.password, res); …
Rainer
  • 1,067
  • 2
  • 14
  • 29
2
votes
1 answer

How to log a string in a postgres plv8 procedure?

I am trying to print a sql query using plv8.elog() in a plv8 procedure. plv8.elog(NOTICE, 'Notice:', str); I don't know why but I am unable to see any output on the console. I searched for the possible solution and found a useful information that…
Anant
  • 3,047
  • 2
  • 27
  • 33
2
votes
1 answer

immutable strict ignored by plv8 function

I thought immutable strict ment the database could not be modified. The following inserts a new row in 'some_table': CREATE FUNCTION insert_row() RETURNS void AS $$ plv8.execute('INSERT INTO some_table (number) VALUES ($1)', [123]); $$ LANGUAGE…
Jacob
  • 1,642
  • 2
  • 15
  • 27
1
vote
0 answers

Is there a way to use a regular expression with the unicode category in Postgres?

I have a table with a username field and want to allow only letters, but include letters from all languages (including Umlauts). So I added a check to that field with a regular expression. That’s where the unicode category would be perfect:…
enyo
  • 16,269
  • 9
  • 56
  • 73
1
vote
0 answers

Is it possible to debug plv8 script direct from IntelIJ IDEA?

IntelliJ IDEA 2022.1.3 (Community Edition) PostgreSQL 9.6 In my java project I use plv8 scripts. Example: var oids_per_vlan_json = JSON.parse(oids_per_vlan); var table_name = plv8.execute("SELECT get_temp_table_name() as name")[0].name;…
Alexei
  • 14,350
  • 37
  • 121
  • 240
1
vote
2 answers

Postgres: Install a specific version of plv8

I'm installing plv8 in docker: FROM postgres:13 AS build ENV PLV8_VERSION=v3.0.0 RUN apt-get update && apt-get upgrade \ && apt-get install -y git curl glib2.0 libc++-dev python python3-pip libv8-dev postgresql-server-dev-$PG_MAJOR…
Kong
  • 8,792
  • 15
  • 68
  • 98
1
vote
0 answers

Can't install pvl8 v.2.3.15: Regenerating ninja files - FAILED: build.ninja

Linux Mint 20.2 , kernel 5.11.0-25-generic I want to install plv8-2.3.15 Help here: https://github.com/plv8/plv8/blob/v2.3.15/docs/BUILDING.md Installed the next packages: sudo apt-get update sudo apt install git sudo apt install python2 sudo apt…
Alexei
  • 14,350
  • 37
  • 121
  • 240
1
vote
1 answer

Cannot install plv8 for Postgres 12 on Windows

I have downloaded the plv8 installation package from xTuple using this link. I have run the installation batch file in that package. I've checked the relevant files are now in bin, lib and share/extension. I have given my user superuser permissions…
cbp
  • 25,252
  • 29
  • 125
  • 205
1
vote
1 answer

Use mustache templates with PostgreSQL and JSONb inputs

Is time to use JSONb datatype as input in a template, and PostgreSQL queries as template system... Mustache will be perfect, if there are some Mustache implementation for PLpgSQL (or adapted for C)... Seems there are no one. But there are a good…
Peter Krauss
  • 13,174
  • 24
  • 167
  • 304
1
vote
0 answers

Heroku and plv8 support error

I would like to use the plv8 extension on heroku. I followed the official tutorial, but however when I connect to psql console on heroku and try to add the extension: create extension PLV8; I get the following error: ERROR: could not open…
1
vote
1 answer

How to insert composite type plv8

I have created a db structure with a composite type array. I would like to insert some values using plv8, but I can't find the correct structure to insert this array. The error I'm getting is: ERROR: malformed record literal: "[object Object]" SQL…
DavidVdd
  • 1,020
  • 3
  • 17
  • 40
1
vote
2 answers

Access PostGIS Functions from plv8

I am trying to write a plv8 function that returns an integer representing a UTM zone value. The function utilizes PostGIS functions. Here is the (not-functioning) idea: CREATE OR REPLACE FUNCTION utm_z(geometry) RETURNS integer AS $$ var…
Joebocop
  • 539
  • 3
  • 9
  • 17