Thread

  1. Re: How to display a user-defined function? (2nd attempt)

    selkovjr@mcs.anl.gov — 2000-09-12T08:19:16Z

    Erich,
    
    This message appears to have been lost, so I am re-sending it. In the
    meanwhile, I found that I wasn't up to date on this. While my original
    response remains valid, you might also want to check this one out:
    
    http://x61.deja.com/[ST_rn=ps]/getdoc.xp?AN=634046478&CONTEXT=968745179.332202028&hitnum=1
    
    --Gene
    
       ----- Original message follows ----- 
    
    To: Erich <hh@cyberpass.net>
    cc: pgsql-general@postgresql.org
    From: selkovjr@mcs.anl.gov
    Reply-to: selkovjr@mcs.anl.gov
    Subject: Re: [GENERAL] How to display a user-defined function? 
    In-reply-to: <200009061940.MAA21210@cyberpass.net> 
    References: <200009061940.MAA21210@cyberpass.net>
    Comments: In-reply-to Erich <hh@cyberpass.net>
       message dated "Wed, 06 Sep 2000 12:40:21 -0700."
    Date: Wed, 06 Sep 2000 21:04:02 -0500
    Sender: selkovjr@selkovjr.xnet.com
    
    > I declared a function using CREATE FUNCTION.  Is there a way I can
    > display the function back?  I tried \df, etc, but I couldn't figure
    > out how to do it.
    
    This feature does not come without some procurement on your part
    
    At the same time when one registers a function, such as
    
    CREATE FUNCTION func(arg, arg, ...) RETURNS ret
            AS 'file' LANGUAGE 'lang';
    
    one also does
    
    INSERT INTO pg_description (objoid, description)
       SELECT oid, 'the function func(arg, arg, ...) does so and so and
    returns (ret)'::text
       FROM pg_proc
       WHERE proname = 'func'::name;
    
    Of course, you are also responsible for updating the description
    record every time you change or delete your function -- that is, every
    time the oid of your function invalidates. It's also nice to let the
    users (and yourself a while later) know about the arguments and the
    return type of your function.
    
    So when you delete it, you might want to do,
    
    DELETE FROM pg_description 
       WHERE (objoid)
       IN (
         SELECT oid
         FROM pg_proc
         WHERE proname = 'func'::name
       );
    
    DROP FUNCTION func(arg, arg, ...);
    
    Wish it worked sine cura, but it doesn't. Maybe it even shouldn't.
    
    --Gene
    
    > 
    > Thanks,
    > 
    > e
    > 
    > -- 
    > This message was my two cents worth.  Please deposit two cents into
    my
    > e-gold account by following this link:
    > http://rootworks.com/twocentsworth.cgi?102861
    > 275A B627 1826 D627 ED35  B8DF 7DDE 4428 0F5C 4454
    
    __
    The answer was my goverment's two cents worth. The DOE grant
    account DE-FG45-93R530280 has been automatically charged.
    Your Tax Cents at Work!