8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 17:23:03 +01:00

cleaning up

This commit is contained in:
tamlin 2001-12-29 11:41:29 +00:00
parent a9fac72f12
commit 5ae485f0b5
32 changed files with 243 additions and 207 deletions

View File

@ -24,7 +24,7 @@
//
//____________________________________________________________
//
// $Id: alice.cpp,v 1.9 2001-12-28 05:14:41 tamlin Exp $
// $Id: alice.cpp,v 1.10 2001-12-29 11:41:21 tamlin Exp $
//
// 2001.07.06 Sean Leyne - Code Cleanup, removed "#ifdef READONLY_DATABASE"
// conditionals, as the engine now fully supports
@ -90,7 +90,7 @@ struct tgbl *gdgbl;
#define ALICE_MSG_FAC 3
#define EXIT(code) { tdgbl->exit_code = (code); \
Firebird::status_longjmp_error::raise(1); }
Firebird::status_exception::raise(1); }
#if defined (WIN95) && !defined (GUI_TOOLS)
static bool fAnsiCP = false;

View File

@ -27,7 +27,7 @@
*
*____________________________________________________________
*
* $Id: alice_meta.epp,v 1.3 2001-12-24 02:50:47 tamlin Exp $
* $Id: alice_meta.epp,v 1.4 2001-12-29 11:41:21 tamlin Exp $
*/
#include "firebird.h"
@ -91,13 +91,11 @@ static struct rfr_tab_t rfr_table[] = {
#ifdef GUI_TOOLS
#define RETURN_ERROR(user_status) \
{ memcpy (user_status, gds_status, sizeof (gds_status)); \
Firebird::status_longjmp_error::raise(0); }
// LONGJMP ((JMP_BUF)tdgbl->alice_env, 1); }
Firebird::status_exception::raise(0); }
#else
#define RETURN_ERROR(user_status) \
{ ALICE_print_status (gds_status); \
Firebird::status_longjmp_error::raise(0); }
// LONGJMP ((JMP_BUF)tdgbl->alice_env, 1); }
Firebird::status_exception::raise(0); }
#endif

View File

@ -865,7 +865,7 @@ extern struct tgbl *gdgbl;
// I had funnies with this cast
#define EXIT(code) { tdgbl->exit_code = ((volatile int)code); \
if (tdgbl->burp_env != NULL) \
Firebird::status_longjmp_error::raise(1); }
Firebird::status_exception::raise(1); }
#else
#error Dont do this, it hurts!

View File

@ -61,12 +61,12 @@
//
// This is a debug option ONLY and SHOULD NEVER be enabled in a production build
// because of its significant performance penality.
static const bool ENABLE_FREQUENT_VERIFICATION = true;
static const bool ENABLE_FREQUENT_VERIFICATION = false;
// These next variables control the Red Zone debugging offered by the memory pool
static const bool ENABLE_RED_ZONES = true; // set to false to disable the red zones
static const bool ENABLE_RED_ZONES = false; // set to false to disable the red zones
static const int RED_ZONE_FILL = 0xFD;
static const int BEFORE_RED_ZONE_SIZE = 3; // The size of the red zone BEFORE the memory,
// in ALLOCATION UNITS! Does NOT need to be set to
@ -308,7 +308,7 @@ extern "C" {
static void ERR_bugcheck(int number)
{
// What to do?
Firebird::status_longjmp_error::raise(number);
Firebird::status_exception::raise(number);
}
}
#endif
@ -320,7 +320,7 @@ static void ERR_bugcheck(int number)
static void private_ERR_bugcheck(int number)
{
Firebird::status_longjmp_error::raise(number);
Firebird::status_exception::raise(number);
}
// TMN: FIXFIX

View File

@ -20,7 +20,7 @@
* All Rights Reserved.
* Contributor(s): ______________________________________.
*
* $Id: ddl.cpp,v 1.5 2001-12-24 02:50:48 tamlin Exp $
* $Id: ddl.cpp,v 1.6 2001-12-29 11:41:22 tamlin Exp $
* 2001.5.20 Claudio Valderrama: Stop null pointer that leads to a crash,
* caused by incomplete yacc syntax that allows ALTER DOMAIN dom SET;
*
@ -255,7 +255,7 @@ void DDL_execute(REQ request)
}
if (s) {
Firebird::status_longjmp_error::raise(tdsql->tsql_status[1]);
Firebird::status_exception::raise(tdsql->tsql_status[1]);
}
}
@ -4708,7 +4708,7 @@ static void modify_relation( REQ request)
METD_drop_relation(request, relation_name);
request->req_relation = 0;
tdsql->tsql_setjmp = old_env;
Firebird::status_longjmp_error::raise(tdsql->tsql_status[1]);
Firebird::status_exception::raise(tdsql->tsql_status[1]);
}
}

View File

