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 );
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?