[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgresql-general
Subject:    [GENERAL] invalid memory alloc after insert with c trigger function
From:       Dudás_József <dj1999 () freemail ! hu>
Date:       2007-05-31 22:52:42
Message-ID: 465F51BA.10506 () freemail ! hu
[Download RAW message or body]

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

[Attachment #3 (text/html)]

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
Hello Everybody!<br>
<br>
I know that something doing wrong, but I can't find out what is it.
This is a part from trigger function:<br>
<span><i><br>
attnum[3] = SPI_fnumber( tupdesc, "arfolyam" );<br>
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<br>
arfolyam = DatumGetFloat8( datums[3] );<br>
elog( INFO, "2.5.0 arfolyam = %f", arfolyam );<br>
if ( attnum[3] == PointerGetDatum( NULL ) ) {<br>
   elog( ERROR, "Hianyzo arfolyam" );<br>
   SPI_finish(); <br>
   return PointerGetDatum(NULL); <br>
}<br>
elog( INFO, "2.5.1 Datums[3] = %f", DatumGetFloat8( datums[3] ) );<br>
rettuple = SPI_modifytuple( trigdata-&gt;tg_relation, tmptuple, 4,
&amp;attnum[0], &amp;datums[0], &amp;isNull[0] );<br>
SPI_freetuple(tmptuple);<br>
SPI_finish();<br>
return PointerGetDatum( rettuple );</i><br>
<br>
After insert:<br>
INFO: string vissza : 1.000000<br>
INFO: 2.5.0 arfolyam = 1.000000<br>
INFO: 2.5.1 Datums[3] = 1.000000<br>
INSERT 0 1<br>
ELES=# SELECT * FROM pgsor;<br>
ERROR: invalid memory alloc request size 4294967293</span><br>
<br>
The datums[0 - 2] are char* / VARCHAR type. If I set <span><i>SPI_modifytuple(
trigdata-&gt;tg_relation, tmptuple, 3, &amp;attnum[0], &amp;datums[0],
&amp;isNull[0] ); </i>than everything is OK after insert.<br>
<br>
The question: what is wrong with converting double to Datum?<br>
<br>
Thanks in advance!<br>
dj</span>
</body>
</html>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic