From c44913146048b66e350ded973efef6090140e994 Mon Sep 17 00:00:00 2001 From: dimitr Date: Mon, 26 Jan 2015 14:54:14 +0000 Subject: [PATCH] This should fix the Windows build. --- src/jrd/fun.epp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/jrd/fun.epp b/src/jrd/fun.epp index 2ef5696d47..78374c3370 100644 --- a/src/jrd/fun.epp +++ b/src/jrd/fun.epp @@ -706,7 +706,19 @@ void FUN_evaluate(thread_db* tdbb, UserFunction* function, jrd_nod* node, impure // Did the udf send an ill-formed descriptor back? UdfError udfError = UeNone; - invoke(tdbb, function, return_ptr, value, args, return_blob_struct, result_was_null, udfError); + // When exception happens inside UDF we have no better choice than storing it in + // tdbb_status_vector and raising again on return from UDF. + // + // This code could be inside invoke() but Windows SEH rules play against us. + + { // scope + ThreadStatusGuard tempStatus(tdbb); + + invoke(tdbb, function, return_ptr, value, args, return_blob_struct, result_was_null, udfError); + + if (tempStatus[0] == isc_arg_gds && tempStatus[1] != FB_SUCCESS) + ERR_post(Arg::StatusVector(tempStatus)); + } switch (udfError) { @@ -1163,8 +1175,6 @@ static void invoke(thread_db* tdbb, SET_TDBB(tdbb); Database* dbb = tdbb->getDatabase(); - ThreadStatusGuard tempStatus(tdbb); - START_CHECK_FOR_EXCEPTIONS(function->fun_exception_message.c_str()); if (function->fun_return_arg) { @@ -1334,12 +1344,6 @@ static void invoke(thread_db* tdbb, result_is_null = true; } END_CHECK_FOR_EXCEPTIONS(function->fun_exception_message.c_str()); - - // When exception happens inside UDF we have no better choice than storing it in - // tdbb_status_vector and raising again on return from UDF - - if (tempStatus[0] == isc_arg_gds && tempStatus[1] != FB_SUCCESS) - ERR_post(Arg::StatusVector(tempStatus)); }