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
99e09962
Commit
99e09962
authored
Nov 04, 2008
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix compiler warnings (including a seriously bogus elog call); minor
code beautification.
parent
1a2b41f4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
18 deletions
+22
-18
src/backend/utils/adt/trigfuncs.c
src/backend/utils/adt/trigfuncs.c
+22
-18
No files found.
src/backend/utils/adt/trigfuncs.c
View file @
99e09962
...
...
@@ -7,25 +7,23 @@
* 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.
1 2008/11/03 20:17:20 adunstan
Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/trigfuncs.c,v 1.
2 2008/11/04 00:29:39 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "commands/trigger.h"
#include "access/htup.h"
#include "commands/trigger.h"
#include "utils/builtins.h"
/*
* suppress_redundant_updates_trigger
*
* This trigger function will inhibit an update from being done
* if the OLD and NEW records are identical.
*
*/
Datum
suppress_redundant_updates_trigger
(
PG_FUNCTION_ARGS
)
{
...
...
@@ -35,41 +33,47 @@ suppress_redundant_updates_trigger(PG_FUNCTION_ARGS)
/* make sure it's called as a trigger */
if
(
!
CALLED_AS_TRIGGER
(
fcinfo
))
elog
(
ERROR
,
(
errcode
(
ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED
),
errmsg
(
"suppress_redundant_updates_trigger: must be called as trigger"
)));
ereport
(
ERROR
,
(
errcode
(
ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED
),
errmsg
(
"suppress_redundant_updates_trigger: must be called as trigger"
)));
/* and that it's called on update */
if
(
!
TRIGGER_FIRED_BY_UPDATE
(
trigdata
->
tg_event
))
ereport
(
ERROR
,
(
errcode
(
ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED
),
errmsg
(
"suppress_redundant_updates_trigger: may only be called on update"
)));
ereport
(
ERROR
,
(
errcode
(
ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED
),
errmsg
(
"suppress_redundant_updates_trigger: must be called on update"
)));
/* and that it's called before update */
if
(
!
TRIGGER_FIRED_BEFORE
(
trigdata
->
tg_event
))
ereport
(
ERROR
,
(
errcode
(
ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED
),
errmsg
(
"suppress_redundant_updates_trigger: may only be called before update"
)));
ereport
(
ERROR
,
(
errcode
(
ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED
),
errmsg
(
"suppress_redundant_updates_trigger: must be called before update"
)));
/* and that it's called for each row */
if
(
!
TRIGGER_FIRED_FOR_ROW
(
trigdata
->
tg_event
))
ereport
(
ERROR
,
(
errcode
(
ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED
),
errmsg
(
"suppress_redundant_updates_trigger: may only be called for each row"
)));
ereport
(
ERROR
,
(
errcode
(
ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED
),
errmsg
(
"suppress_redundant_updates_trigger: must be called for each row"
)));
/* get tuple data, set default re
turn
*/
/* get tuple data, set default re
sult
*/
rettuple
=
newtuple
=
trigdata
->
tg_newtuple
;
oldtuple
=
trigdata
->
tg_trigtuple
;
newheader
=
newtuple
->
t_data
;
oldheader
=
oldtuple
->
t_data
;
/* if the tuple payload is the same ... */
if
(
newtuple
->
t_len
==
oldtuple
->
t_len
&&
newheader
->
t_hoff
==
oldheader
->
t_hoff
&&
(
HeapTupleHeaderGetNatts
(
newheader
)
==
HeapTupleHeaderGetNatts
(
oldheader
)
)
&&
HeapTupleHeaderGetNatts
(
oldheader
))
&&
((
newheader
->
t_infomask
&
~
HEAP_XACT_MASK
)
==
(
oldheader
->
t_infomask
&
~
HEAP_XACT_MASK
)
)
&&
(
oldheader
->
t_infomask
&
~
HEAP_XACT_MASK
)
)
&&
memcmp
(((
char
*
)
newheader
)
+
offsetof
(
HeapTupleHeaderData
,
t_bits
),
((
char
*
)
oldheader
)
+
offsetof
(
HeapTupleHeaderData
,
t_bits
),
newtuple
->
t_len
-
offsetof
(
HeapTupleHeaderData
,
t_bits
))
==
0
)
{
/* ... then suppress the update */
rettuple
=
NULL
;
}
...
...
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