Small bug in pg_dump

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Philip Warner <pjw(at)rhyme(dot)com(dot)au>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Small bug in pg_dump
Date: 2001-03-12 23:41:41
Message-ID: 7680.984440501@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Philip,

I have not updated from CVS in a few days, but I suspect you haven't
noticed this yet: given a mixed-case table name and a scenario that
requires emitting UPDATE pg_class commands, pg_dump puts out
things like

UPDATE "pg_class" SET "reltriggers" = 0 WHERE "relname" ~* '"Table"';

BEGIN TRANSACTION;
CREATE TEMP TABLE "tr" ("tmp_relname" name, "tmp_reltriggers" smallint);
INSERT INTO "tr" SELECT C."relname", count(T."oid") FROM "pg_class" C, "pg_trigger" T WHERE C."oid" = T."tgrelid" AND C."relname" ~* '"Table"' GROUP BY 1;
UPDATE "pg_class" SET "reltriggers" = TMP."tmp_reltriggers" FROM "tr" TMP WHERE
"pg_class"."relname" = TMP."tmp_relname";
DROP TABLE "tr";
COMMIT TRANSACTION;

Of course those ~* '"Table"' clauses aren't going to work too well; the
identifier should NOT be double-quoted inside the pattern.

Actually, this should not be using ~* in the first place --- why isn't
it just using WHERE relname = 'Table' ??? Seems like it's not cool to
gratuitously reset the trigger counts on other tables that contain Table
as a substring of their names.

And while we're at it, the temp table hasn't been necessary for a
release or three. That whole transaction should be replaced by

UPDATE pg_class SET reltriggers =
(SELECT count(*) FROM pg_trigger where pg_class.oid = tgrelid)
WHERE relname = 'Table';

regards, tom lane

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Nathan Myers 2001-03-12 23:44:43 Re: Uh, this is *not* a 64-bit CRC ...
Previous Message Michal Maruka 2001-03-12 23:15:16 Re: psql missing feature