Register
It is currently Mon Apr 21, 2014 6:09 am

PL/sh is a procedural language handler for PostgreSQL


All times are UTC - 6 hours


Post new topic Reply to topic  [ 1 post ] 
Author Message
 PostPosted: Mon Oct 24, 2005 8:43 am   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 657
Location: Des Moines, Iowa
http://plsh.projects.postgresql.org/

Quote:
Overview

PL/sh is a procedural language handler for PostgreSQL that allows you to write stored procedures in a shell of your choice. For example,

CREATE FUNCTION concat(text, text) RETURNS text AS '
#!/bin/sh
echo "$1$2"
' LANGUAGE plsh;

The first line must be a #!-style line that indicates the shell to use. The rest of the function body will be executed by that shell in a separate process. The arguments are available as $1, $2, etc., as usual. (This is the shell's syntax. If your shell uses something different then that's what you need to use.) The return value will become what is printed to the standard output. If anything is printed to the standard error, then the function aborts with an error and the message is printed. If the script does not exit with status 0 then an error is raised as well.

The shell script can do anything you want, but you can't access the database. Trigger functions are also possible, but they can't change the rows. Needless to say, this language should not be declared as TRUSTED.
Download

Souce code distributions are available here: http://pgfoundry.org/projects/plsh/

To build and install it, use this procedure:

./configure --prefix=YOUR_CHOICE CPPFLAGS=-I/where/ever/pgsql/src/include
make
make install

To declare the language in a database, use

psql -d DBNAME -f PREFIX/share/pgplsh/createlang_pgplsh.sql

with a server running. To drop it, simply use droplang pgplsh.


Top
 Profile WWW  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Majestic-12 [Bot] and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP