Add in a call to:

ALTER TABLE [table_name] ENABLE ALWAYS TRIGGER z_reorg_trigger

so that pg_reorg and the z_reorg_trigger can properly work in "replica" mode,
as when using pg_reorg on a Slony slave.

Bug report and patch by Norman Yamada.
This commit is contained in:
Josh Kupershmidt
2012-10-14 10:50:05 -07:00
parent 370e572cfc
commit df12c37edf
2 changed files with 13 additions and 0 deletions

View File

@ -48,6 +48,7 @@ typedef struct reorg_table
const char *create_pktype; /* CREATE TYPE pk */
const char *create_log; /* CREATE TABLE log */
const char *create_trigger; /* CREATE TRIGGER z_reorg_trigger */
const char *alter_table; /* ALTER TABLE ENABLE ALWAYS TRIGGER z_reorg_trigger */
const char *create_table; /* CREATE TABLE table AS SELECT */
const char *drop_columns; /* ALTER TABLE DROP COLUMNs */
const char *delete_log; /* DELETE FROM log */
@ -288,6 +289,7 @@ reorg_one_database(const char *orderby, const char *table)
table.create_pktype = getstr(res, i, c++);
table.create_log = getstr(res, i, c++);
table.create_trigger = getstr(res, i, c++);
table.alter_table = getstr(res, i, c++);
create_table = getstr(res, i, c++);
table.drop_columns = getstr(res, i, c++);
@ -384,6 +386,7 @@ reorg_one_table(const reorg_table *table, const char *orderby)
elog(DEBUG2, "create_pktype : %s", table->create_pktype);
elog(DEBUG2, "create_log : %s", table->create_log);
elog(DEBUG2, "create_trigger : %s", table->create_trigger);
elog(DEBUG2, "alter_table : %s", table->alter_table);
elog(DEBUG2, "create_table : %s", table->create_table);
elog(DEBUG2, "drop_columns : %s", table->drop_columns ? table->drop_columns : "(skipped)");
elog(DEBUG2, "delete_log : %s", table->delete_log);
@ -417,6 +420,7 @@ reorg_one_table(const reorg_table *table, const char *orderby)
command(table->create_pktype, 0, NULL);
command(table->create_log, 0, NULL);
command(table->create_trigger, 0, NULL);
command(table->alter_table, 0, NULL);
printfStringInfo(&sql, "SELECT reorg.disable_autovacuum('reorg.log_%u')", table->target_oid);
command(sql.data, 0, NULL);
command("COMMIT", 0, NULL);