Replies: 3 comments
-
There used to be a "convert issue to discussion", but it has disapeared 🙄 This is a tough nut to crack. While allowing simple plv8 functions creations (like the hello world you provided) might be simple, having something actually useful (like supporting plv8-git) is pretty hard. Here are my reflections on your specific use case:
db.public.registerLanguage('plv8', code => eval(code)); ... which would actually be more elegant, since it allows declaring arbitrary languages.
So in the end, it seems reacheable, but a bit complicated compared to what it does. But that's definitely an appealing idea :) |
Beta Was this translation helpful? Give feedback.
-
Fair enough - for a very limited use case this wouldn't be too hard to implement as a user of pg-mem anyway, so maybe I'll take a look at doing it specifically for plv8-git at some point (if triggers/function syntax are supported one day). I love the idea of |
Beta Was this translation helpful? Give feedback.
-
There's a new Discussions tab at top, new feature on GitHub |
Beta Was this translation helpful? Give feedback.
-
It occurred to me that as well as the API-way of registering a function:
Might it also be possible to enable "real" functions defined via SQL, as long as they use
language
plv8?e.g.
If pgsql-ast-parser is able to parse the
create function
query, it could be automatically mapped to the arguments required forregisterFunction
, whereimplementation
is theeval(...)
result of the body. That way, at least for plv8 functions, it'd be totally valid both in pg-mem and real postgres.I'm interested in this as I have a library which implements row tracking through an in-memory JS git implementation: https://npmjs.com/package/plv8-git - I'm super curious if pg-mem could be used somehow to come full circle and even run the database in memory too.
Edit: just seen you have discussions enabled. I would have created this over there if I'd noticed, since it's not an issue. Feel free to move if you prefer it there too!
Beta Was this translation helpful? Give feedback.
All reactions