Re: Proposal: Store "timestamptz" of database creation on "pg_database"

Поиск
Список
Период
Сортировка
От Dimitri Fontaine
Тема Re: Proposal: Store "timestamptz" of database creation on "pg_database"
Дата
Msg-id m2r4maqyqa.fsf@2ndQuadrant.fr
обсуждение исходный текст
Ответ на Re: Proposal: Store "timestamptz" of database creation on "pg_database"  (Stephen Frost <sfrost@snowman.net>)
Ответы Re: Proposal: Store "timestamptz" of database creation on "pg_database"
Список pgsql-hackers
Stephen Frost <sfrost@snowman.net> writes:
> Apparently I've managed to miss the tricky case..?

That shouldn't be tricky as a user, but has been a tricky subject every
time we've been talking about implement Event Triggers in the past two
years, so I though I would include it:
   create schema test      create table foo(id serial primary key, f1 text);
   create event trigger track_table                     on ddl_command_trace            when tag in ('create table',
'altertable', 'drop table')             and context in ('toplevel', 'generated', 'subcommand')      execute procedure
public.track_table_activity();

The trick is that you then want to fire the event trigger for a command
in a 'subcommand' context, as seen in the logs provided by the "snitch"
example:
   NOTICE:  snitch event: ddl_command_end, context: SUBCOMMAND   NOTICE:           tag: CREATE TABLE, operation:
CREATE,type: TABLE   NOTICE:           oid: 25139, schema: test, name: foo   
 
> Sure, dropping tables, schemas, etc, would have an impact on the values.

we don't have, as of yet, support for a 'cascade' context. We will need
some heavy refactoring to get there, basically forcing the cascade drops
to happen via ProcessUtility(), but having a single DropStmt to handle
that I guess it shouldn't be very hard to do.

> being told "oh, well, you *could* have been collecting it all along if
> you knew about event triggers" isn't a particularly satisfying answer.

True that.

Now, having at least a way to do that without resorting to hacking the
backend or writing a C coded extension sure feels nice enough an answer
to me here.

Regards,
-- 
Dimitri Fontaine
http://2ndQuadrant.fr     PostgreSQL : Expertise, Formation et Support



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Pavel Stehule
Дата:
Сообщение: Re: multiple CREATE FUNCTION AS items for PLs
Следующее
От: Simon Riggs
Дата:
Сообщение: Re: Performance Improvement by reducing WAL for Update Operation