Programming synchronicity
I spent this morning trying to set up PL/Ruby (Ruby for the PostgreSQL database) as an untrusted language. My motivation for this was to be able to use Ruby libraries from within the database in order to do some complex full-text indexing.
The difference between a trusted language is, basically, that a trusted language
- Can be used by any database user.
- Can’t do anything “dangerous” (which means anything involving files, and that includes libraries).
An untrusted language, by contrast
- Can only be used to create functions by a database superuser.
- Can do anything the full language can.
The PL/Ruby documentation didn’t mention how to use it as an untrusted language. Google was no help, either: apparently, no one else had ever tried. However, after searching through the source code, I discovered that not only was it possible, it was quite easy, too.
Coincidentally, someone else was also simultaneously solving the same problem with the help of PL/Ruby’s author.
There’s a strange synchronicity about it.