Thread: virtual fields ( proxy execution ?? )

virtual fields ( proxy execution ?? )

From
paulmoody
Date:
Hi,
    My first post to this list ... pls point me to correct list if
wrong. Now my question ...
Can I reference a field in a record where the data contained in the
field is a value returned or passed to an arbitrary executable. For
example say the arbitrary executable was a mail program then writing to
the field would send a message and reading from the field would retrieve
a message. However for all intents and purposes there would be no
difference perceived by the query orginator than if the message was
merely stored or retrieved from that field. ( ie is there a 'CGI' type
interface for postgresql like for webservers ? ).
 TIA  and regards.


Re: [GENERAL] virtual fields ( proxy execution ?? )

From
Chris Bitmead
Date:
I'm a bit vague on what you mean. Are you saying you want to be able to
say to postgres...

INSERT INTO message(to,subject,body) VALUES ('fred@foo.com', 'Hello',
'How\'s it going');

and instead of storing a message into postgres, it will send a mail
message to fred?

Then you want to say...
SELECT to, subject, body FROM messages;

And have a list of mail messages be returned, not from postgres tables,
but from your UNIX mailbox?

Just want to be clear on what you are asking.


paulmoody wrote:
>
> Hi,
>     My first post to this list ... pls point me to correct list if
> wrong. Now my question ...
> Can I reference a field in a record where the data contained in the
> field is a value returned or passed to an arbitrary executable. For
> example say the arbitrary executable was a mail program then writing to
> the field would send a message and reading from the field would retrieve
> a message. However for all intents and purposes there would be no
> difference perceived by the query orginator than if the message was
> merely stored or retrieved from that field. ( ie is there a 'CGI' type
> interface for postgresql like for webservers ? ).
>  TIA  and regards.

--
Chris Bitmead
http://www.bigfoot.com/~chris.bitmead
mailto:chris.bitmead@bigfoot.com

Re: [GENERAL] virtual fields ( proxy execution ?? )

From
paulmoody
Date:
Hi
    Err maybe that was a bad example. How about this ... I have ( not really )
a large number of programmable power supplies connected to my remote Linux box
where the details about each supply are stored in a database.( eg 100 supplies
= 100 records ). One of the fields in each record might be called voltage. If
I query a particular field then the current voltage of the supply is returned.
If I write to that same field then that particular supply would have its
voltage adjusted to the written value. This would allow me to manipulate the
power supply parameters using SQL and would be a powerful ( no pun  ) tool for
doing all sorts of things in response to alarms etc ( including sending email
).

Thanks again.

Chris Bitmead wrote:

> I'm a bit vague on what you mean. Are you saying you want to be able to
> say to postgres...
>
> INSERT INTO message(to,subject,body) VALUES ('fred@foo.com', 'Hello',
> 'How\'s it going');
>
> and instead of storing a message into postgres, it will send a mail
> message to fred?
>
> Then you want to say...
> SELECT to, subject, body FROM messages;
>
> And have a list of mail messages be returned, not from postgres tables,
> but from your UNIX mailbox?
>
> Just want to be clear on what you are asking.
>


Re: [GENERAL] virtual fields ( proxy execution ?? )

From
jim@reptiles.org (Jim Mercer)
Date:
> Hi
>     Err maybe that was a bad example. How about this ... I have ( not really )
> a large number of programmable power supplies connected to my remote Linux box
> where the details about each supply are stored in a database.( eg 100 supplies
> = 100 records ). One of the fields in each record might be called voltage. If
> I query a particular field then the current voltage of the supply is returned.
> If I write to that same field then that particular supply would have its
> voltage adjusted to the written value. This would allow me to manipulate the
> power supply parameters using SQL and would be a powerful ( no pun  ) tool for
> doing all sorts of things in response to alarms etc ( including sending email
> ).
>
> Thanks again.

looks like an application for triggers.

--
[ Jim Mercer    Reptilian Research      jim@reptiles.org   +1 416 410-5633 ]
[ The telephone, for those of you who  have forgotten, was a commonly used ]
[ communications technology in the days before electronic mail.            ]
[ They're still easy to find in most large cities. -- Nathaniel Borenstein ]

Re: [GENERAL] virtual fields ( proxy execution ?? )

From
Chris Bitmead
Date:
You can set up a trigger to be activated on any event such as UPDATE.
The trigger calls a function which may be a C function. The trigger can
take arguments. So I would say if you wrote a C function which
execve()'s its arguments that would be what you want.

I agree that it sounds useful enough that such a function should perhaps
be a standard part of postgres. Perhaps if you implement it you could
donate it to the core code. (unless there's already one there I don't
know about).

paulmoody wrote:
>
> Hi
>     Err maybe that was a bad example. How about this ... I have ( not really )
> a large number of programmable power supplies connected to my remote Linux box
> where the details about each supply are stored in a database.( eg 100 supplies
> = 100 records ). One of the fields in each record might be called voltage. If
> I query a particular field then the current voltage of the supply is returned.
> If I write to that same field then that particular supply would have its
> voltage adjusted to the written value. This would allow me to manipulate the
> power supply parameters using SQL and would be a powerful ( no pun  ) tool for
> doing all sorts of things in response to alarms etc ( including sending email
> ).
>
> Thanks again.
>
> Chris Bitmead wrote:
>
> > I'm a bit vague on what you mean. Are you saying you want to be able to
> > say to postgres...
> >
> > INSERT INTO message(to,subject,body) VALUES ('fred@foo.com', 'Hello',
> > 'How\'s it going');
> >
> > and instead of storing a message into postgres, it will send a mail
> > message to fred?
> >
> > Then you want to say...
> > SELECT to, subject, body FROM messages;
> >
> > And have a list of mail messages be returned, not from postgres tables,
> > but from your UNIX mailbox?
> >
> > Just want to be clear on what you are asking.
> >

--
Chris Bitmead
http://www.bigfoot.com/~chris.bitmead
mailto:chris.bitmead@bigfoot.com