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

Commit0532175

Browse files
committed
Fix trigger example for PG 7.2 change: count(*) now returns int8.
1 parent7321eed commit0532175

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

‎doc/src/sgml/trigger.sgml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<!--
2+
$Header: /cvsroot/pgsql/doc/src/sgml/trigger.sgml,v 1.19 2001/12/04 02:07:11 tgl Exp $
3+
-->
4+
15
<chapter id="triggers">
26
<title>Triggers</title>
37

@@ -451,7 +455,7 @@ PG_FUNCTION_INFO_V1(trigf);
451455
Datum
452456
trigf(PG_FUNCTION_ARGS)
453457
{
454-
TriggerData *trigdata = (TriggerData *) fcinfo->context;
458+
TriggerData*trigdata = (TriggerData *) fcinfo->context;
455459
TupleDesctupdesc;
456460
HeapTuplerettuple;
457461
char*when;
@@ -490,16 +494,20 @@ trigf(PG_FUNCTION_ARGS)
490494

491495
if (ret < 0)
492496
elog(NOTICE, "trigf (fired %s): SPI_exec returned %d", when, ret);
493-
494-
i = SPI_getbinval(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 1, &amp;isnull);
497+
498+
/* count(*) returns int8 as of PG 7.2, so be careful to convert */
499+
i = (int) DatumGetInt64(SPI_getbinval(SPI_tuptable->vals[0],
500+
SPI_tuptable->tupdesc,
501+
1,
502+
&amp;isnull));
495503

496504
elog (NOTICE, "trigf (fired %s): there are %d tuples in ttest", when, i);
497505

498506
SPI_finish();
499507

500508
if (checknull)
501509
{
502-
i = SPI_getbinval(rettuple, tupdesc, 1, &amp;isnull);
510+
(void) SPI_getbinval(rettuple, tupdesc, 1, &amp;isnull);
503511
if (isnull)
504512
rettuple = NULL;
505513
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp