8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-24 06:43:03 +01:00

Since Vlad and Alex did the hard work, I took the comment from Mike (approx 6 years ago) and did the small change function->method.

This commit is contained in:
robocop 2008-03-28 13:36:19 +00:00
parent b27e6828c9
commit 443feabad9
4 changed files with 57 additions and 57 deletions

View File

@ -1344,7 +1344,7 @@ ISC_STATUS GDS_DSQL_EXECUTE2(ISC_STATUS* user_status,
message->msg_address = in_msg; message->msg_address = in_msg;
statement->rsr_flags &= ~Rsr::FETCHED; statement->rsr_flags &= ~Rsr::FETCHED;
statement->rsr_format = statement->rsr_bind_format; statement->rsr_format = statement->rsr_bind_format;
stmt_clear_exception(statement); statement->clearException();
/* set up the packet for the other guy... */ /* set up the packet for the other guy... */
@ -1572,7 +1572,7 @@ ISC_STATUS GDS_DSQL_EXECUTE_IMMED2(ISC_STATUS* user_status,
message->msg_address = in_msg; message->msg_address = in_msg;
stmt_clear_exception(statement); statement->clearException();
/* set up the packet for the other guy... */ /* set up the packet for the other guy... */
@ -1681,11 +1681,11 @@ ISC_STATUS GDS_DSQL_FETCH(ISC_STATUS* user_status,
if (!(statement->rsr_flags & Rsr::FETCHED)) if (!(statement->rsr_flags & Rsr::FETCHED))
{ {
stmt_raise_exception(statement); statement->raiseException();
statement->rsr_flags &= ~(Rsr::EOF_SET | Rsr::STREAM_ERR | Rsr::PAST_EOF); statement->rsr_flags &= ~(Rsr::EOF_SET | Rsr::STREAM_ERR | Rsr::PAST_EOF);
statement->rsr_rows_pending = 0; statement->rsr_rows_pending = 0;
stmt_clear_exception(statement); statement->clearException();
REM_MSG message = statement->rsr_message; REM_MSG message = statement->rsr_message;
if (message) if (message)
@ -1779,7 +1779,7 @@ ISC_STATUS GDS_DSQL_FETCH(ISC_STATUS* user_status,
/* We've reached eof or there was an error */ /* We've reached eof or there was an error */
!(statement->rsr_flags & (Rsr::EOF_SET | Rsr::STREAM_ERR)) && !(statement->rsr_flags & (Rsr::EOF_SET | Rsr::STREAM_ERR)) &&
/* No error pending */ /* No error pending */
(!stmt_have_exception(statement) ))) (!statement->haveException() )))
{ {
/* set up the packet for the other guy... */ /* set up the packet for the other guy... */
@ -1835,10 +1835,10 @@ ISC_STATUS GDS_DSQL_FETCH(ISC_STATUS* user_status,
/* We've either got data, or some is on the way, or we have an error, or we have EOF */ /* We've either got data, or some is on the way, or we have an error, or we have EOF */
fb_assert(statement->rsr_msgs_waiting || (statement->rsr_rows_pending > 0) fb_assert(statement->rsr_msgs_waiting || (statement->rsr_rows_pending > 0)
|| stmt_have_exception(statement) || statement->haveException()
|| statement->rsr_flags & (Rsr::EOF_SET)); || statement->rsr_flags & (Rsr::EOF_SET));
while (!stmt_have_exception(statement) /* received a database error */ while (!statement->haveException() /* received a database error */
&&!(statement->rsr_flags & (Rsr::EOF_SET)) /* reached end of cursor */ &&!(statement->rsr_flags & (Rsr::EOF_SET)) /* reached end of cursor */
&&!(statement->rsr_msgs_waiting >= 2) /* Have looked ahead for end of batch */ &&!(statement->rsr_msgs_waiting >= 2) /* Have looked ahead for end of batch */
&&!(statement->rsr_rows_pending == 0)) &&!(statement->rsr_rows_pending == 0))
@ -2308,7 +2308,7 @@ ISC_STATUS GDS_DSQL_SET_CURSOR(ISC_STATUS* user_status,
try try
{ {
stmt_raise_exception(statement); statement->raiseException();
/* make sure the protocol supports it */ /* make sure the protocol supports it */
@ -2361,7 +2361,7 @@ ISC_STATUS GDS_DSQL_SET_CURSOR(ISC_STATUS* user_status,
if (!receive_response(rdb, packet)) { if (!receive_response(rdb, packet)) {
return user_status[1]; return user_status[1];
} }
stmt_raise_exception(statement); statement->raiseException();
} }
catch (const Firebird::Exception& ex) catch (const Firebird::Exception& ex)
{ {
@ -2402,7 +2402,7 @@ ISC_STATUS GDS_DSQL_SQL_INFO(ISC_STATUS* user_status,
try try
{ {
stmt_raise_exception(statement); statement->raiseException();
/* make sure the protocol supports it */ /* make sure the protocol supports it */
@ -2413,7 +2413,7 @@ ISC_STATUS GDS_DSQL_SQL_INFO(ISC_STATUS* user_status,
status = info(user_status, rdb, op_info_sql, statement->rsr_id, 0, status = info(user_status, rdb, op_info_sql, statement->rsr_id, 0,
item_length, items, 0, 0, buffer_length, buffer); item_length, items, 0, 0, buffer_length, buffer);
stmt_raise_exception(statement); statement->raiseException();
} }
catch (const Firebird::Exception& ex) catch (const Firebird::Exception& ex)
{ {
@ -4791,13 +4791,13 @@ static bool clear_stmt_que(rem_port* port, ISC_STATUS* user_status, RSR statemen
return false; return false;
// We must receive isc_req_sync as we did fetch after EOF // We must receive isc_req_sync as we did fetch after EOF
fb_assert(stmt_have_exception(statement) == isc_req_sync); fb_assert(statement->haveException() == isc_req_sync);
} }
// hvlad: clear isc_req_sync error as it is received because of our batch // hvlad: clear isc_req_sync error as it is received because of our batch
// fetching code, not because of wrong client application // fetching code, not because of wrong client application
if (stmt_have_exception(statement) == isc_req_sync) { if (statement->haveException() == isc_req_sync) {
stmt_clear_exception(statement); statement->clearException();
} }
return true; return true;
@ -4913,7 +4913,7 @@ static bool batch_dsql_fetch(rem_port* port,
/* save the status vector in a safe place */ /* save the status vector in a safe place */
stmt_save_exception(statement, tmp_status, false); statement->saveException(tmp_status, false);
statement->rsr_rows_pending = 0; statement->rsr_rows_pending = 0;
--statement->rsr_batch_count; --statement->rsr_batch_count;
@ -6096,8 +6096,7 @@ static bool receive_packet_noqueue(rem_port* port,
if (!check_response(rdb, &p->packet)) if (!check_response(rdb, &p->packet))
{ {
// save error within the corresponding statement // save error within the corresponding statement
stmt_save_exception(statement, statement->saveException(p->packet.p_resp.p_resp_status_vector, false);
p->packet.p_resp.p_resp_status_vector, false);
} }
else else
{ {
@ -6149,7 +6148,7 @@ static bool receive_queued_packet(rem_port* port,
/* Grab first queue entry */ /* Grab first queue entry */
RMTQUE que_inst = port->port_receive_rmtque; rmtque* que_inst = port->port_receive_rmtque;
/* Receive the data */ /* Receive the data */
@ -6176,7 +6175,7 @@ static void enqueue_receive(rem_port* port,
* Functional description * Functional description
* *
**************************************/ **************************************/
RMTQUE que_inst = new rmtque; rmtque* const que_inst = new rmtque;
/* Prepare a queue entry */ /* Prepare a queue entry */
@ -6187,7 +6186,7 @@ static void enqueue_receive(rem_port* port,
que_inst->rmtque_rdb = rdb; que_inst->rmtque_rdb = rdb;
/* Walk to the end of the current queue */ /* Walk to the end of the current queue */
RMTQUE* queptr = &port->port_receive_rmtque; rmtque** queptr = &port->port_receive_rmtque;
while (*queptr) while (*queptr)
queptr = &(*queptr)->rmtque_next; queptr = &(*queptr)->rmtque_next;
@ -6211,7 +6210,7 @@ static void dequeue_receive( rem_port* port)
/* Grab first queue entry & de-queue it*/ /* Grab first queue entry & de-queue it*/
RMTQUE que_inst = port->port_receive_rmtque; rmtque* que_inst = port->port_receive_rmtque;
port->port_receive_rmtque = que_inst->rmtque_next; port->port_receive_rmtque = que_inst->rmtque_next;
que_inst->rmtque_next = NULL; que_inst->rmtque_next = NULL;
@ -6376,7 +6375,7 @@ static void release_statement( RSR* statement)
delete (*statement)->rsr_user_select_format; delete (*statement)->rsr_user_select_format;
} }
delete (*statement)->rsr_select_format; delete (*statement)->rsr_select_format;
stmt_release_exception(*statement); (*statement)->releaseException();
REMOTE_release_messages((*statement)->rsr_message); REMOTE_release_messages((*statement)->rsr_message);
delete *statement; delete *statement;

View File

@ -67,7 +67,7 @@ REM_MSG PARSE_messages(const UCHAR* blr, USHORT blr_length)
const USHORT msg_number = *blr++; const USHORT msg_number = *blr++;
USHORT count = *blr++; USHORT count = *blr++;
count += (*blr++) << 8; count += (*blr++) << 8;
rem_fmt* format = new rem_fmt(count); rem_fmt* const format = new rem_fmt(count);
#ifdef DEBUG_REMOTE_MEMORY #ifdef DEBUG_REMOTE_MEMORY
printf("PARSE_messages allocate format %x\n", format); printf("PARSE_messages allocate format %x\n", format);
#endif #endif

View File

@ -215,7 +215,7 @@ struct rem_fmt : public Firebird::GlobalStorage
Firebird::Array<dsc> fmt_desc; Firebird::Array<dsc> fmt_desc;
public: public:
rem_fmt(size_t rpt) : explicit rem_fmt(size_t rpt) :
fmt_length(0), fmt_net_length(0), fmt_count(0), fmt_length(0), fmt_net_length(0), fmt_count(0),
fmt_version(0), fmt_desc(getPool(), rpt) fmt_version(0), fmt_desc(getPool(), rpt)
{ {
@ -238,7 +238,7 @@ typedef struct Message : public Firebird::GlobalStorage
UCharArrayAutoPtr msg_buffer; /* Allocated message */ UCharArrayAutoPtr msg_buffer; /* Allocated message */
public: public:
Message(size_t rpt) : explicit Message(size_t rpt) :
msg_next(0), msg_next(0),
#ifdef SCROLLABLE_CURSORS #ifdef SCROLLABLE_CURSORS
msg_prior(0), msg_absolute(0), msg_prior(0), msg_absolute(0),
@ -310,7 +310,7 @@ public:
#endif #endif
public: public:
Rrq(size_t rpt) : explicit Rrq(size_t rpt) :
rrq_rdb(0), rrq_rtr(0), rrq_next(0), rrq_levels(0), rrq_rdb(0), rrq_rtr(0), rrq_next(0), rrq_levels(0),
rrq_handle(0), rrq_id(0), rrq_max_msg(0), rrq_level(0), rrq_handle(0), rrq_id(0), rrq_max_msg(0), rrq_level(0),
rrq_rpt(getPool(), rpt) rrq_rpt(getPool(), rpt)
@ -374,6 +374,12 @@ public:
rsr_rows_pending(0), rsr_msgs_waiting(0), rsr_reorder_level(0), rsr_batch_count(0) rsr_rows_pending(0), rsr_msgs_waiting(0), rsr_reorder_level(0), rsr_batch_count(0)
{ } { }
void saveException(const ISC_STATUS* status, bool overwrite);
void clearException();
ISC_STATUS haveException();
void raiseException();
void releaseException();
static ISC_STATUS badHandle() { return isc_bad_req_handle; } static ISC_STATUS badHandle() { return isc_bad_req_handle; }
} *RSR; } *RSR;
@ -391,6 +397,8 @@ private:
} ptr; } ptr;
public: public:
RemoteObject() { ptr.rdb = 0; }
template <typename R> template <typename R>
R* get(R* r) R* get(R* r)
{ {
@ -401,62 +409,55 @@ public:
return r; return r;
} }
public:
void operator=(Rdb* v) { ptr.rdb = v; } void operator=(Rdb* v) { ptr.rdb = v; }
void operator=(Rtr* v) { ptr.rtr = v; } void operator=(Rtr* v) { ptr.rtr = v; }
void operator=(Rbl* v) { ptr.rbl = v; } void operator=(Rbl* v) { ptr.rbl = v; }
void operator=(Rrq* v) { ptr.rrq = v; } void operator=(Rrq* v) { ptr.rrq = v; }
void operator=(Rsr* v) { ptr.rsr = v; } void operator=(Rsr* v) { ptr.rsr = v; }
public:
operator Rdb*() { return get(ptr.rdb); } operator Rdb*() { return get(ptr.rdb); }
operator Rtr*() { return get(ptr.rtr); } operator Rtr*() { return get(ptr.rtr); }
operator Rbl*() { return get(ptr.rbl); } operator Rbl*() { return get(ptr.rbl); }
operator Rrq*() { return get(ptr.rrq); } operator Rrq*() { return get(ptr.rrq); }
operator Rsr*() { return get(ptr.rsr); } operator Rsr*() { return get(ptr.rsr); }
bool isMissing() { return ptr.rdb == NULL; } bool isMissing() const { return ptr.rdb == NULL; }
void release() { ptr.rdb = 0; } void release() { ptr.rdb = 0; }
}; };
// will be methods of remote statement class inline void Rsr::saveException(const ISC_STATUS* status, bool overwrite)
inline void stmt_save_exception(RSR statement, const ISC_STATUS* status, bool overwrite)
{ {
if (!statement->rsr_status) { if (!rsr_status) {
statement->rsr_status = new Firebird::StatusHolder(); rsr_status = new Firebird::StatusHolder();
} }
if (overwrite || !statement->rsr_status->getError()) { if (overwrite || !rsr_status->getError()) {
statement->rsr_status->save(status); rsr_status->save(status);
} }
} }
inline void stmt_clear_exception(RSR statement) inline void Rsr::clearException()
{ {
if (statement->rsr_status) if (rsr_status)
statement->rsr_status->clear(); rsr_status->clear();
} }
inline ISC_STATUS stmt_have_exception(RSR statement) inline ISC_STATUS Rsr::haveException()
{ {
return (statement->rsr_status ? return (rsr_status ? rsr_status->getError() : 0);
statement->rsr_status->getError() : 0);
} }
inline void stmt_raise_exception(RSR statement) inline void Rsr::raiseException()
{ {
if (statement->rsr_status) if (rsr_status)
statement->rsr_status->raise(); rsr_status->raise();
} }
inline void stmt_release_exception(RSR statement) inline void Rsr::releaseException()
{ {
if (statement->rsr_status) delete rsr_status;
{ rsr_status = NULL;
delete statement->rsr_status;
statement->rsr_status = NULL;
}
} }
#include "../remote/xdr.h" #include "../remote/xdr.h"
@ -503,7 +504,7 @@ public:
// port_flags // port_flags
const USHORT PORT_symmetric = 0x0001; // Server/client archiectures are symmetic const USHORT PORT_symmetric = 0x0001; // Server/client architectures are symmetic
const USHORT PORT_rpc = 0x0002; // Protocol is remote procedure call const USHORT PORT_rpc = 0x0002; // Protocol is remote procedure call
const USHORT PORT_async = 0x0004; // Port is asynchronous channel for events const USHORT PORT_async = 0x0004; // Port is asynchronous channel for events
const USHORT PORT_no_oob = 0x0008; // Don't send out of band data const USHORT PORT_no_oob = 0x0008; // Don't send out of band data
@ -849,7 +850,7 @@ public:
typedef bool (*t_rmtque_fn)(rem_port*, rmtque*, ISC_STATUS*, USHORT); typedef bool (*t_rmtque_fn)(rem_port*, rmtque*, ISC_STATUS*, USHORT);
typedef struct rmtque : public Firebird::GlobalStorage struct rmtque : public Firebird::GlobalStorage
{ {
rmtque* rmtque_next; // Next entry in queue rmtque* rmtque_next; // Next entry in queue
void* rmtque_parm; // What request has response in queue void* rmtque_parm; // What request has response in queue
@ -863,6 +864,6 @@ public:
rmtque() : rmtque() :
rmtque_next(0), rmtque_parm(0), rmtque_message(0), rmtque_rdb(0), rmtque_function(0) rmtque_next(0), rmtque_parm(0), rmtque_message(0), rmtque_rdb(0), rmtque_function(0)
{ } { }
} *RMTQUE; };
#endif // REMOTE_REMOTE_H #endif // REMOTE_REMOTE_H

View File

@ -84,7 +84,7 @@ typedef struct srvr : public Firebird::GlobalStorage
USHORT srvr_flags; USHORT srvr_flags;
public: public:
srvr(srvr *servers, rem_port* port, USHORT flags) : srvr(srvr* servers, rem_port* port, USHORT flags) :
srvr_next(servers), srvr_parent_port(port), srvr_next(servers), srvr_parent_port(port),
srvr_port_type(port->port_type), srvr_flags(flags) srvr_port_type(port->port_type), srvr_flags(flags)
{ } { }
@ -2165,7 +2165,7 @@ ISC_STATUS rem_port::fetch(P_SQLDATA * sqldata, PACKET* sendL)
if (!(statement->rsr_flags & Rsr::FETCHED)) { if (!(statement->rsr_flags & Rsr::FETCHED)) {
statement->rsr_flags &= ~(Rsr::EOF_SET | Rsr::STREAM_ERR); statement->rsr_flags &= ~(Rsr::EOF_SET | Rsr::STREAM_ERR);
stmt_clear_exception(statement); statement->clearException();
REM_MSG message = statement->rsr_message; REM_MSG message = statement->rsr_message;
if (message != NULL) { if (message != NULL) {
statement->rsr_buffer = message; statement->rsr_buffer = message;
@ -2323,7 +2323,7 @@ ISC_STATUS rem_port::fetch(P_SQLDATA * sqldata, PACKET* sendL)
/* If already have an error queued, don't overwrite it */ /* If already have an error queued, don't overwrite it */
if (!(statement->rsr_flags & Rsr::STREAM_ERR)) { if (!(statement->rsr_flags & Rsr::STREAM_ERR)) {
statement->rsr_flags |= Rsr::STREAM_ERR; statement->rsr_flags |= Rsr::STREAM_ERR;
stmt_save_exception(statement, status_vector, true); statement->saveException(status_vector, true);
} }
} }
if (s == 100) if (s == 100)
@ -4010,7 +4010,7 @@ static void release_statement( RSR * statement)
delete (*statement)->rsr_select_format; delete (*statement)->rsr_select_format;
delete (*statement)->rsr_bind_format; delete (*statement)->rsr_bind_format;
stmt_release_exception(*statement); (*statement)->releaseException();
REMOTE_release_messages((*statement)->rsr_message); REMOTE_release_messages((*statement)->rsr_message);
delete *statement; delete *statement;