added the mio_svc_marc_dev_error_t type

This commit is contained in:
hyung-hwan 2020-06-21 15:30:44 +00:00
parent 31d92b9292
commit dce9353bc8
3 changed files with 29 additions and 15 deletions

View File

@ -138,8 +138,11 @@ printf ("[%lu] NO DATA..\n", sid);
break; break;
case MIO_SVC_MARC_RCODE_ERROR: case MIO_SVC_MARC_RCODE_ERROR:
printf ("QUERY ERROR - %s\n", data); /* TODO: how to get both error code and error message? */ {
mio_svc_marc_dev_error_t* err = (mio_svc_marc_dev_error_t*)data;
printf ("QUERY ERROR - [%d] %s\n", err->mar_errcode, err->mar_errmsg);
break; break;
}
} }
} }

View File

@ -219,13 +219,16 @@ static void mar_on_query_started (mio_dev_mar_t* dev, int mar_ret, const mio_bch
if (mar_ret) if (mar_ret)
{ {
mio_svc_marc_dev_error_t err;
printf ("QUERY FAILED...%d -> %s\n", mar_ret, mar_errmsg); printf ("QUERY FAILED...%d -> %s\n", mar_ret, mar_errmsg);
#if 0 #if 0
if (mar_ret == CR_SERVER_GONE_ERROR || /* server gone away between queries */ if (mar_ret == CR_SERVER_GONE_ERROR || /* server gone away between queries */
mar_ret == CR_SERVER_LOST) /* server gone away during a query */ mar_ret == CR_SERVER_LOST) /* server gone away during a query */
#endif #endif
sq->on_result(sess->svc, sess->sid, MIO_SVC_MARC_RCODE_ERROR, mysql_error(dev->hnd), sq->qctx); err.mar_errcode = mar_ret;
err.mar_errmsg = mar_errmsg;
sq->on_result(sess->svc, sess->sid, MIO_SVC_MARC_RCODE_ERROR, &err, sq->qctx);
dequeue_session_query (sess->svc->mio, sess); dequeue_session_query (sess->svc->mio, sess);
send_pending_query_if_any (sess); send_pending_query_if_any (sess);

View File

@ -50,11 +50,11 @@ enum mio_dev_mar_state_t
/* convenience bit masks */ /* convenience bit masks */
MIO_DEV_MAR_ALL_PROGRESS_BITS = (MIO_DEV_MAR_CONNECTING | MIO_DEV_MAR_ALL_PROGRESS_BITS = (MIO_DEV_MAR_CONNECTING |
MIO_DEV_MAR_CONNECTED | MIO_DEV_MAR_CONNECTED |
MIO_DEV_MAR_QUERY_STARTING | MIO_DEV_MAR_QUERY_STARTING |
MIO_DEV_MAR_QUERY_STARTED | MIO_DEV_MAR_QUERY_STARTED |
MIO_DEV_MAR_ROW_FETCHING | MIO_DEV_MAR_ROW_FETCHING |
MIO_DEV_MAR_ROW_FETCHED) MIO_DEV_MAR_ROW_FETCHED)
}; };
typedef enum mio_dev_mar_state_t mio_dev_mar_state_t; typedef enum mio_dev_mar_state_t mio_dev_mar_state_t;
@ -168,10 +168,18 @@ enum mio_svc_marc_rcode_t
{ {
MIO_SVC_MARC_RCODE_ROW, /* has row *- data is MYSQL_ROW */ MIO_SVC_MARC_RCODE_ROW, /* has row *- data is MYSQL_ROW */
MIO_SVC_MARC_RCODE_DONE, /* completed or no more row - data is NULL */ MIO_SVC_MARC_RCODE_DONE, /* completed or no more row - data is NULL */
MIO_SVC_MARC_RCODE_ERROR /* query error - data is a numeric database error code cast to void* */ MIO_SVC_MARC_RCODE_ERROR /* query error - data is mio_sv_marc_dev_error_t* */
}; };
typedef enum mio_svc_marc_rcode_t mio_svc_marc_rcode_t; typedef enum mio_svc_marc_rcode_t mio_svc_marc_rcode_t;
struct mio_svc_marc_dev_error_t
{
int mar_errcode;
const mio_bch_t* mar_errmsg;
};
typedef struct mio_svc_marc_dev_error_t mio_svc_marc_dev_error_t;
typedef void (*mio_svc_marc_on_result_t) ( typedef void (*mio_svc_marc_on_result_t) (
mio_svc_marc_t* marc, mio_svc_marc_t* marc,
mio_oow_t sid, mio_oow_t sid,
@ -250,13 +258,13 @@ static MIO_INLINE mio_t* mio_svc_marc_getmio(mio_svc_marc_t* svc) { return mio_s
MIO_EXPORT int mio_svc_mar_querywithbchars ( MIO_EXPORT int mio_svc_mar_querywithbchars (
mio_svc_marc_t* marc, mio_svc_marc_t* marc,
mio_oow_t sid, mio_oow_t sid,
mio_svc_marc_qtype_t qtype, mio_svc_marc_qtype_t qtype,
const mio_bch_t* qptr, const mio_bch_t* qptr,
mio_oow_t qlen, mio_oow_t qlen,
mio_svc_marc_on_result_t on_result, mio_svc_marc_on_result_t on_result,
void* qctx void* qctx
); );
#ifdef __cplusplus #ifdef __cplusplus