Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb65ebc7

Browse files
committed
fix suppress_redundant_updates_trigger() where relation has Oids, per gripe from KaiGai Kohei
1 parente2a277b commitb65ebc7

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

‎src/backend/utils/adt/trigfuncs.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/backend/utils/adt/trigfuncs.c,v 1.2 2008/11/04 00:29:39 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/utils/adt/trigfuncs.c,v 1.3 2008/11/05 18:49:27 adunstan Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -62,6 +62,12 @@ suppress_redundant_updates_trigger(PG_FUNCTION_ARGS)
6262
newheader=newtuple->t_data;
6363
oldheader=oldtuple->t_data;
6464

65+
if (oldheader->t_infomask&HEAP_HASOID)
66+
{
67+
Oidoldoid=HeapTupleHeaderGetOid(oldheader);
68+
HeapTupleHeaderSetOid(newheader,oldoid);
69+
}
70+
6571
/* if the tuple payload is the same ... */
6672
if (newtuple->t_len==oldtuple->t_len&&
6773
newheader->t_hoff==oldheader->t_hoff&&
@@ -77,5 +83,6 @@ suppress_redundant_updates_trigger(PG_FUNCTION_ARGS)
7783
rettuple=NULL;
7884
}
7985

86+
8087
returnPointerGetDatum(rettuple);
8188
}

‎src/test/regress/expected/triggers.out

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,17 +542,31 @@ CREATE TABLE min_updates_test (
542542
f1text,
543543
f2 int,
544544
f3 int);
545+
CREATE TABLE min_updates_test_oids (
546+
f1text,
547+
f2 int,
548+
f3 int) WITH OIDS;
545549
INSERT INTO min_updates_test VALUES ('a',1,2),('b','2',null);
550+
INSERT INTO min_updates_test_oids VALUES ('a',1,2),('b','2',null);
546551
CREATE TRIGGER z_min_update
547552
BEFORE UPDATE ON min_updates_test
548553
FOR EACH ROW EXECUTE PROCEDURE suppress_redundant_updates_trigger();
554+
CREATE TRIGGER z_min_update
555+
BEFORE UPDATE ON min_updates_test_oids
556+
FOR EACH ROW EXECUTE PROCEDURE suppress_redundant_updates_trigger();
549557
\set QUIET false
550558
UPDATE min_updates_test SET f1 = f1;
551559
UPDATE 0
552560
UPDATE min_updates_test SET f2 = f2 + 1;
553561
UPDATE 2
554562
UPDATE min_updates_test SET f3 = 2 WHERE f3 is null;
555563
UPDATE 1
564+
UPDATE min_updates_test_oids SET f1 = f1;
565+
UPDATE 0
566+
UPDATE min_updates_test_oids SET f2 = f2 + 1;
567+
UPDATE 2
568+
UPDATE min_updates_test_oids SET f3 = 2 WHERE f3 is null;
569+
UPDATE 1
556570
\set QUIET true
557571
SELECT * FROM min_updates_test;
558572
f1 | f2 | f3
@@ -561,4 +575,12 @@ SELECT * FROM min_updates_test;
561575
b | 3 | 2
562576
(2 rows)
563577

578+
SELECT * FROM min_updates_test_oids;
579+
f1 | f2 | f3
580+
----+----+----
581+
a | 2 | 2
582+
b | 3 | 2
583+
(2 rows)
584+
564585
DROP TABLE min_updates_test;
586+
DROP TABLE min_updates_test_oids;

‎src/test/regress/sql/triggers.sql

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,12 +424,23 @@ CREATE TABLE min_updates_test (
424424
f2int,
425425
f3int);
426426

427+
CREATETABLEmin_updates_test_oids (
428+
f1text,
429+
f2int,
430+
f3int) WITH OIDS;
431+
427432
INSERT INTO min_updates_testVALUES ('a',1,2),('b','2',null);
428433

434+
INSERT INTO min_updates_test_oidsVALUES ('a',1,2),('b','2',null);
435+
429436
CREATETRIGGERz_min_update
430437
BEFOREUPDATEON min_updates_test
431438
FOR EACH ROW EXECUTE PROCEDURE suppress_redundant_updates_trigger();
432439

440+
CREATETRIGGERz_min_update
441+
BEFOREUPDATEON min_updates_test_oids
442+
FOR EACH ROW EXECUTE PROCEDURE suppress_redundant_updates_trigger();
443+
433444
\set QUIET false
434445

435446
UPDATE min_updates_testSET f1= f1;
@@ -438,9 +449,19 @@ UPDATE min_updates_test SET f2 = f2 + 1;
438449

439450
UPDATE min_updates_testSET f3=2WHERE f3 isnull;
440451

452+
UPDATE min_updates_test_oidsSET f1= f1;
453+
454+
UPDATE min_updates_test_oidsSET f2= f2+1;
455+
456+
UPDATE min_updates_test_oidsSET f3=2WHERE f3 isnull;
457+
441458
\set QUIET true
442459

443460
SELECT*FROM min_updates_test;
444461

462+
SELECT*FROM min_updates_test_oids;
463+
445464
DROPTABLE min_updates_test;
446465

466+
DROPTABLE min_updates_test_oids;
467+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp