From: | Emanuel Calvo Franco <postgres(dot)arg(at)gmail(dot)com> |
---|---|
To: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> |
Cc: | Laura Martinelli <lmartinelli(at)mail(dot)unlu(dot)edu(dot)ar>, pgsql-es-ayuda(at)postgresql(dot)org, lmartinelli(at)unlu(dot)edu(dot)ar |
Subject: | Re: [pgsql-es-ayuda] Re[2]: Finalizar sesión de usuario activa |
Date: | 2009-04-15 21:17:17 |
Message-ID: | f205bb120904151417q6e0f0ebftd7a092689276b40b@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
El día 14 de abril de 2009 17:31, Alvaro Herrera
<alvherre(at)alvh(dot)no-ip(dot)org> escribió:
> Emanuel Calvo Franco escribió:
>
>> bastaria con corroborar que el parametro concuerde y que sea distinto
>> de pg_backend_pid().
>
> Justamente ... escribir la función completa es sólo un SMOP
>
> --
> Alvaro Herrera Developer, http://www.PostgreSQL.org/
> "Everybody understands Mickey Mouse. Few understand Hermann Hesse.
> Hardly anybody understands Einstein. And nobody understands Emperor Norton."
>
-- Esta función recibe como parámetro el numero del backend
-- que se desea matar.
create or replace function pg_terminate_backend_test(int) returns int
language plperlu security definer volatile as $$
$pid = shift;
my $myPid = spi_exec_query('select pg_backend_pid();');
if ($pid == $myPid->{rows}[0]->{pg_backend_pid}){
elog(WARNING, "Este pid pertenece al backend actual.");
return 1;
}
my $othersesions = spi_exec_query('SELECT procpid FROM pg_stat_activity
EXCEPT SELECT pg_backend_pid()::int;');
my $numRows = $othersesions->{processed};
foreach my $rn (0 .. $numRows - 1) {
my $rs = $othersesions->{rows}[$rn];
if ($rs->{procpid} == $pid){
$ret = kill TERM, $pid;
elog WARNING, "could not send signal TERM to $pid: $!" unless $ret == 1;
return $ret;
}
}
elog(WARNING, "Este pid no pertenece a un backend activo.");
return 1;
$$;
me quedó algo así... quizás le encuentre algo para modificar...
--
Emanuel Calvo Franco
Sumate al ARPUG !
(www.postgres-arg.org -
www.arpug.com.ar)
ArPUG / AOSUG Member
Postgresql Support & Admin
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2009-04-15 21:25:44 | Re: Re[2]: Finalizar sesión de usuario activa |
Previous Message | Arturo Munive | 2009-04-15 20:31:28 | Re: funciones de depuracion [Solucionado] |