Closed dpage closed 2 years ago
Comment migrated from Redmine: https://redmine.postgresql.org/issues/576#note-1 Originally created by Anonymous at 2011-08-12 18:23:37 UTC.
The fix is pretty obvious in this case. The code mistakenly trims all outer enclosing brackets, which leads to unmatched brackets in test 2.) - both left brackets were removed.
pgTrigger.cpp, line 393:
Comment migrated from Redmine: https://redmine.postgresql.org/issues/576#note-2 Originally created by Guillaume Lelarge at 2011-08-16 17:13:41 UTC.
Your patch wasn't enough. We need to strip the first and last brackets, but the previous code did strip too much.
See http://git.postgresql.org/gitweb/?p=pgadmin3.git;a=commit;h=ba8d4935060774d1340a42870b3140a99886dc85 and http://git.postgresql.org/gitweb/?p=pgadmin3.git;a=commit;h=4f4a24588973132989c129db3ddd14d48adeab23.
Redmine ticket header update:
Name | Old Value | New Value |
---|---|---|
Resolution changed | fixed |
Comment migrated from Redmine: https://redmine.postgresql.org/issues/576#note-3 Originally created by Anonymous at 2011-08-20 01:20:26 UTC.
First off, I don't actually understand most of the code, I am only poking at a spot I found. My "code" is from the top of my head.
My patch apparently fixed the problem but left one set of enclosing brackets too many. Your additional patch cuts first and last character from the WHEN-Expression.
In v1.14 RC1 I still see one set of brackets too many. So, somehow, this fails to work. Or maybe it does works but still leaves an extra set of brackets just like pg_get_triggerdef() does. (No idea why.)
In any case, I propose this simpler fix instead: pgTrigger.cpp, line 393:
Comment migrated from Redmine: https://redmine.postgresql.org/issues/576#note-4 Originally created by Guillaume Lelarge at 2011-08-20 07:28:21 UTC.
It doesn't fail, [[PostgreSQL]] send it to us this way. And it works. You can copy the statement to execute it, it works.
Your new fix won't work all the time. What we can do is use the new argument of pg_get_triggerdef that makes the definition prettier. That could be done.
Issue closed on Redmine.
Issue migrated from Redmine: https://redmine.postgresql.org/issues/576 Originally created by Anonymous at 2011-08-12 18:06:13 UTC.
Brackets around the WHEN condition are missing or unmatched in the SQL pane. (See ticket #387)
pg feature applies to postgresql 9.0+ Tested with pgAdmin 1.14.0 Beta 3 on Win XP; pg 9.0.4 on Debian Squeeze.
Docs: http://www.postgresql.org/docs/9.0/interactive/sql-createtrigger.html
-- Test case --
CREATE TABLE foo(a serial, b text, c text, d text);
CREATE OR REPLACE FUNCTION trg_foo_upaft() RETURNS trigger AS $BODY$ BEGIN
-- do something RETURN NEW;
END; $BODY$ LANGUAGE plpgsql VOLATILE;
-- Test 1.) -- I say: -- DROP TRIGGER up_aft ON foo; CREATE TRIGGER up_aft AFTER UPDATE ON foo FOR EACH ROW WHEN ((old.b, old.c, old.d) <> (new.b, new.c, new.d)) EXECUTE PROCEDURE trg_foo_upaft();
--> pgAdmin says: CREATE TRIGGER up_aft AFTER UPDATE ON foo FOR EACH ROW WHEN (old.b <> new.b) OR (old.c <> new.c) OR (old.d <> new.d) EXECUTE PROCEDURE trg_foo_upaft(); --! no enclosing brackets !
-- Test 2.) -- I say: -- DROP TRIGGER up_aft ON foo; CREATE TRIGGER up_aft AFTER UPDATE ON foo FOR EACH ROW WHEN ((old.b <> new.b) OR (old.c <> new.c) OR (old.d <> new.d)) EXECUTE PROCEDURE trg_foo_upaft();
--> pgAdmin says: CREATE TRIGGER up_aft AFTER UPDATE ON foo FOR EACH ROW WHEN (old.b <> new.b) OR (old.c <> new.c)) OR (old.d <> new.d) EXECUTE PROCEDURE trg_foo_upaft(); --! unmatched bracket and missing enclosing brackets !