From: | "Billow Gao" <billowgy(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Can a C function(server program) be a UDP or TCP server? |
Date: | 2007-10-18 16:27:59 |
Message-ID: | 677a32120710180927g4f437e00tb5c534438b488d9e@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Thanks. This is what I want to know :-)
Regards,
Billow
>Yeah, what he wants is to implement a function in Postgres which does
>something like an LDAP or DNS lookup or something like that.
>Sure you can do this. The only tricky bit is the thing you mentioned about
>reusing the connection. You could always leave the connection in a safe
state
>and don't need to worry about cleaning it up then you could just store it
in a
>static variable which would be the simplest option.
>If you want to use Postgres's facilities for allocating memory and cleaning
it
>up when no longer in use you can use some of the Postgres internal API for
>memory contexts and resource owners. But I don't see any particular reason
you
>should need to worry about this stuff for something simple you're
implementing
>yourself.
On 10/18/07, D'Arcy J.M. Cain <darcy(at)druid(dot)net> wrote:
>
> On Thu, 18 Oct 2007 11:24:24 -0400
> "Billow Gao" <billowgy(at)gmail(dot)com> wrote:
> > I can write the network program.
> > But I am not 100% sure whether I can add the c-language function (
> > http://www.postgresql.org/docs/8.2/interactive/xfunc-c.html)
> > to PostgreSQL. The function will be dynamic loaded by PostgreSQL.
> > I want to know whether there are any limitation on the function I wrote.
> >
> > for example:
> > If I want to write a function:
> >
> > PG_FUNCTION_INFO_V1(c_talktoremoteudp);
> >
> >
> > And use it in PostgreSQL like:
> >
> > =========================================
> > SELECT name, c_talktoremoteudp
> >
> > (emp, 1500) AS overpaid
> > FROM emp
> > WHERE name = 'Bill' OR name = 'Sam';
> >
> > =========================================
> > The function c_talktoremoteudp will:
> > 1. send udp data to remote udp server
> > 2. monitor an udp port and wait for the reply
> > 3. return the data to the select query.
>
> I am confused. The dynamic function resides in the server. The query
> runs in the server. Where is the "remoteness" in any of this? Are you
> saying that there is a second server that is not PostgreSQL that uses
> UDP that you want to communicate with and merge info into the
> PostgreSQL server from?
>
> --
> D'Arcy J.M. Cain <darcy(at)druid(dot)net> | Democracy is three wolves
> http://www.druid.net/darcy/ | and a sheep voting on
> +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
>
From | Date | Subject | |
---|---|---|---|
Next Message | Kevin Grittner | 2007-10-18 17:16:06 | Re: max_prepared_transactions default ... why 5? |
Previous Message | Gregory Stark | 2007-10-18 16:23:47 | Re: max_prepared_transactions default ... why 5? |