Professional Web Applications Themes

Private or publice function - PostgreSQL / PGSQL

Hi, How can I create a publice or private function? Nirmalya Lahiri __________________________________ Do you Yahoo!? Yahoo! Mail - 250MB free storage. Do more. Manage less. [url]http://info.mail./mail_250[/url] ---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match...

  1. #1

    Default Private or publice function

    Hi,
    How can I create a publice or private function?

    Nirmalya Lahiri



    __________________________________
    Do you Yahoo!?
    Yahoo! Mail - 250MB free storage. Do more. Manage less.
    [url]http://info.mail./mail_250[/url]

    ---------------------------(end of broadcast)---------------------------
    TIP 9: the planner will ignore your desire to choose an index scan if your
    joining column's datatypes do not match

    Nirmalya Lahiri Guest

  2. #2

    Default Re: Private or publice function

    Nirmalya Lahiri wrote:
    > Hi,
    > How can I create a publice or private function?
    I'm not sure the concept makes sense in PostgreSQL. Can you explain what
    you're trying to achieve?

    --
    Richard Huxton
    Archonet Ltd

    ---------------------------(end of broadcast)---------------------------
    TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to [email]majordomopostgresql.org[/email])

    Richard Huxton Guest

  3. #3

    Default Re: Private or publice function

    Thanks Richard,
    for your reply. Now I am explaining you what I want.
    Let I have 4
    functions......function_1(),function_2(),function_ 3(),function_4().


    create or replace function function_1() returns numeric as '
    begin
    create or replace function function_2() returns numeric as ''
    begin
    --------
    --------
    end;
    '' language plpgsql
    -----------
    -----------
    -----------
    create or replace function function_3() returns numeric as ''
    begin
    ---------
    ---------
    end;
    '' language plpgsql
    end ;
    ' language plpgsql



    create or replace function function_4() returns numeric as '
    begin
    -----------
    -----------
    end;
    ' language plpgsql


    Now after creating these functions, I can easily call every function
    from psql prompt. But I want to encapsulate function_2() and
    function_3() withen function_1(), so that no one can call
    function_2() and function_3() from psql prompt and from function_4(),
    only from withen the function_1() I can call function_2() and
    function_3().

    Is it possible in PostgreSQL?

    Nirmalya Lahiri


    --- Richard Huxton <devarchonet.com> wrote:
    > Nirmalya Lahiri wrote:
    > > Hi,
    > > How can I create a publice or private function?
    >
    > I'm not sure the concept makes sense in PostgreSQL. Can you explain
    > what
    > you're trying to achieve?
    >
    > --
    > Richard Huxton
    > Archonet Ltd
    >
    > ---------------------------(end of
    > broadcast)---------------------------
    > TIP 2: you can get off all lists at once with the unregister
    > command
    > (send "unregister YourEmailAddressHere" to
    > [email]majordomopostgresql.org[/email])
    >



    __________________________________
    Do you Yahoo!?
    Read only the mail you want - Yahoo! Mail SpamGuard.
    [url]http://promotions./new_mail[/url]

    ---------------------------(end of broadcast)---------------------------
    TIP 1: subscribe and unsubscribe commands go to [email]majordomopostgresql.org[/email]

    Nirmalya Lahiri Guest

  4. #4

    Default Re: Private or publice function

    Nirmalya Lahiri wrote:
    > Thanks Richard,
    > for your reply. Now I am explaining you what I want.
    > Let I have 4
    > functions......function_1(),function_2(),function_ 3(),function_4().
    [snip]
    > Now after creating these functions, I can easily call every function
    > from psql prompt. But I want to encapsulate function_2() and
    > function_3() withen function_1(), so that no one can call
    > function_2() and function_3() from psql prompt and from function_4(),
    > only from withen the function_1() I can call function_2() and
    > function_3().
    >
    > Is it possible in PostgreSQL?
    Not elegantly - plpgsql only has PostgreSQL's naming and permissions
    structure to use. Perhaps the simplest is to create a schema "private"
    only accessible to user "U1". Place function2(),function(3) in schema
    "private".
    Place function1() in the public schema, making sure you create it as
    user "U1" and mark it "SECURITY DEFINER".

    So - everyone can execute function1(), but only user U1 can run
    function2()/3(). Since function1() runs as user U1 everything should
    just work.

    --
    Richard Huxton
    Archonet Ltd

    ---------------------------(end of broadcast)---------------------------
    TIP 4: Don't 'kill -9' the postmaster

    Richard Huxton Guest

  5. #5

    Default Re: Private or publice function

    On Tue, Jan 11, 2005 at 18:36:17 +0000,
    Richard Huxton <devarchonet.com> wrote:
    > Nirmalya Lahiri wrote:
    > >Thanks Richard,
    > > for your reply. Now I am explaining you what I want.
    > >Let I have 4
    > >functions......function_1(),function_2(),function _3(),function_4().
    > [snip]
    > > Now after creating these functions, I can easily call every function
    > >from psql prompt. But I want to encapsulate function_2() and
    > >function_3() withen function_1(), so that no one can call
    > >function_2() and function_3() from psql prompt and from function_4(),
    > >only from withen the function_1() I can call function_2() and
    > >function_3().
    > >
    > > Is it possible in PostgreSQL?
    >
    > Not elegantly - plpgsql only has PostgreSQL's naming and permissions
    > structure to use. Perhaps the simplest is to create a schema "private"
    > only accessible to user "U1". Place function2(),function(3) in schema
    > "private".
    > Place function1() in the public schema, making sure you create it as
    > user "U1" and mark it "SECURITY DEFINER".
    >
    > So - everyone can execute function1(), but only user U1 can run
    > function2()/3(). Since function1() runs as user U1 everything should
    > just work.
    This is the right idea, but you can do it more elegantly using the
    EXECUTE privilege for functions. Postgres grants EXECUTE access to
    PUBLIC by default for functions, as they are usually meant to be
    public. But you can revoke that access and use the scheme above without
    needing to futz with schemas.

    ---------------------------(end of broadcast)---------------------------
    TIP 8: explain yze is your friend

    Bruno Wolff III Guest

Similar Threads

  1. #39474 [NEW]: Object private attributes displays with list function
    By josefinarey at yahoo dot com dot ar in forum PHP Bugs
    Replies: 1
    Last Post: November 12th, 06:56 PM
  2. Private class function
    By ASP-ASP in forum Macromedia Flash Actionscript
    Replies: 0
    Last Post: February 7th, 04:30 AM
  3. Replies: 0
    Last Post: July 31st, 07:30 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139