invalid memory alloc after insert with c trigger function

From: Dudás József <dj1999(at)freemail(dot)hu>
To: pgsql-general(at)postgresql(dot)org
Subject: invalid memory alloc after insert with c trigger function
Date: 2007-05-31 22:52:42
Message-ID: 465F51BA.10506@freemail.hu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello Everybody!

I know that something doing wrong, but I can't find out what is it. This
is a part from trigger function:
/
attnum[3] = SPI_fnumber( tupdesc, "arfolyam" );
datums[3] = _selectFunctionB( "SELECT ertek FROM foo WHERE
parameter='rate'" ); // this come back with Datum type from select -
PG_RETURN_FLOAT8( b ); is end of this function where b is double type
arfolyam = DatumGetFloat8( datums[3] );
elog( INFO, "2.5.0 arfolyam = %f", arfolyam );
if ( attnum[3] == PointerGetDatum( NULL ) ) {
elog( ERROR, "Hianyzo arfolyam" );
SPI_finish();
return PointerGetDatum(NULL);
}
elog( INFO, "2.5.1 Datums[3] = %f", DatumGetFloat8( datums[3] ) );
rettuple = SPI_modifytuple( trigdata->tg_relation, tmptuple, 4,
&attnum[0], &datums[0], &isNull[0] );
SPI_freetuple(tmptuple);
SPI_finish();
return PointerGetDatum( rettuple );/

After insert:
INFO: string vissza : 1.000000
INFO: 2.5.0 arfolyam = 1.000000
INFO: 2.5.1 Datums[3] = 1.000000
INSERT 0 1
ELES=# SELECT * FROM pgsor;
ERROR: invalid memory alloc request size 4294967293

The datums[0 - 2] are char* / VARCHAR type. If I set /SPI_modifytuple(
trigdata->tg_relation, tmptuple, 3, &attnum[0], &datums[0], &isNull[0]
); /than everything is OK after insert.

The question: what is wrong with converting double to Datum?

Thanks in advance!
dj

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ottavio Campana 2007-05-31 23:23:13 shut down one database?
Previous Message PFC 2007-05-31 21:46:00 Re: why postgresql over other RDBMS