* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/utils/adt/trigfuncs.c,v 1.2 2008/11/04 00:29:39 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/trigfuncs.c,v 1.3 2008/11/05 18:49:27 adunstan Exp $
*
*-------------------------------------------------------------------------
*/
newheader = newtuple->t_data;
oldheader = oldtuple->t_data;
+ if (oldheader->t_infomask & HEAP_HASOID)
+ {
+ Oid oldoid = HeapTupleHeaderGetOid(oldheader);
+ HeapTupleHeaderSetOid(newheader, oldoid);
+ }
+
/* if the tuple payload is the same ... */
if (newtuple->t_len == oldtuple->t_len &&
newheader->t_hoff == oldheader->t_hoff &&
rettuple = NULL;
}
+
return PointerGetDatum(rettuple);
}
f1 text,
f2 int,
f3 int);
+CREATE TABLE min_updates_test_oids (
+ f1 text,
+ f2 int,
+ f3 int) WITH OIDS;
INSERT INTO min_updates_test VALUES ('a',1,2),('b','2',null);
+INSERT INTO min_updates_test_oids VALUES ('a',1,2),('b','2',null);
CREATE TRIGGER z_min_update
BEFORE UPDATE ON min_updates_test
FOR EACH ROW EXECUTE PROCEDURE suppress_redundant_updates_trigger();
+CREATE TRIGGER z_min_update
+BEFORE UPDATE ON min_updates_test_oids
+FOR EACH ROW EXECUTE PROCEDURE suppress_redundant_updates_trigger();
\set QUIET false
UPDATE min_updates_test SET f1 = f1;
UPDATE 0
UPDATE 2
UPDATE min_updates_test SET f3 = 2 WHERE f3 is null;
UPDATE 1
+UPDATE min_updates_test_oids SET f1 = f1;
+UPDATE 0
+UPDATE min_updates_test_oids SET f2 = f2 + 1;
+UPDATE 2
+UPDATE min_updates_test_oids SET f3 = 2 WHERE f3 is null;
+UPDATE 1
\set QUIET true
SELECT * FROM min_updates_test;
f1 | f2 | f3
b | 3 | 2
(2 rows)
+SELECT * FROM min_updates_test_oids;
+ f1 | f2 | f3
+----+----+----
+ a | 2 | 2
+ b | 3 | 2
+(2 rows)
+
DROP TABLE min_updates_test;
+DROP TABLE min_updates_test_oids;
f2 int,
f3 int);
+CREATE TABLE min_updates_test_oids (
+ f1 text,
+ f2 int,
+ f3 int) WITH OIDS;
+
INSERT INTO min_updates_test VALUES ('a',1,2),('b','2',null);
+INSERT INTO min_updates_test_oids VALUES ('a',1,2),('b','2',null);
+
CREATE TRIGGER z_min_update
BEFORE UPDATE ON min_updates_test
FOR EACH ROW EXECUTE PROCEDURE suppress_redundant_updates_trigger();
+CREATE TRIGGER z_min_update
+BEFORE UPDATE ON min_updates_test_oids
+FOR EACH ROW EXECUTE PROCEDURE suppress_redundant_updates_trigger();
+
\set QUIET false
UPDATE min_updates_test SET f1 = f1;
UPDATE min_updates_test SET f3 = 2 WHERE f3 is null;
+UPDATE min_updates_test_oids SET f1 = f1;
+
+UPDATE min_updates_test_oids SET f2 = f2 + 1;
+
+UPDATE min_updates_test_oids SET f3 = 2 WHERE f3 is null;
+
\set QUIET true
SELECT * FROM min_updates_test;
+SELECT * FROM min_updates_test_oids;
+
DROP TABLE min_updates_test;
+DROP TABLE min_updates_test_oids;
+