Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
99e09962
Commit
99e09962
authored
16 years ago
by
Tom Lane
Browse files
Options
Downloads
Patches
Plain Diff
Fix compiler warnings (including a seriously bogus elog call); minor
code beautification.
parent
1a2b41f4
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/backend/utils/adt/trigfuncs.c
+22
-18
22 additions, 18 deletions
src/backend/utils/adt/trigfuncs.c
with
22 additions
and
18 deletions
src/backend/utils/adt/trigfuncs.c
+
22
−
18
View file @
99e09962
...
@@ -7,25 +7,23 @@
...
@@ -7,25 +7,23 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $PostgreSQL: pgsql/src/backend/utils/adt/trigfuncs.c,v 1.
1
2008/11/0
3 20:17:20 adunstan
Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/trigfuncs.c,v 1.
2
2008/11/0
4 00:29:39 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
#include
"postgres.h"
#include
"postgres.h"
#include
"commands/trigger.h"
#include
"access/htup.h"
#include
"access/htup.h"
#include
"commands/trigger.h"
#include
"utils/builtins.h"
/*
/*
* suppress_redundant_updates_trigger
* suppress_redundant_updates_trigger
*
*
* This trigger function will inhibit an update from being done
* This trigger function will inhibit an update from being done
* if the OLD and NEW records are identical.
* if the OLD and NEW records are identical.
*
*/
*/
Datum
Datum
suppress_redundant_updates_trigger
(
PG_FUNCTION_ARGS
)
suppress_redundant_updates_trigger
(
PG_FUNCTION_ARGS
)
{
{
...
@@ -35,31 +33,36 @@ suppress_redundant_updates_trigger(PG_FUNCTION_ARGS)
...
@@ -35,31 +33,36 @@ suppress_redundant_updates_trigger(PG_FUNCTION_ARGS)
/* make sure it's called as a trigger */
/* make sure it's called as a trigger */
if
(
!
CALLED_AS_TRIGGER
(
fcinfo
))
if
(
!
CALLED_AS_TRIGGER
(
fcinfo
))
elog
(
ERROR
,
(
errcode
(
ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED
),
ereport
(
ERROR
,
(
errcode
(
ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED
),
errmsg
(
"suppress_redundant_updates_trigger: must be called as trigger"
)));
errmsg
(
"suppress_redundant_updates_trigger: must be called as trigger"
)));
/* and that it's called on update */
/* and that it's called on update */
if
(
!
TRIGGER_FIRED_BY_UPDATE
(
trigdata
->
tg_event
))
if
(
!
TRIGGER_FIRED_BY_UPDATE
(
trigdata
->
tg_event
))
ereport
(
ERROR
,
(
errcode
(
ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED
),
ereport
(
ERROR
,
errmsg
(
"suppress_redundant_updates_trigger: may only be called on update"
)));
(
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 */
/* and that it's called before update */
if
(
!
TRIGGER_FIRED_BEFORE
(
trigdata
->
tg_event
))
if
(
!
TRIGGER_FIRED_BEFORE
(
trigdata
->
tg_event
))
ereport
(
ERROR
,
(
errcode
(
ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED
),
ereport
(
ERROR
,
errmsg
(
"suppress_redundant_updates_trigger: may only be called before update"
)));
(
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 */
/* and that it's called for each row */
if
(
!
TRIGGER_FIRED_FOR_ROW
(
trigdata
->
tg_event
))
if
(
!
TRIGGER_FIRED_FOR_ROW
(
trigdata
->
tg_event
))
ereport
(
ERROR
,
(
errcode
(
ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED
),
ereport
(
ERROR
,
errmsg
(
"suppress_redundant_updates_trigger: may only be called for each row"
)));
(
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
;
rettuple
=
newtuple
=
trigdata
->
tg_newtuple
;
oldtuple
=
trigdata
->
tg_trigtuple
;
oldtuple
=
trigdata
->
tg_trigtuple
;
newheader
=
newtuple
->
t_data
;
newheader
=
newtuple
->
t_data
;
oldheader
=
oldtuple
->
t_data
;
oldheader
=
oldtuple
->
t_data
;
/* if the tuple payload is the same ... */
if
(
newtuple
->
t_len
==
oldtuple
->
t_len
&&
if
(
newtuple
->
t_len
==
oldtuple
->
t_len
&&
newheader
->
t_hoff
==
oldheader
->
t_hoff
&&
newheader
->
t_hoff
==
oldheader
->
t_hoff
&&
(
HeapTupleHeaderGetNatts
(
newheader
)
==
(
HeapTupleHeaderGetNatts
(
newheader
)
==
...
@@ -70,6 +73,7 @@ suppress_redundant_updates_trigger(PG_FUNCTION_ARGS)
...
@@ -70,6 +73,7 @@ suppress_redundant_updates_trigger(PG_FUNCTION_ARGS)
((
char
*
)
oldheader
)
+
offsetof
(
HeapTupleHeaderData
,
t_bits
),
((
char
*
)
oldheader
)
+
offsetof
(
HeapTupleHeaderData
,
t_bits
),
newtuple
->
t_len
-
offsetof
(
HeapTupleHeaderData
,
t_bits
))
==
0
)
newtuple
->
t_len
-
offsetof
(
HeapTupleHeaderData
,
t_bits
))
==
0
)
{
{
/* ... then suppress the update */
rettuple
=
NULL
;
rettuple
=
NULL
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment