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

Commit99e0996

Browse files
committed
Fix compiler warnings (including a seriously bogus elog call); minor
code beautification.
1 parent1a2b41f commit99e0996

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

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

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,23 @@
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.1 2008/11/03 20:17:20 adunstan Exp $
10+
* $PostgreSQL: pgsql/src/backend/utils/adt/trigfuncs.c,v 1.2 2008/11/04 00:29:39 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
14-
15-
16-
1714
#include"postgres.h"
18-
#include"commands/trigger.h"
15+
1916
#include"access/htup.h"
17+
#include"commands/trigger.h"
18+
#include"utils/builtins.h"
19+
2020

2121
/*
2222
* suppress_redundant_updates_trigger
2323
*
2424
* This trigger function will inhibit an update from being done
2525
* if the OLD and NEW records are identical.
26-
*
2726
*/
28-
2927
Datum
3028
suppress_redundant_updates_trigger(PG_FUNCTION_ARGS)
3129
{
@@ -35,41 +33,47 @@ suppress_redundant_updates_trigger(PG_FUNCTION_ARGS)
3533

3634
/* make sure it's called as a trigger */
3735
if (!CALLED_AS_TRIGGER(fcinfo))
38-
elog(ERROR, (errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED),
39-
errmsg("suppress_redundant_updates_trigger: must be called as trigger")));
36+
ereport(ERROR,
37+
(errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED),
38+
errmsg("suppress_redundant_updates_trigger: must be called as trigger")));
4039

4140
/* and that it's called on update */
4241
if (!TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
43-
ereport(ERROR, (errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED),
44-
errmsg("suppress_redundant_updates_trigger: may only be called on update")));
42+
ereport(ERROR,
43+
(errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED),
44+
errmsg("suppress_redundant_updates_trigger: must be called on update")));
4545

4646
/* and that it's called before update */
4747
if (!TRIGGER_FIRED_BEFORE(trigdata->tg_event))
48-
ereport(ERROR, (errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED),
49-
errmsg("suppress_redundant_updates_trigger: may only be called before update")));
48+
ereport(ERROR,
49+
(errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED),
50+
errmsg("suppress_redundant_updates_trigger: must be called before update")));
5051

5152
/* and that it's called for each row */
5253
if (!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event))
53-
ereport(ERROR, (errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED),
54-
errmsg("suppress_redundant_updates_trigger: may only be called for each row")));
54+
ereport(ERROR,
55+
(errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED),
56+
errmsg("suppress_redundant_updates_trigger: must be called for each row")));
5557

56-
/* get tuple data, set defaultreturn */
58+
/* get tuple data, set defaultresult */
5759
rettuple=newtuple=trigdata->tg_newtuple;
5860
oldtuple=trigdata->tg_trigtuple;
5961

6062
newheader=newtuple->t_data;
6163
oldheader=oldtuple->t_data;
6264

65+
/* if the tuple payload is the same ... */
6366
if (newtuple->t_len==oldtuple->t_len&&
6467
newheader->t_hoff==oldheader->t_hoff&&
6568
(HeapTupleHeaderGetNatts(newheader)==
66-
HeapTupleHeaderGetNatts(oldheader))&&
69+
HeapTupleHeaderGetNatts(oldheader))&&
6770
((newheader->t_infomask& ~HEAP_XACT_MASK)==
68-
(oldheader->t_infomask& ~HEAP_XACT_MASK) )&&
71+
(oldheader->t_infomask& ~HEAP_XACT_MASK))&&
6972
memcmp(((char*)newheader)+ offsetof(HeapTupleHeaderData,t_bits),
7073
((char*)oldheader)+ offsetof(HeapTupleHeaderData,t_bits),
7174
newtuple->t_len- offsetof(HeapTupleHeaderData,t_bits))==0)
7275
{
76+
/* ... then suppress the update */
7377
rettuple=NULL;
7478
}
7579

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp