Re: Is it possible to stop sessions killing eachother when they all authorize as the same role?

From: Guillaume Lelarge <guillaume(at)lelarge(dot)info>
To: Bryn Llewellyn <bryn(at)yugabyte(dot)com>
Cc: Tom Lane PostgreSQL <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, pgsql-general list <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Is it possible to stop sessions killing eachother when they all authorize as the same role?
Date: 2022-09-13 19:57:55
Message-ID: CAECtzeVR=85LZK10dmcH-ChUHu+UMqhCJUr7Vw2EWUXE_7yYgA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

This won't answer your question but still... I usually really like your
scripts, it's nicely written, but this part seems really weird to me:

Le mar. 13 sept. 2022 à 20:23, Bryn Llewellyn <bryn(at)yugabyte(dot)com> a écrit :

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> *-- No errordo $body$declare p int not null := 0;begin for p in (
> select pid from pg_stat_activity where backend_type = 'client
> backend' and pid <> pg_backend_pid()) loop perform
> pg_terminate_backend(p); end loop;end;$body$;*
>

While your script works great, I'm wondering why you don't write it this
way:

SELECT pg_terminate_backend(pid) FROM pg_stat_activity
WHERE backend_type = 'client backend' AND pid <> pg_backend_pid();

As it is less code, it's quicker to understand what it does.

--
Guillaume.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jeremy Smith 2022-09-13 20:11:04 Re: Is it possible to stop sessions killing eachother when they all authorize as the same role?
Previous Message Bryn Llewellyn 2022-09-13 19:46:23 Re: Is it possible to stop sessions killing eachother when they all authorize as the same role?