Re: Alter Table from Trigger

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Tamara Tardif <tamara(at)ccxtechnologies(dot)com>
Cc: pgsql-novice <pgsql-novice(at)lists(dot)postgresql(dot)org>
Subject: Re: Alter Table from Trigger
Date: 2020-03-19 17:06:23
Message-ID: CAKFQuwYAUiBR-5c6wP=NCQt1G8OPpXAxuL9k6CXuvcyggF70BQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Thu, Mar 19, 2020 at 9:32 AM Tamara Tardif <tamara(at)ccxtechnologies(dot)com>
wrote:

> Hello,
>
> Is altering a table from its own trigger possible? If not, how come?
>
> For context, I am trying to attach a partition to a table using a trigger
> on that same table. Here is the error:
>
> ERROR: cannot ALTER TABLE "tablename" because it is being used by active
> queries in this session
>
> Any help would be greatly appreciated.
>

The error message answers both of your questions. The rule is that
structure is constant while queries are running. The various lock types
handle this and cause queries in different sessions to queue up. If you
try and break things within the same session you end up with something like
the error message shown instead as queuing won't help.

Whether there is a workable way to accomplish your goal I do not know.

David J.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Roberto Taglia 2020-03-25 10:10:58 Another view
Previous Message Tamara Tardif 2020-03-19 16:32:02 Alter Table from Trigger