The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Installing untrusted PL/Ruby for PostgreSQL

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Robby Russell

Posts: 981
Nickname: matchboy
Registered: Apr, 2005

Robby Russell is the Founder & Executive Director PLANET ARGON, a Ruby on Rails development firm
Installing untrusted PL/Ruby for PostgreSQL Posted: Aug 23, 2005 9:22 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Robby Russell.
Original Post: Installing untrusted PL/Ruby for PostgreSQL
Feed Title: Robby on Rails
Feed URL: http://www.contegix.com/rss/feed.xml
Feed Description: My reflections on programming with Ruby, Rails, PostgreSQL... and learning how to run a business...
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Robby Russell
Latest Posts From Robby on Rails

Advertisement

This is going to be short and sweet.

”PL/Ruby is a loadable procedural language for the Postgres database system that enable the Ruby language to create functions and trigger procedures”

Method 1. The standard, safe, PL/Ruby.

Before running this, you need to have all the PostgreSQL headers installed. (se INSTALL in the postgresql directory) make install-all-headers

To install PL/Ruby, you need to download the tarball from here. As you can see, I download it with wget and then install like I would any ruby library. (maybe plruby could become a gem?)

cd /usr/local/src
wget ftp://moulon.inra.fr/pub/ruby/plruby.tar.gz
tar zxvf plruby.tar.gz
cd plruby
ruby extconf.rb
make
make install

Method 2: The untrusted, but super cool PL/Ruby.

Guy Decoux, author of PL/Ruby, was kind enough to share a secret about the PL/Ruby install. (from his email…)

Well plruby normally run with $SAFE = 12, this value if fixed at compile time. 

Now it has an undocumented option, if you compile it with

ruby extconf.rb --with-safe-level=0 ...

 it will run with $SAFE = 0 and you have the equivalent of an untrusted language.

Pretty simple solution, eh?

On my server I was able to run the following:

cd /usr/local/src
wget ftp://moulon.inra.fr/pub/ruby/plruby.tar.gz
tar zxvf plruby.tar.gz
cd plruby
sudo ruby extconf.rb \ --with-pgsql-dir=/usr/local/pgsql-8.0 \ --with-safe-level=0 \ --with-suffix=u
make
make install

Update: the --with-suffix=u was added after someone commented on this. This allows you to install plruby and plrubyu.

Installing PL/Ruby in PostgreSQL Up until now, you haven’t actually installed the language into the database. We’re close though!

All that you need to do is run the following commands to install it to a specific database in your server.

$ psql template1
template1=# CREATE DATABASE plruby;
CREATE DATABASE
template1=# \c plruby
You are now connected to database "plruby".
plruby=#    create function plruby_call_handler() returns language_handler
plruby-#    as '/usr/lib/site_ruby/1.8/i386-linux/plruby.so'
plruby-#    language 'C';
CREATE FUNCTION
plruby=#    create  language 'plruby'
plruby-#    handler plruby_call_handler
plruby-#    lancompiler 'PL/Ruby';
CREATE LANGUAGE
plruby=#

That should be all there is to it!

Where do we go from here?

See my post: PL/Ruby loves RubyGems and DRb

Read: Installing untrusted PL/Ruby for PostgreSQL

Topic: Improving the ActiveRecord Experience Previous Topic   Next Topic Topic: RubyConf 2005, here I come!

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use