Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
b65ebc7e
Commit
b65ebc7e
authored
Nov 05, 2008
by
Andrew Dunstan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix suppress_redundant_updates_trigger() where relation has Oids, per gripe from KaiGai Kohei
parent
e2a277bd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
1 deletion
+51
-1
src/backend/utils/adt/trigfuncs.c
src/backend/utils/adt/trigfuncs.c
+8
-1
src/test/regress/expected/triggers.out
src/test/regress/expected/triggers.out
+22
-0
src/test/regress/sql/triggers.sql
src/test/regress/sql/triggers.sql
+21
-0
No files found.
src/backend/utils/adt/trigfuncs.c
View file @
b65ebc7e
...
...
@@ -7,7 +7,7 @@
* 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 $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -62,6 +62,12 @@ suppress_redundant_updates_trigger(PG_FUNCTION_ARGS)
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
&&
...
...
@@ -77,5 +83,6 @@ suppress_redundant_updates_trigger(PG_FUNCTION_ARGS)
rettuple
=
NULL
;
}
return
PointerGetDatum
(
rettuple
);
}
src/test/regress/expected/triggers.out
View file @
b65ebc7e
...
...
@@ -542,10 +542,18 @@ CREATE TABLE min_updates_test (
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
...
...
@@ -553,6 +561,12 @@ UPDATE min_updates_test SET f2 = f2 + 1;
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
...
...
@@ -561,4 +575,12 @@ SELECT * FROM min_updates_test;
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;
src/test/regress/sql/triggers.sql
View file @
b65ebc7e
...
...
@@ -424,12 +424,23 @@ CREATE TABLE min_updates_test (
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
;
...
...
@@ -438,9 +449,19 @@ UPDATE min_updates_test SET f2 = f2 + 1;
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
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment