Re: session persistent data for plperl

Поиск
Список
Период
Сортировка
От Thomas Hallgren
Тема Re: session persistent data for plperl
Дата
Msg-id c05t4e$21v8$1@news.hub.org
обсуждение исходный текст
Ответ на session persistent data for plperl  (Andrew Dunstan <andrew@dunslane.net>)
Ответы Re: session persistent data for plperl  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: session persistent data for plperl  (Andrew Dunstan <andrew@dunslane.net>)
Список pgsql-hackers
What about transactions? Let's say the first call was in a transaction
that's been rolled back. Semantically, that means the call never happened.
If you maintain the session data in a table, everything is fine of course.
But if it's in memory the solution has some rather nasty implications to it.

This is one scenario where I think it would be useful if the backend
provided some transaction callback mechanisms (discussed in this group
earlier under topic "Transaction callback"). That would enable the
implementation of "transaction aware session persistent data" in memory.

Regards,

- thomas

"Andrew Dunstan" <andrew@dunslane.net> wrote in message
news:402672F4.4050905@dunslane.net...
>
> The attached tiny patch (not intended for application yet) provides a
> space for plperl functions to create and share session persistent data,
> which I should think would increase the utility of plperl. Essentially
> it creates a hash called %session_globals which it then injects into the
> safe container where plperl functions live.
>
> Comments are welcome - this is just a proof of concept. If this seems
> good to people, I will try to use a similar mechanism to "register"
> plperl functions so they can call each other.
>
> cheers
>
> andrew
>
> (stupid) example use (using dollar quoting in psql ;-) ):
>
> andrew=# create function perlfunc() returns text language plperl as $$
> andrew$# if (!exists $session_globals{x}) { $session_globals{x} =
> 'abcxyz'; }
> andrew$# return $session_globals{x}++;
> andrew$# $$;
> CREATE FUNCTION
> andrew=# select perlfunc();
>  perlfunc
> ----------
>  abcxyz
> (1 row)
>
> andrew=# select perlfunc();
>  perlfunc
> ----------
>  abcxza
> (1 row)
>
> andrew=# create function perlfunc2() returns text language plperl as $$
> andrew$# if (!exists $session_globals{x}) { $session_globals{x} =
> 'abcxyz'; }
> andrew$# $session_globals{x} = reverse $session_globals{x};
> andrew$# return $session_globals{x}++;
> andrew$# $$;
> CREATE FUNCTION
> andrew=# select perlfunc2();
>  perlfunc2
> -----------
>  bzxcba
> (1 row)
>
> andrew=# select perlfunc2();
>  perlfunc2
> -----------
>  bbcxzb
> (1 row)
>
> andrew=# select perlfunc();
>  perlfunc
> ----------
>  bbcxzc
> (1 row)
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
>




В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andrew Dunstan
Дата:
Сообщение: Re: session persistent data for plperl
Следующее
От: Tom Lane
Дата:
Сообщение: Re: RFC: Security documentation