| From: | Dimitri Fontaine <dimitri(at)2ndQuadrant(dot)fr> |
|---|---|
| To: | Andres Freund <andres(at)2ndquadrant(dot)com> |
| Cc: | Simon Riggs <simon(at)2ndQuadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org |
| Subject: | Re: ALTER TABLE ... NOREWRITE option |
| Date: | 2012-12-06 20:34:26 |
| Message-ID: | m2txryudgt.fsf@2ndQuadrant.fr |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> On 2012-12-06 18:42:22 +0000, Simon Riggs wrote:
>> "in-between state" means what? And what danger do you see?
>
> For example during table rewrites we have a temporary pg_class entry
> thats a full copy of the table, with a separate oid, relfilenode and
> everything. That gets dropped rather unceremonially, without the usual
> safety checks. If the user did anything referencing that table we would
> possibly have a corrupt catalog or even a segfault at our hands.
>
> For normal triggers the code takes quite some care to avoid such
> dangers.
I think we need to be solving that problem when we implement new firing
points for event trigger. The 'table_rewrite' event needs to fire at a
time when the code can cope with it. That's the main difficulty in
adding events in that system, asserting their code location safety.
> Event triggers get called *during* the ALTER TABLE. So if were not
> careful they see something thats not easy to handle.
They need to fire before catalogs are modified, or after, not in
between, I agree with that. I don't see other ways of implementing that
than carefully placing the call to user code in the backend's code.
> I am for example not sure what would happen if we had a "rewrite" event
> trigger which inserts a log entry into a logtable. Not a stupid idea,
> right?
> Now imagine we had a deferred unique key on that logtable and the
> logtable is the one that gets rewritten...
The log insert needs to happen either before or after the rewrite, in
terms of catalog state. I don't see any magic bullet here.
--
Dimitri Fontaine
http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Alvaro Herrera | 2012-12-06 21:02:11 | pgsql: Background worker processes |
| Previous Message | Dimitri Fontaine | 2012-12-06 20:26:15 | Re: in-catalog Extension Scripts and Control parameters (templates?) |