@ -25,7 +25,7 @@
* December 2001 Mike Nordell: Major overhaul to (try to) make it C++
*/
/*
$Id: dsql.cpp,v 1.7 2001-12-24 02:50:48 tamlin Exp $
$Id: dsql.cpp,v 1.8 2001-12-29 11:41:22 tamlin Exp $
*/
/**************************************************************
V4 Multi-threading changes.
@ -3944,7 +3944,7 @@ static void punt(void)
tdsql = GET_THREAD_DATA;
Firebird::status_longjmp_error::raise(tdsql->tsql_status[1]);
Firebird::status_exception::raise(tdsql->tsql_status[1]);
}

View File

@ -110,7 +110,7 @@ void ERRD_error( int code, const char* text)
sprintf(s, "** DSQL error: %s **\n", text);
TRACE(s);
Firebird::status_longjmp_error::raise(code);
Firebird::status_exception::raise(code);
}
@ -212,7 +212,7 @@ BOOLEAN ERRD_post_warning(STATUS status, ...)
}
void ERRD_post( STATUS status, ...)
void ERRD_post(STATUS status, ...)
{
/**************************************
*
@ -222,15 +222,17 @@ void ERRD_post( STATUS status, ...)
*
* Functional description
* Post an error, copying any potentially
* transient data before we do the longjmp.
* transient data before we punt.
*
**************************************/
STATUS *status_vector;
STATUS tmp_status[ISC_STATUS_LENGTH], warning_status[ISC_STATUS_LENGTH];
int i, tmp_status_len = 0, status_len = 0, err_status_len = 0;
int warning_count = 0, warning_indx = 0;
status_vector = ((TSQL) GET_THREAD_DATA)->tsql_status;
STATUS tmp_status[ISC_STATUS_LENGTH];
STATUS warning_status[ISC_STATUS_LENGTH];
int tmp_status_len = 0;
int status_len = 0;
int warning_indx = 0;
STATUS*status_vector = ((TSQL) GET_THREAD_DATA)->tsql_status;
/* stuff the status into temp buffer */
MOVE_CLEAR(tmp_status, sizeof(tmp_status));
@ -242,7 +244,8 @@ void ERRD_post( STATUS status, ...)
if (status_vector[0] != gds_arg_gds ||
(status_vector[0] == gds_arg_gds && status_vector[1] == 0 &&
status_vector[2] != gds_arg_warning)) {
status_vector[2] != gds_arg_warning))
{
/* this is a blank status vector */
status_vector[0] = gds_arg_gds;
status_vector[1] = gds_dsql_error;
@ -253,27 +256,36 @@ void ERRD_post( STATUS status, ...)
if (status_len)
--status_len;
/* check for duplicated error code */
for (i = 0; i < ISC_STATUS_LENGTH; i++) {
if (status_vector[i] == gds_arg_end && i == status_len)
// check for duplicated error code
int i;
for (i = 0; i < ISC_STATUS_LENGTH; i++)
{
if (status_vector[i] == gds_arg_end && i == status_len) {
break; /* end of argument list */
}
if (i && i == warning_indx)
if (i && i == warning_indx) {
break; /* vector has no more errors */
}
if (status_vector[i] == tmp_status[1] && i &&
status_vector[i - 1] != gds_arg_warning &&
i + tmp_status_len - 2 < ISC_STATUS_LENGTH &&
(memcmp(&status_vector[i], &tmp_status[1],
sizeof(STATUS) * (tmp_status_len - 2)) == 0)) {
sizeof(STATUS) * (tmp_status_len - 2)) == 0))
{
/* duplicate found */
ERRD_punt();
}
}
/* if the status_vector has only warnings then adjust err_status_len */
if ((err_status_len = i) == 2 && warning_indx)
// if the status_vector has only warnings then adjust err_status_len
int err_status_len = i;
if (err_status_len == 2 && warning_indx) {
err_status_len = 0;
}
int warning_count = 0;
if (warning_indx) {
/* copy current warning(s) to a temp buffer */
@ -283,14 +295,17 @@ void ERRD_post( STATUS status, ...)
PARSE_STATUS(warning_status, warning_count, warning_indx);
}
/* add the status into a real buffer right in between last error
and first warning */
// add the status into a real buffer right in between last
// error and first warning
if ((i = err_status_len + tmp_status_len) < ISC_STATUS_LENGTH) {
i = err_status_len + tmp_status_len;
if (i < ISC_STATUS_LENGTH)
{
MOVE_FASTER(tmp_status, &status_vector[err_status_len],
sizeof(STATUS) * tmp_status_len);
/* copy current warning(s) to the status_vector */
if (warning_count && i + warning_count - 1 < ISC_STATUS_LENGTH) {
if (warning_count && i + warning_count - 1 < ISC_STATUS_LENGTH)
{
MOVE_FASTER(warning_status, &status_vector[i - 1],
sizeof(STATUS) * warning_count);
@ -323,7 +338,7 @@ void ERRD_punt(void)
/* Give up whatever we were doing and return to the user. */
Firebird::status_longjmp_error::raise(tdsql->tsql_status[1]);
Firebird::status_exception::raise(tdsql->tsql_status[1]);
}

View File

@ -1442,7 +1442,7 @@ static void error_post(STATUS status, ...)
// Give up whatever we were doing and return to the user.
Firebird::status_longjmp_error::raise(UDSQL_error->dsql_status[1]);
Firebird::status_exception::raise(UDSQL_error->dsql_status[1]);
}

View File

@ -217,7 +217,7 @@ static void expand_error(
**************************************/
DDL_err(number, arg1, arg2, arg3, arg4, arg5);
Firebird::status_longjmp_error::raise(TRUE);
Firebird::status_exception::raise(TRUE);
}

View File

@ -196,7 +196,7 @@ void PARSE_error( USHORT number, TEXT * arg1, TEXT * arg2)
**************************************/
DDL_err(number, arg1, arg2, NULL, NULL, NULL);
Firebird::status_longjmp_error::raise(TRUE);
Firebird::status_exception::raise(TRUE);
}

View File

@ -20,7 +20,7 @@
//
// All Rights Reserved.
// Contributor(s): ______________________________________.
// $Id: gpre.cpp,v 1.6 2001-12-24 02:50:49 tamlin Exp $
// $Id: gpre.cpp,v 1.7 2001-12-29 11:41:22 tamlin Exp $
// Revision 1.2 2000/11/16 15:54:29 fsg
// Added new switch -verbose to gpre that will dump
// parsed lines to stderr
@ -38,7 +38,7 @@
//
//____________________________________________________________
//
// $Id: gpre.cpp,v 1.6 2001-12-24 02:50:49 tamlin Exp $
// $Id: gpre.cpp,v 1.7 2001-12-29 11:41:22 tamlin Exp $
//
#define GPRE_MAIN
@ -925,7 +925,7 @@ void CPR_abort()
{
++fatals;
Firebird::status_longjmp_error::raise(1);
Firebird::status_exception::raise(1);
}

View File

@ -20,7 +20,7 @@
//
// All Rights Reserved.
// Contributor(s): ______________________________________.
// $Id: par.cpp,v 1.4 2001-12-24 02:50:49 tamlin Exp $
// $Id: par.cpp,v 1.5 2001-12-29 11:41:22 tamlin Exp $
// Revision 1.2 2000/11/27 09:26:13 fsg
// Fixed bugs in gpre to handle PYXIS forms
// and allow edit.e and fred.e to go through
@ -37,7 +37,7 @@
//
//____________________________________________________________
//
// $Id: par.cpp,v 1.4 2001-12-24 02:50:49 tamlin Exp $
// $Id: par.cpp,v 1.5 2001-12-29 11:41:22 tamlin Exp $
//
#include "firebird.h"
@ -1156,12 +1156,7 @@ SYM PAR_symbol(enum sym_t type)
void PAR_unwind()
{
#pragma FB_COMPILER_MESSAGE("Fix! Wierd jmp_buf use! This might crash!")
//longjmp(*PAR_jmp_buf, (SLONG) 1);
Firebird::status_longjmp_error::raise(1);
Firebird::status_exception::raise(1);
}

View File

@ -29,19 +29,19 @@
namespace Firebird {
class status_longjmp_error : public std::exception
class status_exception : public std::exception
{
public:
explicit status_longjmp_error(STATUS s)
explicit status_exception(STATUS s)
: m_s(s)
{}
virtual ~status_longjmp_error() {}
virtual ~status_exception() {}
virtual const char* what() const
{ return "Firebird::status_longjmp_error"; }
{ return "Firebird::status_exception"; }
STATUS value() const { return m_s; }
// TMN: to be moved into its own source file!
static void raise(STATUS s) { throw status_longjmp_error(s); }
static void raise(STATUS s) { throw status_exception(s); }
private:
STATUS m_s;

View File

@ -206,7 +206,7 @@ int CLIB_ROUTINE main( int argc,
exit(FINI_OK);
} // try
catch (const Firebird::status_longjmp_error& e) {
catch (const Firebird::status_exception& e) {
exit(e.value());
}
}
@ -233,7 +233,7 @@ void GJRN_abort( int number)
gjrn_msg_partial(0, 0, 0, 0, 0, 0); /* msg 0: gbak:: */
GJRN_printf(1, NULL, NULL, NULL, NULL); /* msg 1: exiting journal utility due to errors */
Firebird::status_longjmp_error::raise(FINI_ERROR);
Firebird::status_exception::raise(FINI_ERROR);
}
@ -441,7 +441,7 @@ static int start_disable( int argc, SCHAR ** argv)
if ((*argv)[0] != '-') {
if (database) {
GJRN_printf(12, database, NULL, NULL, NULL); /* msg 12: database file name (%s) already specified */
Firebird::status_longjmp_error::raise(FINI_ERROR);
Firebird::status_exception::raise(FINI_ERROR);
}
database = *argv++;
continue;
@ -540,7 +540,7 @@ static int start_dump( int argc, SCHAR ** argv)
if ((*argv)[0] != '-') {
if (database) {
GJRN_printf(12, database, NULL, NULL, NULL); /* msg 12: database file name (%s) already specified */
Firebird::status_longjmp_error::raise(FINI_ERROR);
Firebird::status_exception::raise(FINI_ERROR);
}
database = *argv++;
continue;
@ -575,7 +575,7 @@ static int start_dump( int argc, SCHAR ** argv)
old_file_size = atoi(*argv++);
if (old_file_size <= 0) {
GJRN_printf(16, NULL, NULL, NULL, NULL); /* msg 16: online dump file size must be greater than zero */
Firebird::status_longjmp_error::raise(FINI_ERROR);
Firebird::status_exception::raise(FINI_ERROR);
}
}
else
@ -699,7 +699,7 @@ static int start_dump( int argc, SCHAR ** argv)
if (handle)
gds__detach_database(status_vector, GDS_REF(handle));
Firebird::status_longjmp_error::raise(FINI_ERROR);
Firebird::status_exception::raise(FINI_ERROR);
}
if (handle)
@ -759,7 +759,7 @@ static int start_enable( int argc, SCHAR ** argv)
if ((*argv)[0] != '-') {
if (database) {
GJRN_printf(12, database, NULL, NULL, NULL); /* msg 12: database file name (%s) already specified */
Firebird::status_longjmp_error::raise(FINI_ERROR);
Firebird::status_exception::raise(FINI_ERROR);
}
database = *argv++;
continue;

View File

@ -17,7 +17,7 @@
* Contributor(s): ______________________________________.
*/
/*
$Id: align.cpp,v 1.3 2001-12-24 02:50:50 tamlin Exp $
$Id: align.cpp,v 1.4 2001-12-29 11:41:22 tamlin Exp $
*/
#include "firebird.h"
@ -156,5 +156,5 @@ static int check_double()
static void handler()
{
Firebird::status_longjmp_error::raise(1);
Firebird::status_exception::raise(1);
}

View File

@ -522,7 +522,7 @@ void DLL_EXPORT ERR_punt(void)
#pragma FB_COMPILER_MESSAGE("FIXME! C functions can not throw! FIXME!")
Firebird::status_longjmp_error::raise(tdbb->tdbb_status_vector[1]);
Firebird::status_exception::raise(tdbb->tdbb_status_vector[1]);
}
#endif
@ -596,7 +596,7 @@ void DLL_EXPORT ERR_warning(STATUS status, ...)
*
* Functional description
* Write an error out to the status vector but
* don't longjmp back to the user. This allows
* don't throw an exception. This allows
* sending a warning message back to the user
* without stopping execution of a request. Note
* that subsequent errors can supersede this one.

View File

@ -21,7 +21,7 @@
* Contributor(s): ______________________________________.
*/
/*
$Id: exe.cpp,v 1.5 2001-12-28 06:31:38 tamlin Exp $
$Id: exe.cpp,v 1.6 2001-12-29 11:41:22 tamlin Exp $
*/
#include "firebird.h"
@ -116,7 +116,7 @@ static NOD send_msg(TDBB, register NOD);
static void set_error(TDBB, XCP);
static NOD stall(TDBB, register NOD);
static NOD store(TDBB, register NOD, SSHORT);
static BOOLEAN test_error(TDBB, XCP);
static BOOLEAN test_error(TDBB, const XCP);
static void trigger_failure(TDBB, REQ);
static void validate(TDBB, NOD);
@ -651,7 +651,7 @@ void EXE_receive(TDBB tdbb,
transaction->tra_save_point = request->req_proc_sav_point;
request->req_proc_sav_point = save_sav_point;
release_proc_save_points(request);
Firebird::status_longjmp_error::raise(-1);
Firebird::status_exception::raise(-1);
}
}
@ -1171,7 +1171,7 @@ static NOD erase(TDBB tdbb, NOD node, SSHORT which_trig)
} // try
catch (...) {
Firebird::status_longjmp_error::raise(-1);
Firebird::status_exception::raise(-1);
}
/* if the stream is navigational, it is now positioned on a crack */
@ -1336,7 +1336,7 @@ static void execute_procedure(TDBB tdbb, NOD node)
proc_request->req_flags &= ~(req_in_use | req_proc_fetch);
proc_request->req_timestamp = 0;
delete temp_buffer;
Firebird::status_longjmp_error::raise(-1);
Firebird::status_exception::raise(-1);
}
tdbb->tdbb_default = old_pool;
@ -1424,7 +1424,7 @@ static REQ execute_triggers(TDBB tdbb,
release_triggers(tdbb, vector);
}
if (!trigger) {
Firebird::status_longjmp_error::raise(-1);
Firebird::status_exception::raise(-1);
}
return trigger;
}
@ -1636,7 +1636,7 @@ static NOD looper(TDBB tdbb, REQ request, NOD in_node)
} \
catch (std::exception&) { \
if (dbb->dbb_flags & DBB_bugcheck) { \
Firebird::status_longjmp_error::raise(tdbb->tdbb_status_vector[1]); \
Firebird::status_exception::raise(tdbb->tdbb_status_vector[1]); \
} \
BUGCHECK (290); /* msg 290 error during savepoint backout */ \
}
@ -1663,15 +1663,16 @@ static NOD looper(TDBB tdbb, REQ request, NOD in_node)
VOLATILE NOD node = in_node;
/* Catch errors so we can unwind cleanly */
// Catch errors so we can unwind cleanly
SSHORT error_pending = FALSE;
try {
/* Execute stuff until we drop */
// Execute stuff until we drop
while (node && !(request->req_flags & req_stall)) {
while (node && !(request->req_flags & req_stall))
{
#ifdef MULTI_THREAD
if (request->req_operation == req::req_evaluate &&
@ -1829,8 +1830,9 @@ static NOD looper(TDBB tdbb, REQ request, NOD in_node)
/* If an error is still pending when the savepoint is
supposed to end, then the application didn't handle the
error and the savepoint should be undone. */
if (error_pending)
if (error_pending) {
++transaction->tra_save_point->sav_verb_count;
}
VERB_CLEANUP;
}
@ -1874,9 +1876,10 @@ static NOD looper(TDBB tdbb, REQ request, NOD in_node)
case req::req_unwind:
{
VOLATILE NOD handlers, *ptr, *end;
VOLATILE NOD *ptr, *end;
if (request->req_flags & req_leave) {
if (request->req_flags & req_leave)
{
/** Although the req_operation is set to req_unwind
it is not an error case if req_leave bit is set.
req_leave bit indicates that we hit an EXIT
@ -1886,7 +1889,8 @@ static NOD looper(TDBB tdbb, REQ request, NOD in_node)
node = node->nod_parent;
break;
}
if (transaction != dbb->dbb_sys_trans) {
if (transaction != dbb->dbb_sys_trans)
{
MOVE_FAST((SCHAR *) request + node->nod_impure,
&count, sizeof(SLONG));
/* Since there occurred an error (req_unwind), undo all savepoints
@ -1899,18 +1903,21 @@ static NOD looper(TDBB tdbb, REQ request, NOD in_node)
VERB_CLEANUP;
}
}
if ( (handlers = node->nod_arg[e_blk_handlers]) ) {
VOLATILE NOD handlers = node->nod_arg[e_blk_handlers];
if (handlers)
{
ULONG prev_req_error_handler;
node = node->nod_parent;
for (ptr = handlers->nod_arg,
end = ptr + handlers->nod_count; ptr < end;
ptr++)
if (test_error
(tdbb,
reinterpret_cast <
xcp *
>((*ptr)->nod_arg[e_err_conditions]))) {
{
const XCP pXcp =
reinterpret_cast<XCP>((*ptr)->nod_arg[e_err_conditions]);
if (test_error(tdbb, pXcp))
{
request->req_operation = req::req_evaluate;
node = (*ptr)->nod_arg[e_err_action];
error_pending = FALSE;
@ -1949,19 +1956,23 @@ static NOD looper(TDBB tdbb, REQ request, NOD in_node)
tdbb->tdbb_request = request;
/* The error is dealt with by the application, cleanup
this block's savepoint. */
if (transaction != dbb->dbb_sys_trans) {
for (save_point =
transaction->tra_save_point;
save_point
&& count <= save_point->sav_number;
save_point =
transaction->tra_save_point)
VERB_CLEANUP;
if (transaction != dbb->dbb_sys_trans)
{
for (save_point = transaction->tra_save_point;
save_point &&
count <= save_point->sav_number;
save_point = transaction->tra_save_point)
{
VERB_CLEANUP;
}
}
}
}
}
else
{
node = node->nod_parent;
}
/* If the application didn't have an error handler, then
the error will still be pending. Undo the block by
@ -2307,13 +2318,15 @@ static NOD looper(TDBB tdbb, REQ request, NOD in_node)
default:
BUGCHECK(168); /* msg 168 looper: action not yet implemented */
}
#ifdef HSDEBUGSTACK
TestStack();
#endif
#if defined(DEBUG_GDS_ALLOC) && defined(PROD_BUILD)
memory_count++;
if ((memory_count % memory_debug) == 0)
if ((memory_count % memory_debug) == 0) {
ALL_check_memory();
}
#endif
}
@ -2324,7 +2337,8 @@ static NOD looper(TDBB tdbb, REQ request, NOD in_node)
#ifdef SCROLLABLE_CURSORS
&& !(request->req_flags & req_async_processing)
#endif
) {
)
{
request->req_flags &= ~(req_active | req_reserved);
request->req_timestamp = 0;
release_blobs(tdbb, request);
@ -2335,9 +2349,9 @@ static NOD looper(TDBB tdbb, REQ request, NOD in_node)
tdbb->tdbb_transaction = (tdbb->tdbb_request = old_request) ?
old_request->req_transaction : 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 delete
the last savepoint */
// in the case of a pending error condition (one which did not
// result in a exception to the top of looper), we need to
// delete the last savepoint
if (error_pending) {
if (transaction != dbb->dbb_sys_trans) {
@ -2358,9 +2372,9 @@ static NOD looper(TDBB tdbb, REQ request, NOD in_node)
ERR_punt();
}
/* if the request was aborted, assume that we have already
longjmp'ed to the top of looper, and therefore that the last
savepoint has already been deleted */
// if the request was aborted, assume that we have already
// longjmp'ed to the top of looper, and therefore that the
// last savepoint has already been deleted
if (request->req_flags & req_abort) {
ERR_post(gds_req_sync, 0);
@ -2370,7 +2384,7 @@ static NOD looper(TDBB tdbb, REQ request, NOD in_node)
catch (...) {
/* If the database is already bug-checked, then get out. */
if (dbb->dbb_flags & DBB_bugcheck) {
Firebird::status_longjmp_error::raise(tdbb->tdbb_status_vector[1]);
Firebird::status_exception::raise(tdbb->tdbb_status_vector[1]);
}
#ifdef GATEWAY
@ -2612,7 +2626,7 @@ static NOD modify(TDBB tdbb, register NOD node, SSHORT which_trig)
} // try
catch (...) {
Firebird::status_longjmp_error::raise(-1);
Firebird::status_exception::raise(-1);
}
/* if the stream is navigational, we must position the stream on the new
@ -3403,30 +3417,25 @@ static NOD store(TDBB tdbb, register NOD node, SSHORT which_trig)
* Execute a STORE statement.
*
**************************************/
DBB dbb;
register REQ request;
STA impure;
REQ trigger;
FMT format;
SSHORT stream, n;
SSHORT n;
USHORT length;
REC record;
RPB *rpb;
DSC *desc;
REL relation;
TRA transaction;
register UCHAR *p;
SET_TDBB(tdbb);
dbb = tdbb->tdbb_database;
DBB dbb = tdbb->tdbb_database;
BLKCHK(node, type_nod);
request = tdbb->tdbb_request;
transaction = request->req_transaction;
impure = (STA) ((SCHAR *) request + node->nod_impure);
stream = (USHORT) node->nod_arg[e_sto_relation]->nod_arg[e_rel_stream];
rpb = &request->req_rpb[stream];
relation = rpb->rpb_relation;
REQ request = tdbb->tdbb_request;
TRA transaction = request->req_transaction;
STA impure = (STA) ((SCHAR *) request + node->nod_impure);
SSHORT stream = (USHORT) node->nod_arg[e_sto_relation]->nod_arg[e_rel_stream];
RPB* rpb = &request->req_rpb[stream];
REL relation = rpb->rpb_relation;
switch (request->req_operation) {
case req::req_evaluate:
@ -3448,71 +3457,83 @@ static NOD store(TDBB tdbb, register NOD node, SSHORT which_trig)
(which_trig != POST_TRIG) &&
(trigger = execute_triggers(tdbb, &relation->rel_pre_store,
0, record)))
trigger_failure(tdbb, trigger);
{
trigger_failure(tdbb, trigger);
}
#endif
if (node->nod_arg[e_sto_validate])
if (node->nod_arg[e_sto_validate]) {
validate(tdbb, node->nod_arg[e_sto_validate]);
}
/* For optimum on-disk record compression, zero all unassigned
fields. In addition, zero the tail of assigned varying fields
so that previous remnants don't defeat compression efficiency. */
for (n = 0; n < format->fmt_count; n++) {
for (n = 0; n < format->fmt_count; n++)
{
desc = &format->fmt_desc[n];
if (!desc->dsc_address)
if (!desc->dsc_address) {
continue;
p = record->rec_data + (SLONG) desc->dsc_address;
if (TEST_NULL(record, n)) {
if ( (length = desc->dsc_length) )
do
*p++ = 0;
while (--length);
}
else if (desc->dsc_dtype == dtype_varying) {
VARY *vary;
vary = (VARY *) p;
if ((length = desc->dsc_length - sizeof(USHORT)) >
vary->vary_length) {
p = record->rec_data + (SLONG) desc->dsc_address;
if (TEST_NULL(record, n))
{
length = desc->dsc_length;
if (length) {
do {
*p++ = 0;
} while (--length);
}
}
else if (desc->dsc_dtype == dtype_varying)
{
VARY* vary = (VARY *) p;
length = desc->dsc_length - sizeof(USHORT);
if (length > vary->vary_length)
{
p = reinterpret_cast<UCHAR*>(vary->vary_string + vary->vary_length);
length -= vary->vary_length;
do
do {
*p++ = 0;
while (--length);
} while (--length);
}
}
}
#ifndef GATEWAY
if (relation->rel_file)
if (relation->rel_file) {
EXT_store(rpb, reinterpret_cast < int *>(transaction));
else if (!relation->rel_view_rse) {
}
else if (!relation->rel_view_rse)
{
SSHORT bad_index;
REL bad_relation;
IDX_E error_code;
VIO_store(tdbb, rpb, transaction);
if ((error_code = IDX_store(tdbb,
IDX_E error_code = IDX_store(tdbb,
rpb,
transaction,
&bad_relation,
reinterpret_cast <
USHORT *
>(&bad_index))))
ERR_duplicate_error(error_code, bad_relation, bad_index);
reinterpret_cast<USHORT*>(&bad_index));
if (error_code) {
ERR_duplicate_error(error_code, bad_relation, bad_index);
}
}
if (relation->rel_post_store &&
(which_trig != PRE_TRIG) &&
(trigger = execute_triggers(tdbb, &relation->rel_post_store,
0, record)))
trigger_failure(tdbb, trigger);
{
trigger_failure(tdbb, trigger);
}
request->req_records_inserted++;
if (transaction != dbb->dbb_sys_trans)
if (transaction != dbb->dbb_sys_trans) {
--transaction->tra_save_point->sav_verb_count;
}
#else
VIO_store(tdbb, rpb, transaction, node->nod_arg[e_sto_sql]);
#endif
@ -3543,10 +3564,12 @@ static NOD store(TDBB tdbb, register NOD node, SSHORT which_trig)
#ifndef GATEWAY
p = record->rec_data;
if ( (n = (format->fmt_count + 7) >> 3) )
do
n = (format->fmt_count + 7) >> 3;
if (n) {
do {
*p++ = 0xff;
while (--n);
} while (--n);
}
#else
EXE_set_fields_null(tdbb, record, format);
#endif
@ -3596,7 +3619,7 @@ static NOD stream(TDBB tdbb, register NOD node)
#endif
static BOOLEAN test_error(TDBB tdbb, XCP conditions)
static BOOLEAN test_error(TDBB tdbb, const XCP conditions)
{
/**************************************
*
@ -3608,15 +3631,15 @@ static BOOLEAN test_error(TDBB tdbb, XCP conditions)
* Test for match of current state with list of error conditions.
*
**************************************/
SSHORT i, sqlcode;
STATUS *status_vector;
SET_TDBB(tdbb);
status_vector = tdbb->tdbb_status_vector;
sqlcode = gds__sqlcode(status_vector);
STATUS* status_vector = tdbb->tdbb_status_vector;
SSHORT sqlcode = gds__sqlcode(status_vector);
for (i = 0; i < conditions->xcp_count; i++) {
switch (conditions->xcp_rpt[i].xcp_type) {
for (SSHORT i = 0; i < conditions->xcp_count; ++i)
{
switch (conditions->xcp_rpt[i].xcp_type)
{
case xcp_sql_code:
if (sqlcode == conditions->xcp_rpt[i].xcp_code) {
status_vector[0] = 0;
@ -3635,7 +3658,8 @@ static BOOLEAN test_error(TDBB tdbb, XCP conditions)
case xcp_xcp_code:
if ((status_vector[1] == gds_except) &&
(status_vector[3] == conditions->xcp_rpt[i].xcp_code)) {
(status_vector[3] == conditions->xcp_rpt[i].xcp_code))
{
status_vector[0] = 0;
status_vector[1] = 0;
return TRUE;
@ -3666,37 +3690,47 @@ static void trigger_failure(TDBB tdbb, REQ trigger)
* Trigger failed, report error.
*
**************************************/
TEXT *msg;
STATUS code;
SET_TDBB(tdbb);
EXE_unwind(tdbb, trigger);
trigger->req_attachment = NULL;
trigger->req_flags &= ~req_in_use;
trigger->req_timestamp = 0;
if (trigger->req_flags & req_leave) {
if (trigger->req_flags & req_leave)
{
trigger->req_flags &= ~req_leave;
TEXT* msg;
if (trigger->req_trg_name &&
(msg =
MET_trigger_msg(tdbb, trigger->req_trg_name,
trigger->req_label))) {
if (trigger->req_flags & req_sys_trigger) {
code = PAR_symbol_to_gdscode(msg);
(msg = MET_trigger_msg(tdbb,
trigger->req_trg_name,
trigger->req_label)))
{
if (trigger->req_flags & req_sys_trigger)
{
STATUS code = PAR_symbol_to_gdscode(msg);
if (code)
{
ERR_post(gds_integ_fail,
gds_arg_number, (SLONG) trigger->req_label,
gds_arg_gds, code, 0);
}
}
ERR_post(gds_integ_fail,
gds_arg_number, (SLONG) trigger->req_label,
gds_arg_gds, gds_random, gds_arg_string, msg, 0);
}
else
{
ERR_post(gds_integ_fail, gds_arg_number,
(SLONG) trigger->req_label, 0);
}
}
else
{
ERR_punt();
}
}
#endif
@ -3713,11 +3747,12 @@ static void validate(TDBB tdbb, NOD list)
* Execute a list of validation expressions.
*
**************************************/
NOD *ptr1, *ptr2;
SET_TDBB(tdbb);
BLKCHK(list, type_nod);
NOD *ptr1, *ptr2;
for (ptr1 = list->nod_arg, ptr2 = ptr1 + list->nod_count;
ptr1 < ptr2; ptr1++)
{

View File

@ -3868,7 +3868,7 @@ static void blr_error(CTL control, TEXT * string, TEXT * arg1)
blr_format(control, string, arg1);
offset = 0;
PRINT_LINE;
Firebird::status_longjmp_error::raise(-1);
Firebird::status_exception::raise(-1);
}

View File

@ -87,7 +87,7 @@
*/
/*
$Id: ib_stdio.cpp,v 1.3 2001-12-24 02:50:51 tamlin Exp $
$Id: ib_stdio.cpp,v 1.4 2001-12-29 11:41:23 tamlin Exp $
*/
#include "firebird.h"
@ -371,8 +371,8 @@ int ib__sflush(register IB_FILE * fp)
n = fp->_p - p; /* write this much */
/*
* Set these immediately to avoid problems with longjmp and to allow
* exchange buffering (via setvbuf) in user write function.
* Set these immediately to allow exchange buffering
* (via setvbuf) in user write function.
*/
fp->_p = p;
fp->_w = t & (IB__SLBF | IB__SNBF) ? 0 : fp->_bf._size;
@ -4012,7 +4012,7 @@ int ib__swbuf(register int c, register IB_FILE * fp)
register int n;
/*
* In case we cannot write, or longjmp takes us out early,
* In case we cannot write, or an exception takes us out early,
* make sure _w is 0 (if fully- or un-buffered) or -_bf._size
* (if line buffered) so that we will get called again.
* If we did not do this, a sufficient number of ib_putc()

View File

@ -162,6 +162,6 @@ static void post_error(
}
if (longjmp_addr) {
Firebird::status_longjmp_error::raise(status_vector[1]);
Firebird::status_exception::raise(status_vector[1]);
}
}

View File

@ -61,7 +61,7 @@ extern "C" {
#define getpid() 0
#endif
static void bug_lck(TEXT *);
static void bug_lck(TEXT*);
static void check_lock(LCK, USHORT);
static BOOLEAN compatible(LCK, LCK, USHORT);
static void enqueue(TDBB, LCK, USHORT, SSHORT);
@ -485,12 +485,10 @@ SLONG LCK_get_owner_handle(TDBB tdbb, enum lck_t lock_type)
* return the right kind of lock owner given a lock type.
*
**************************************/
DBB dbb;
ATT attachment;
SET_TDBB(tdbb);
dbb = tdbb->tdbb_database;
attachment = tdbb->tdbb_attachment;
DBB dbb = tdbb->tdbb_database;
ATT attachment = tdbb->tdbb_attachment;
switch (lock_type) {
case LCK_database:
case LCK_bdb:
@ -513,7 +511,7 @@ SLONG LCK_get_owner_handle(TDBB tdbb, enum lck_t lock_type)
return LCK_OWNER_HANDLE_ATT;
default:
bug_lck("Invalid lock type in LCK_get_owner_handle ()");
/* Not Reached - bug_lck longjmp's out */
/* Not Reached - bug_lck calls ERR_post */
return 0;
}
}
@ -924,7 +922,7 @@ void LCK_write_data(LCK lock, SLONG data)
#endif
static void bug_lck(TEXT * string)
static void bug_lck(TEXT* string)
{
/**************************************
*

View File

@ -1154,7 +1154,7 @@ static BOOLEAN find_dbkey(RSB rsb, ULONG record_number)
catch (...) {
CCH_RELEASE(tdbb, &window);
tdbb->tdbb_setjmp = (UCHAR *) old_env;
Firebird::status_longjmp_error::raise(-1);
Firebird::status_exception::raise(-1);
}
}
#endif
@ -1350,7 +1350,7 @@ static BOOLEAN find_record(
catch (...) {
CCH_RELEASE(tdbb, &window);
tdbb->tdbb_setjmp = (UCHAR *) old_env;
Firebird::status_longjmp_error::raise(-1);
Firebird::status_exception::raise(-1);
}
}
#endif
@ -1710,7 +1710,7 @@ static BOOLEAN get_record(
tdbb->tdbb_attachment->att_flags |=
(old_att_flags & ATT_no_cleanup);
tdbb->tdbb_setjmp = (UCHAR *) old_env;
Firebird::status_longjmp_error::raise(-1);
Firebird::status_exception::raise(-1);
}
return result;

View File

@ -288,8 +288,7 @@ void SCL_check_index( TDBB tdbb, TEXT * index_name, USHORT mask)
if (request) {
CMP_release(tdbb, (REQ) request);
}
// LONGJMP(*(JMP_BUF*)&tdbb->tdbb_setjmp, (int) tdbb->tdbb_status_vector[1]);
Firebird::status_longjmp_error::raise(tdbb->tdbb_status_vector[1]);
Firebird::status_exception::raise(tdbb->tdbb_status_vector[1]);
}
}
@ -977,8 +976,7 @@ static BOOLEAN check_user_group(CONST TEXT* acl,
catch (...) {
tdbb->tdbb_setjmp = (UCHAR *) old_env;
delete buffer;
// LONGJMP(*(JMP_BUF*)&tdbb->tdbb_setjmp, (int) tdbb->tdbb_status_vector[1]);
Firebird::status_longjmp_error::raise(tdbb->tdbb_status_vector[1]);
Firebird::status_exception::raise(tdbb->tdbb_status_vector[1]);
}
return (n != number);
@ -1129,8 +1127,7 @@ static SLONG compute_access(TDBB tdbb,
catch (...) {
tdbb->tdbb_setjmp = (UCHAR *) old_env;
delete str_buffer;
// LONGJMP(*(JMP_BUF*)&tdbb->tdbb_setjmp, (int) tdbb->tdbb_status_vector[1]);
Firebird::status_longjmp_error::raise(tdbb->tdbb_status_vector[1]);
Firebird::status_exception::raise(tdbb->tdbb_status_vector[1]);
}
return privileges;

View File

@ -522,7 +522,7 @@ static USHORT process_statement( USHORT flush_flag)
return FALSE;
} // try
catch (const Firebird::status_longjmp_error& e) {
catch (const Firebird::status_exception& e) {
GEN_release();
return e.value();
}

View File

@ -95,7 +95,7 @@ void ERRQ_database_error( DBB dbb, STATUS * status_vector)
ERRQ_msg_put(458, dbb->dbb_filename, NULL, NULL, NULL, NULL); /* Msg458 ** connection to database %s lost ** */
if (QLI_env) {
Firebird::status_longjmp_error::raise(-1);
Firebird::status_exception::raise(-1);
}
}
@ -122,7 +122,7 @@ void ERRQ_error(
ERRQ_error_format(number, arg1, arg2, arg3, arg4, arg5);
if (QLI_env)
Firebird::status_longjmp_error::raise(-1);
Firebird::status_exception::raise(-1);
else {
ERRQ_pending();
ERRQ_exit(FINI_ERROR);

View File

@ -95,7 +95,7 @@ UCHAR* DLL_EXPORT ALLR_alloc(ULONG size)
*status_vector = gds_arg_end;
}
Firebird::status_longjmp_error::raise(gds_virmemexh);
Firebird::status_exception::raise(gds_virmemexh);
return NULL; /* compiler silencer */
}
@ -138,7 +138,7 @@ BLK DLL_EXPORT ALLR_block(UCHAR type, ULONG count)
}
}
Firebird::status_longjmp_error::raise(gds_bug_check);
Firebird::status_exception::raise(gds_bug_check);
}
// Compute block length, recasting count to make sure the calculation

View File

@ -4678,7 +4678,7 @@ static BOOLEAN batch_dsql_fetch(trdb* trdb,
statement->rsr_rows_pending = 0;
--statement->rsr_batch_count;
dequeue_receive(port);
Firebird::status_longjmp_error::raise(user_status[1]);
Firebird::status_exception::raise(user_status[1]);
}
if (packet->p_operation != op_fetch_response) {
@ -4839,7 +4839,7 @@ static BOOLEAN batch_gds_receive(trdb* trdb,
tail->rrq_rows_pending = 0;
--tail->rrq_batch_count;
dequeue_receive(port);
Firebird::status_longjmp_error::raise(user_status[1]);
Firebird::status_exception::raise(user_status[1]);
}
if (packet->p_operation != op_send) {
@ -5844,7 +5844,7 @@ static void move_error( STATUS status, ...)
if (p_args >= end_args)
end_args[-1] = gds_arg_end;
Firebird::status_longjmp_error::raise(trdb->trdb_status_vector[1]);
Firebird::status_exception::raise(trdb->trdb_status_vector[1]);
}

View File

@ -333,7 +333,7 @@ void SRVR_multi_thread( PORT main_port, USHORT flags)
#ifdef DEV_BUILD
#ifdef DEBUG
if ((request_count++ % 4) == 0) {
Firebird::status_longjmp_error::raise(gds__virmemexh);
Firebird::status_exception::raise(gds__virmemexh);
}
#endif /* DEBUG */
#endif /* DEV_BUILD */
@ -357,7 +357,7 @@ void SRVR_multi_thread( PORT main_port, USHORT flags)
#ifdef DEV_BUILD
#ifdef DEBUG
if ((request_count % 5) == 0) {
Firebird::status_longjmp_error::raise(gds__virmemexh);
Firebird::status_exception::raise(gds__virmemexh);
}
#endif /* DEBUG */
#endif /* DEV_BUILD */

View File

@ -227,11 +227,8 @@ static struct tdba *gddba;
#define RESTORE_THREAD_DATA
#endif
//#define EXIT(code) { tddba->exit_code = code; \
// LONGJMP(*reinterpret_cast<jmp_buf*>(&tddba->dba_env), 1); }
#define EXIT(code) { tddba->exit_code = code; \
Firebird::status_longjmp_error::raise(0); }
Firebird::status_exception::raise(0); }
#define GSTAT_MSG_FAC 21

View File

@ -36,6 +36,7 @@
#include "../jrd/isc_f_proto.h"
#include "../jrd/thd.h"
#include "../jrd/enc_proto.h"
#include "../include/fb_exception.h"
#ifdef WIN_NT
#include <io.h>
@ -210,7 +211,7 @@ static struct tdba *gddba;
#endif
#define EXIT(code) { tddba->exit_code = code; \
LONGJMP(tddba->dba_env, 1); }
Firebird::status_exception::raise(1); }
#ifdef NETWARE_386

View File

@ -87,7 +87,7 @@ typedef int (DLL_EXPORT* OUTPUTPROC) (SLONG, UCHAR *);
#define EXIT(code) { tdsec->tsec_exit_code = (code); \
if (tdsec->tsec_env != NULL) \
Firebird::status_longjmp_error::raise(1); }
Firebird::status_exception::raise(1); }
typedef struct user_data {
int operation; /* what's to be done */

View File

@ -1767,7 +1767,7 @@ static void report_walw_bug_or_error(
ib_fprintf(DEBUG_FD, "WAL writer encountered error, code=%d\n", code);
}
Firebird::status_longjmp_error::raise(status_vector[1]);
Firebird::status_exception::raise(status_vector[1]);
}