Thread

  1. hi, i write a function in postgresql source code, how to register this function?

    sunpeng <bluevaley@gmail.com> — 2010-06-16T16:42:25Z

    hi,i write a function in postgresql source code, how to register this
    function?
    it is not an aggregate function.
    i don't use 34.3"User-Defined Functions" described in
    http://www.postgresql.org/docs/8.4/interactive/xfunc.html, i just write it
    in postgresql sourcecode, how to register this function to let final  user
    use? Should i only add one tuple in pg_process table? how to add ?
    thanks!
    peng
    
  2. Re: hi,i write a function in postgresql source code, how to register this function?

    Raymond O'Donnell <rod@iol.ie> — 2010-06-16T18:31:39Z

    On 16/06/2010 17:42, sunpeng wrote:
    > hi,i write a function in postgresql source code, how to register this
    > function?
    > it is not an aggregate function.
    > i don't use 34.3"User-Defined Functions" described in
    > http://www.postgresql.org/docs/8.4/interactive/xfunc.html, i just write
    > it in postgresql sourcecode, how to register this function to let final 
    > user use? Should i only add one tuple in pg_process table? how to add ?
    
    What do you mean by "PostgreSQL source code"? - SQL? pl/pgsql?
    
    Generally, you just execute the following SQL command:
    
        create or replace function my_function(.....) returns [return type]
        as
        $$
           [function code here]
        $$
        language [whatever - usually sql or plpgsql] ;
    
    
    ....or am I missing something in your question?
    
    Ray.
    
    
    -- 
    Raymond O'Donnell :: Galway :: Ireland
    rod@iol.ie
    
    
  3. Re: hi,i write a function in postgresql source code, how to register this function?

    sunpeng <bluevaley@gmail.com> — 2010-06-16T19:02:22Z

    It's just in postgresql 8.4 source code,e.g in
    /backend/executor/functions.c, not in sql,not in pl/pgsql
    
    
    2010/6/16 Raymond O'Donnell <rod@iol.ie>
    
    > On 16/06/2010 17:42, sunpeng wrote:
    > > hi,i write a function in postgresql source code, how to register this
    > > function?
    > > it is not an aggregate function.
    > > i don't use 34.3"User-Defined Functions" described in
    > > http://www.postgresql.org/docs/8.4/interactive/xfunc.html, i just write
    > > it in postgresql sourcecode, how to register this function to let final
    > > user use? Should i only add one tuple in pg_process table? how to add ?
    >
    > What do you mean by "PostgreSQL source code"? - SQL? pl/pgsql?
    >
    > Generally, you just execute the following SQL command:
    >
    >    create or replace function my_function(.....) returns [return type]
    >    as
    >    $$
    >       [function code here]
    >    $$
    >    language [whatever - usually sql or plpgsql] ;
    >
    >
    > ....or am I missing something in your question?
    >
    > Ray.
    >
    >
    > --
    > Raymond O'Donnell :: Galway :: Ireland
    > rod@iol.ie
    >
    
  4. Re: hi, i write a function in postgresql source code, how to register this function?

    Adrian von Bidder <avbidder@fortytwo.ch> — 2010-06-16T20:00:58Z

    Hi,
    
    On Wednesday 16 June 2010 18.42:25 sunpeng wrote:
    > hi,i write a function in postgresql source code, how to register this
    > function?
    > it is not an aggregate function.
    > i don't use 34.3"User-Defined Functions" described in
    > http://www.postgresql.org/docs/8.4/interactive/xfunc.html, i just write
    > it in postgresql sourcecode, how to register this function to let final 
    > user use? Should i only add one tuple in pg_process table? how to add ?
    
    Perhaps, before thinking about the low-level implementation (where you wrote 
    the function): could you describe what you are trying to do and why you 
    think that you can not (or should not) do this with the usual pg extension 
    mechanisms as described in chapter 34 of the documentation?
    
    In my experience, PostgreSQL can be made to do almost everything and needs 
    changes to the core code only in very rare cases.
    
    If you've already written the code in C, perhaps you can adapt it to work as 
    a DSO as described in chapter 34.9 [1]?  I've never done this, but from my 
    understanding a C language module has nearly full access to all server 
    internals, so what you are doing in functions.c should also be possible from 
    an external module.
    
    cheers
    -- vbi
    
    [1] <http://www.postgresql.org/docs/8.4/interactive/xfunc-c.html>
    
    -- 
    featured product: vim - http://vim.org
    
  5. Re: hi, i write a function in postgresql source code, how to register this function?

    Dimitri Fontaine <dfontaine@hi-media.com> — 2010-06-17T08:43:02Z

    sunpeng <bluevaley@gmail.com> writes:
    
    > hi,i write a function in postgresql source code, how to register this function?
    
    See src/include/catalog/pg_proc.h
    
    But you should *really* consider making it a loadable module. That's the
    way it makes sense for any code you want to add in the server unless
    you're preparing a patch for PostgreSQL itself, or you're doing a new
    Index Access Method that you want crash safe.
    
    Regards,
    -- 
    dim