Wanted: ALTER TRIGGER ... OWNED BY EXTENSION

From: Moshe Jacobson <moshe(at)neadwerx(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Wanted: ALTER TRIGGER ... OWNED BY EXTENSION
Date: 2014-03-31 18:49:46
Message-ID: CAJ4CxLmxxv3+S3ReV78DvmfDSTVkVDVLoLqb426qXY6f8TvySQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

An extension <http://pgxn.org/dist/cyanaudit> I'm working on dynamically
creates trigger functions and installs them on tables in public. The
triggers are automatically created when one of the extension's config
tables is populated.

Even though I mark the trigger *functions *as owned by my extension, the
trigger definitions themselves are still dumped by pg_dump and restored by
pg_restore. This is a problem when pg_restore is using parallelism (-j),
and one thread starts issuing CREATE TRIGGER commands before the other
thread has finished populating the config table.

What ends up happening is pg_restore throws a whole lot of errors saying
that the function referenced by the CREATE TRIGGER command does not exist.
However, the function and trigger are actually created later on once the
config table is populated.

Using pg_restore without -j is a workaround, but I'd really like to be able
to mark my extension's triggers as owned by the extension, so that these
errors will not show up when restoring.

Is there a better workaround that I'm not aware of?

Thanks.

Moshe Jacobson
Manager of Systems Engineering, Nead Werx Inc. <http://www.neadwerx.com>
2323 Cumberland Parkway · Suite 201 · Atlanta, GA 30339

"Quality is not an act, it is a habit." -- Aristotle

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Raymond O'Donnell 2014-03-31 18:49:58 Re: Complex query
Previous Message Igor Neyman 2014-03-31 18:48:58 Re: Complex query