Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-general by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group