Sockets and posgtres

Поиск
Список
Период
Сортировка
Искать

Sockets and posgtres

От:
"J S B" <jsbali@gmail.com>
Дата:
Hi,
I'm trying to make my database a client for an external unix based deamon process acting as a server.
I was thinking of writing some clinet application in a shared object in the database (same as what we do with socket programing)  that does other Db
related activities as well.
Would be a right thing to do or we have specific tools available in postgres to accomplish such kind of things.

Thanks,
Jas

Re: Sockets and posgtres

От:
Jim Nasby <jim@nasby.net>
Дата:
On Sep 26, 2006, at 3:25 PM, J S B wrote:
> Hi,
> I'm trying to make my database a client for an external unix based  
> deamon process acting as a server.
> I was thinking of writing some clinet application in a shared  
> object in the database (same as what we do with socket programing)   
> that does other Db
> related activities as well.
> Would be a right thing to do or we have specific tools available in  
> postgres to accomplish such kind of things.

If I'm understanding what you're trying to do (have a function  
connect to an external process?), I don't think anything exists right  
now. But it shouldn't be too hard to write something to do that. You  
might want to create a generic utility and put it on pgFoundry in  
case others find it useful. Oracle has a package that allows for TCP  
(as well as other communications) from the database; looking at their  
interface might be useful.
--
Jim Nasby                                            jim@nasby.net
EnterpriseDB      http://enterprisedb.com      512.569.9461 (cell)


Re: Sockets and posgtres

От:
Tony Caduto <tony_caduto@amsoftwaredesign.com>
Дата:
Jim Nasby wrote:
>
> If I'm understanding what you're trying to do (have a function connect 
> to an external process?), I don't think anything exists right now. But 
> it shouldn't be too hard to write something to do that. You might want 
> to create a generic utility and put it on pgFoundry in case others 
> find it useful. Oracle has a package that allows for TCP (as well as 
> other communications) from the database; looking at their interface 
> might be useful.
> -- 
> Jim Nasby                                            jim@nasby.net
> EnterpriseDB      http://enterprisedb.com      512.569.9461 (cell)
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
>               http://www.postgresql.org/docs/faq
>
You can easily do that with PLperl

The funtion then connects to the server running on localhost, and sends 
some commands terminated with CRLF.

CREATE or REPLACE FUNCTION public.psendpopup(text,text)
RETURNS pg_catalog.varchar AS
$BODY$
use IO::Socket;
$sock = new IO::Socket::INET (
PeerAddr => 'localhost',
PeerPort => '32000',
Proto => 'tcp',
);
die "Could not create socket: $!\n" unless $sock;
print $sock "null\r\n";
print $sock "send_broadcast\r\n";
print $sock $_[0]."\r\n";
print $sock $_[1]."\r\n";

close($sock);
$BODY$
LANGUAGE 'plperlu' VOLATILE;


-- 
Tony Caduto
AM Software Design
http://www.amsoftwaredesign.com
Home of PG Lightning Admin for Postgresql
Your best bet for Postgresql Administration 

FAQ