From: Vlad H. <hv...@us...> - 2006-07-31 20:23:55
|
Build Version : V2.0.0.4858 Vulcan 1.0 Development (writeBuildNum.sh,v 1.1.1.831 2006/07/31 20:23:51 hvlad Exp ) Update of /cvsroot/firebird/vulcan/src/jrd In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv19107/src/jrd Modified Files: exe.cpp gds.cpp tdbb.h Log Message: Ported FB2 ability to stuff PSQL stack trace into status vector Index: exe.cpp =================================================================== RCS file: /cvsroot/firebird/vulcan/src/jrd/exe.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -b -U3 -r1.19 -r1.20 --- exe.cpp 17 May 2006 12:59:41 -0000 1.19 +++ exe.cpp 31 Jul 2006 20:23:51 -0000 1.20 @@ -173,6 +173,7 @@ static void trigger_failure(thread_db*, Request*); static void validate(thread_db*, JRD_NOD); inline void PreModifyEraseTriggers(thread_db*, Relation*, Triggers**, SSHORT, record_param*, Record*, req_ta); +static void stuff_stack_trace(Request* request, OSRIException& exception); #ifdef PC_ENGINE static JRD_NOD find(thread_db*, JRD_NOD); @@ -209,6 +210,8 @@ #define PRE_TRIG 1 #define POST_TRIG 2 +const size_t MAX_STACK_TRACE = 2048; + /* this constant defines how many records are locked before we check whether record locking has been turned off for a given relation; if we set the @@ -1486,7 +1489,56 @@ } +static void stuff_stack_trace(Request* request, OSRIException& exception) +{ + JString sTrace; + bool isEmpty = true; + + for (Request* req = request; req; req = req->req_caller) + { + JString name; + + if (req->req_trg_name.length()) { + name = "At trigger '"; + name += req->req_trg_name; + } + else if (req->req_procedure) { + name = "At procedure '"; + name += req->req_procedure->findName(); + } + + if (! name.IsEmpty()) + { + // name.trim(); + + if (sTrace.length() + name.length() + 2 > MAX_STACK_TRACE) + break; + + if (isEmpty) { + isEmpty = false; + } + else { + sTrace += "\n"; + } + sTrace += name + "'"; + //if (req->req_src_line) + //{ + // Firebird::string src_info; + // src_info.printf(" line: %u, col: %u", req->req_src_line, req->req_src_column); + + // if (sTrace.length() + src_info.length() > MAX_STACK_TRACE) + // break; + + // sTrace += src_info; + //} + } + } + + if (!isEmpty) + // ERR_post_nothrow(isc_stack_trace, isc_arg_string, ERR_cstring(sTrace), 0); + exception.postException(isc_stack_trace, isc_arg_string, ERR_cstring(sTrace), 0); +} static JRD_NOD looper(thread_db* tdbb, Request *request, JRD_NOD in_node) @@ -1546,6 +1598,9 @@ Request *old_request = tdbb->tdbb_request; tdbb->tdbb_request = request; tdbb->tdbb_transaction = transaction; + fb_assert(request->req_caller == NULL); + request->req_caller = old_request; + SLONG save_point_number = (transaction->tra_save_point) ? transaction->tra_save_point->sav_number : 0; JRD_NOD node = in_node; @@ -1715,7 +1770,7 @@ if (request->req_operation == req_evaluate) { if (impure->irsb_flags & irsb_open) - ERR_post(isc_invalid_cursor_state, isc_arg_string, "open", 0); + ERR_post(isc_cursor_already_open, 0); //RSE_open(tdbb, rsb); rsb->open(request); @@ -1728,7 +1783,7 @@ if (request->req_operation == req_evaluate) { if (!(impure->irsb_flags & irsb_open)) - ERR_post(isc_invalid_cursor_state, isc_arg_string, "closed", 0); + ERR_post(isc_cursor_not_open, 0); //RSE_close(tdbb, rsb); rsb->close(request); @@ -1743,7 +1798,7 @@ { case req_evaluate: if (!(impure->irsb_flags & irsb_open)) - ERR_post(isc_invalid_cursor_state, isc_arg_string, "closed", 0); + ERR_post(isc_cursor_not_open, 0); if (node->nod_arg[e_cursor_stmt_seek]) { @@ -2041,6 +2096,8 @@ tdbb->tdbb_default = old_pool; tdbb->tdbb_request = old_request; + fb_assert(request->req_caller == old_request); + request->req_caller = NULL; /* Save the previous state of req_error_handler bit. We need to restore it later. This is @@ -2069,6 +2126,8 @@ catch_disabled = false; tdbb->tdbb_default = request->req_pool; tdbb->tdbb_request = request; + fb_assert(request->req_caller == NULL); + request->req_caller = old_request; /* The error is dealt with by the application, cleanup this block's savepoint. */ @@ -2117,8 +2176,11 @@ case nod_error_handler: if (request->req_flags & req_error_handler && !error_pending) + { + fb_assert(request->req_caller == old_request); + request->req_caller = NULL; return node; - + } node = node->nod_parent; node = node->nod_parent; @@ -2451,6 +2513,12 @@ pendingException = exception; request->req_operation = req_unwind; request->req_label = 0; + + if (! (tdbb->tdbb_flags & TDBB_stack_trace_done) ) + { + stuff_stack_trace(request, pendingException); + tdbb->tdbb_flags |= TDBB_stack_trace_done; + } } } // while() @@ -2489,6 +2557,8 @@ request->req_next = node; tdbb->tdbb_default = old_pool; tdbb->tdbb_transaction = (tdbb->tdbb_request = old_request) ? old_request->req_transaction : NULL; + fb_assert(request->req_caller == old_request); + request->req_caller = NULL; // in the case of a pending error condition (one which did not // result in a exception to the top of looper), we need to Index: gds.cpp =================================================================== RCS file: /cvsroot/firebird/vulcan/src/jrd/gds.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -b -U3 -r1.9 -r1.10 --- gds.cpp 7 Apr 2006 12:05:38 -0000 1.9 +++ gds.cpp 31 Jul 2006 20:23:51 -0000 1.10 @@ -1865,9 +1865,9 @@ USHORT code = (USHORT) gds__decode(status_vector[1], &fac, &class_); if ((code < FB_NELEM(gds__sql_code)) && - (gds__sql_code[code] != GENERIC_SQLCODE)) + (gds__sql_code[code].sql_code != GENERIC_SQLCODE)) { - sqlcode = gds__sql_code[code]; + sqlcode = gds__sql_code[code].sql_code; have_sqlcode = true; } } Index: tdbb.h =================================================================== RCS file: /cvsroot/firebird/vulcan/src/jrd/tdbb.h,v retrieving revision 1.6 retrieving revision 1.7 diff -b -U3 -r1.6 -r1.7 --- tdbb.h 18 Oct 2005 19:20:32 -0000 1.6 +++ tdbb.h 31 Jul 2006 20:23:51 -0000 1.7 @@ -17,7 +17,7 @@ const USHORT TDBB_prc_being_dropped = 4; /* Dropping a procedure */ const USHORT TDBB_set_backup_state = 8; /* Setting state for backup lock */ const USHORT TDBB_backup_merge = 16; /* Merging changes from difference file */ -//const USHORT TDBB_stack_trace_done = 32; /* PSQL stack trase is added into status-vector */ +const USHORT TDBB_stack_trace_done = 32; /* PSQL stack trase is added into status-vector */ #define MAX_THREAD_BDBS 10 |