diff options
Diffstat (limited to 'sql/serenitas.c')
| -rw-r--r-- | sql/serenitas.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/sql/serenitas.c b/sql/serenitas.c index 5932ef34..76f5b62f 100644 --- a/sql/serenitas.c +++ b/sql/serenitas.c @@ -158,9 +158,6 @@ double calc(TDate today, TDate start_date, TDate end_date, double recovery, doub PG_FUNCTION_INFO_V1(upfront_from_level); Datum upfront_from_level(PG_FUNCTION_ARGS) { - if (SPI_connect() == SPI_ERROR_CONNECT) { - elog(ERROR, "something wrong happened"); - } const text* redindexcode = PG_GETARG_TEXT_PP(0); DateADT maturity = PG_GETARG_DATEADT(1); float8 traded_level = PG_GETARG_FLOAT8(2); @@ -177,6 +174,9 @@ Datum upfront_from_level(PG_FUNCTION_ARGS) { int ret; values[0] = PointerGetDatum(redindexcode); values[1] = DateADTGetDatum(maturity); + if (SPI_connect() == SPI_ERROR_CONNECT) { + elog(ERROR, "something wrong happened"); + } ret = SPI_execute_with_args(sql_query, nargs, argtypes, values, nulls, true, 1); proc = SPI_processed; int coupon; @@ -242,7 +242,7 @@ Datum upfront_from_level(PG_FUNCTION_ARGS) { double upfront; upfront = calc(TDate_from_DateADT(trade_date), issue_date, TDate_from_DateADT(maturity), recovery, coupon / 10000.0, cal_from_currency(currency), curve, traded_level, true); /* pfree(index); */ - /* pfree(currency); */ - /* free(curve); */ + pfree(currency); + free(curve); PG_RETURN_FLOAT8(upfront); } |
