From 5c1b00450c9b6c0e1f70db26e92fd79f7119223b Mon Sep 17 00:00:00 2001 From: Philip Warner Date: Sun, 18 Mar 2001 03:45:12 +0000 Subject: [PATCH] Fixed but in _enableTriggersIfNecessary introduced by previous patches by me which caused segfault in a data-only retore with BLOBs --- src/bin/pg_dump/pg_backup_archiver.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c index 3e7c1b06d4..51f0aff0aa 100644 --- a/src/bin/pg_dump/pg_backup_archiver.c +++ b/src/bin/pg_dump/pg_backup_archiver.c @@ -471,10 +471,17 @@ static void _enableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te, RestoreO * command when one is available. */ ahprintf(AH, "-- Enable triggers\n"); - ahprintf(AH, "UPDATE pg_class SET reltriggers = " + if (te && te->name && strlen(te->name) > 0) + { + ahprintf(AH, "UPDATE pg_class SET reltriggers = " "(SELECT count(*) FROM pg_trigger where pg_class.oid = tgrelid) " "WHERE relname = '%s';\n\n", te->name); + } else { + ahprintf(AH, "UPDATE \"pg_class\" SET \"reltriggers\" = " + "(SELECT count(*) FROM pg_trigger where pg_class.oid = tgrelid) " + "WHERE \"relname\" !~ '^pg_';\n\n"); + } /* * Restore the user connection from the start of this procedure -- 2.40.0