Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Sure, use a language that has access to some kind of shared global variable. For example %_SHARED in plperl:

Something like:

  CREATE OR REPLACE FUNCTION set_foo(name text) returns void as   $$
        my $name = shift;
        die "set_foo() has already been called" if   ($_SHARED{'set_foo'});
        $_SHARED{'set_foo'} = $name;
  $$
  LANGUAGE plperl;


  CREATE OR REPLACE FUNCTION get_foo() returns text as $$
        my $name = shift;
        return $_SHARED{'set_foo'} || 'nobody';
  $$
It would be fairly trivial to extend that to support calling set_foo() once per transaction by checking against txid_current(). But if users can create plperl functions and the worry is sql injection-- It should be easy to write the same thing in C.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: