|
| 1 | +<!-- |
| 2 | +$Header: /cvsroot/pgsql/doc/src/sgml/trigger.sgml,v 1.19 2001/12/04 02:07:11 tgl Exp $ |
| 3 | +--> |
| 4 | + |
1 | 5 | <chapter id="triggers"> |
2 | 6 | <title>Triggers</title> |
3 | 7 |
|
@@ -451,7 +455,7 @@ PG_FUNCTION_INFO_V1(trigf); |
451 | 455 | Datum |
452 | 456 | trigf(PG_FUNCTION_ARGS) |
453 | 457 | { |
454 | | -TriggerData *trigdata = (TriggerData *) fcinfo->context; |
| 458 | +TriggerData*trigdata = (TriggerData *) fcinfo->context; |
455 | 459 | TupleDesctupdesc; |
456 | 460 | HeapTuplerettuple; |
457 | 461 | char*when; |
@@ -490,16 +494,20 @@ trigf(PG_FUNCTION_ARGS) |
490 | 494 |
|
491 | 495 | if (ret < 0) |
492 | 496 | elog(NOTICE, "trigf (fired %s): SPI_exec returned %d", when, ret); |
493 | | - |
494 | | -i = SPI_getbinval(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 1, &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 | + &isnull)); |
495 | 503 |
|
496 | 504 | elog (NOTICE, "trigf (fired %s): there are %d tuples in ttest", when, i); |
497 | 505 |
|
498 | 506 | SPI_finish(); |
499 | 507 |
|
500 | 508 | if (checknull) |
501 | 509 | { |
502 | | -i = SPI_getbinval(rettuple, tupdesc, 1, &isnull); |
| 510 | +(void) SPI_getbinval(rettuple, tupdesc, 1, &isnull); |
503 | 511 | if (isnull) |
504 | 512 | rettuple = NULL; |
505 | 513 | } |
|