mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
MNDR:
- Remove the SET_STMT_ERROR macro
This commit is contained in:
parent
4bb784cd0d
commit
3eee292669
2 changed files with 25 additions and 67 deletions
|
@ -104,54 +104,12 @@ void mysqlnd_upsert_status_init(MYSQLND_UPSERT_STATUS * const upsert_status);
|
|||
(buf_len) = 0; \
|
||||
}
|
||||
|
||||
|
||||
enum_func_status mysqlnd_error_info_init(MYSQLND_ERROR_INFO * const info, zend_bool persistent);
|
||||
|
||||
|
||||
#define SET_OOM_ERROR(info) SET_CLIENT_ERROR((info), CR_OUT_OF_MEMORY, UNKNOWN_SQLSTATE, mysqlnd_out_of_memory)
|
||||
#define SET_EMPTY_ERROR(info) (info)->m->reset((info))
|
||||
#define SET_CLIENT_ERROR(info, err_no, sqlstate, error) (info)->m->set_client_error((info), (err_no), (sqlstate), (error))
|
||||
#define COPY_CLIENT_ERROR(error_info_to, error_info_from) \
|
||||
{ \
|
||||
SET_CLIENT_ERROR((error_info_to), (error_info_from).error_no, (error_info_from).sqlstate, (error_info_from).error); \
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
#define SET_EMPTY_ERROR(error_info) \
|
||||
{ \
|
||||
(error_info).error_no = 0; \
|
||||
(error_info).error[0] = '\0'; \
|
||||
strlcpy((error_info).sqlstate, "00000", sizeof((error_info).sqlstate)); \
|
||||
if ((error_info).error_list) { \
|
||||
zend_llist_clean((error_info).error_list); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define SET_CLIENT_ERROR(error_info, a, b, c) \
|
||||
{ \
|
||||
if (0 == (a)) { \
|
||||
SET_EMPTY_ERROR((error_info)); \
|
||||
} else { \
|
||||
(error_info).error_no = (a); \
|
||||
strlcpy((error_info).sqlstate, (b), sizeof((error_info).sqlstate)); \
|
||||
strlcpy((error_info).error, (c), sizeof((error_info).error)); \
|
||||
if ((error_info).error_list) {\
|
||||
MYSQLND_ERROR_LIST_ELEMENT error_for_the_list = {0}; \
|
||||
\
|
||||
error_for_the_list.error_no = (a); \
|
||||
strlcpy(error_for_the_list.sqlstate, (b), sizeof(error_for_the_list.sqlstate)); \
|
||||
error_for_the_list.error = mnd_pestrdup((c), TRUE); \
|
||||
if (error_for_the_list.error) { \
|
||||
DBG_INF_FMT("adding error [%s] to the list", error_for_the_list.error); \
|
||||
zend_llist_add_element((error_info).error_list, &error_for_the_list); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#define SET_STMT_ERROR(stmt, a, b, c) SET_CLIENT_ERROR((stmt)->error_info, a, b, c)
|
||||
#define SET_CLIENT_ERROR(info, err_no, sqlstate, error) (err_no)? (info)->m->set_client_error((info), (err_no), (sqlstate), (error)) : (info)->m->reset((info))
|
||||
#define SET_OOM_ERROR(info) SET_CLIENT_ERROR((info), CR_OUT_OF_MEMORY, UNKNOWN_SQLSTATE, mysqlnd_out_of_memory)
|
||||
#define COPY_CLIENT_ERROR(dest, source) SET_CLIENT_ERROR((dest), (source).error_no, (source).sqlstate, (source).error)
|
||||
|
||||
#define CONN_GET_STATE(c) (c)->m->get_state((c))
|
||||
#define CONN_SET_STATE(c, s) (c)->m->set_state((c), (s))
|
||||
|
|
|
@ -706,7 +706,7 @@ MYSQLND_METHOD(mysqlnd_stmt, send_execute)(MYSQLND_STMT * const s, enum_mysqlnd_
|
|||
/* Only initted - error */
|
||||
SET_CLIENT_ERROR(conn->error_info, CR_COMMANDS_OUT_OF_SYNC, UNKNOWN_SQLSTATE,
|
||||
mysqlnd_out_of_sync);
|
||||
SET_STMT_ERROR(stmt, CR_COMMANDS_OUT_OF_SYNC, UNKNOWN_SQLSTATE, mysqlnd_out_of_sync);
|
||||
SET_CLIENT_ERROR(stmt->error_info, CR_COMMANDS_OUT_OF_SYNC, UNKNOWN_SQLSTATE, mysqlnd_out_of_sync);
|
||||
DBG_INF("FAIL");
|
||||
DBG_RETURN(FAIL);
|
||||
}
|
||||
|
@ -714,7 +714,7 @@ MYSQLND_METHOD(mysqlnd_stmt, send_execute)(MYSQLND_STMT * const s, enum_mysqlnd_
|
|||
if (stmt->param_count) {
|
||||
unsigned int i, not_bound = 0;
|
||||
if (!stmt->param_bind) {
|
||||
SET_STMT_ERROR(stmt, CR_PARAMS_NOT_BOUND, UNKNOWN_SQLSTATE,
|
||||
SET_CLIENT_ERROR(stmt->error_info, CR_PARAMS_NOT_BOUND, UNKNOWN_SQLSTATE,
|
||||
"No data supplied for parameters in prepared statement");
|
||||
DBG_INF("FAIL");
|
||||
DBG_RETURN(FAIL);
|
||||
|
@ -728,7 +728,7 @@ MYSQLND_METHOD(mysqlnd_stmt, send_execute)(MYSQLND_STMT * const s, enum_mysqlnd_
|
|||
char * msg;
|
||||
mnd_sprintf(&msg, 0, "No data supplied for %u parameter%s in prepared statement",
|
||||
not_bound, not_bound>1 ?"s":"");
|
||||
SET_STMT_ERROR(stmt, CR_PARAMS_NOT_BOUND, UNKNOWN_SQLSTATE, msg);
|
||||
SET_CLIENT_ERROR(stmt->error_info, CR_PARAMS_NOT_BOUND, UNKNOWN_SQLSTATE, msg);
|
||||
if (msg) {
|
||||
mnd_sprintf_free(msg);
|
||||
}
|
||||
|
@ -746,7 +746,7 @@ MYSQLND_METHOD(mysqlnd_stmt, send_execute)(MYSQLND_STMT * const s, enum_mysqlnd_
|
|||
command->free_command(command);
|
||||
}
|
||||
} else {
|
||||
SET_STMT_ERROR(stmt, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, "Couldn't generate the request. Possibly OOM.");
|
||||
SET_CLIENT_ERROR(stmt->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, "Couldn't generate the request. Possibly OOM.");
|
||||
}
|
||||
|
||||
if (free_request) {
|
||||
|
@ -1217,7 +1217,7 @@ MYSQLND_METHOD(mysqlnd_stmt, fetch)(MYSQLND_STMT * const s, zend_bool * const fe
|
|||
|
||||
if (!stmt->result ||
|
||||
stmt->state < MYSQLND_STMT_WAITING_USE_OR_STORE) {
|
||||
SET_STMT_ERROR(stmt, CR_COMMANDS_OUT_OF_SYNC, UNKNOWN_SQLSTATE, mysqlnd_out_of_sync);
|
||||
SET_CLIENT_ERROR(stmt->error_info, CR_COMMANDS_OUT_OF_SYNC, UNKNOWN_SQLSTATE, mysqlnd_out_of_sync);
|
||||
|
||||
DBG_ERR("command out of sync");
|
||||
DBG_RETURN(FAIL);
|
||||
|
@ -1379,22 +1379,22 @@ MYSQLND_METHOD(mysqlnd_stmt, send_long_data)(MYSQLND_STMT * const s, unsigned in
|
|||
SET_EMPTY_ERROR(stmt->conn->error_info);
|
||||
|
||||
if (stmt->state < MYSQLND_STMT_PREPARED) {
|
||||
SET_STMT_ERROR(stmt, CR_NO_PREPARE_STMT, UNKNOWN_SQLSTATE, mysqlnd_stmt_not_prepared);
|
||||
SET_CLIENT_ERROR(stmt->error_info, CR_NO_PREPARE_STMT, UNKNOWN_SQLSTATE, mysqlnd_stmt_not_prepared);
|
||||
DBG_ERR("not prepared");
|
||||
DBG_RETURN(FAIL);
|
||||
}
|
||||
if (!stmt->param_bind) {
|
||||
SET_STMT_ERROR(stmt, CR_COMMANDS_OUT_OF_SYNC, UNKNOWN_SQLSTATE, mysqlnd_out_of_sync);
|
||||
SET_CLIENT_ERROR(stmt->error_info, CR_COMMANDS_OUT_OF_SYNC, UNKNOWN_SQLSTATE, mysqlnd_out_of_sync);
|
||||
DBG_ERR("command out of sync");
|
||||
DBG_RETURN(FAIL);
|
||||
}
|
||||
if (param_no >= stmt->param_count) {
|
||||
SET_STMT_ERROR(stmt, CR_INVALID_PARAMETER_NO, UNKNOWN_SQLSTATE, "Invalid parameter number");
|
||||
SET_CLIENT_ERROR(stmt->error_info, CR_INVALID_PARAMETER_NO, UNKNOWN_SQLSTATE, "Invalid parameter number");
|
||||
DBG_ERR("invalid param_no");
|
||||
DBG_RETURN(FAIL);
|
||||
}
|
||||
if (stmt->param_bind[param_no].type != MYSQL_TYPE_LONG_BLOB) {
|
||||
SET_STMT_ERROR(stmt, CR_INVALID_BUFFER_USE, UNKNOWN_SQLSTATE, mysqlnd_not_bound_as_blob);
|
||||
SET_CLIENT_ERROR(stmt->error_info, CR_INVALID_BUFFER_USE, UNKNOWN_SQLSTATE, mysqlnd_not_bound_as_blob);
|
||||
DBG_ERR("param_no is not of a blob type");
|
||||
DBG_RETURN(FAIL);
|
||||
}
|
||||
|
@ -1464,7 +1464,7 @@ MYSQLND_METHOD(mysqlnd_stmt, send_long_data)(MYSQLND_STMT * const s, unsigned in
|
|||
"while sending long data. Probably max_allowed_packet_size "
|
||||
"is smaller than the data. You have to increase it or send "
|
||||
"smaller chunks of data. Answer was "MYSQLND_SZ_T_SPEC" bytes long.", packet_len);
|
||||
SET_STMT_ERROR(stmt, CR_CONNECTION_ERROR, UNKNOWN_SQLSTATE,
|
||||
SET_CLIENT_ERROR(stmt->error_info, CR_CONNECTION_ERROR, UNKNOWN_SQLSTATE,
|
||||
"Server responded to COM_STMT_SEND_LONG_DATA.");
|
||||
ret = FAIL;
|
||||
}
|
||||
|
@ -1489,7 +1489,7 @@ MYSQLND_METHOD(mysqlnd_stmt, bind_parameters)(MYSQLND_STMT * const s, MYSQLND_PA
|
|||
DBG_INF_FMT("stmt=%lu param_count=%u", stmt->stmt_id, stmt->param_count);
|
||||
|
||||
if (stmt->state < MYSQLND_STMT_PREPARED) {
|
||||
SET_STMT_ERROR(stmt, CR_NO_PREPARE_STMT, UNKNOWN_SQLSTATE, mysqlnd_stmt_not_prepared);
|
||||
SET_CLIENT_ERROR(stmt->error_info, CR_NO_PREPARE_STMT, UNKNOWN_SQLSTATE, mysqlnd_stmt_not_prepared);
|
||||
DBG_ERR("not prepared");
|
||||
if (param_bind) {
|
||||
s->m->free_parameter_bind(s, param_bind);
|
||||
|
@ -1504,7 +1504,7 @@ MYSQLND_METHOD(mysqlnd_stmt, bind_parameters)(MYSQLND_STMT * const s, MYSQLND_PA
|
|||
unsigned int i = 0;
|
||||
|
||||
if (!param_bind) {
|
||||
SET_STMT_ERROR(stmt, CR_COMMANDS_OUT_OF_SYNC, UNKNOWN_SQLSTATE, "Re-binding (still) not supported");
|
||||
SET_CLIENT_ERROR(stmt->error_info, CR_COMMANDS_OUT_OF_SYNC, UNKNOWN_SQLSTATE, "Re-binding (still) not supported");
|
||||
DBG_ERR("Re-binding (still) not supported");
|
||||
DBG_RETURN(FAIL);
|
||||
} else if (stmt->param_bind) {
|
||||
|
@ -1558,13 +1558,13 @@ MYSQLND_METHOD(mysqlnd_stmt, bind_one_parameter)(MYSQLND_STMT * const s, unsigne
|
|||
DBG_INF_FMT("stmt=%lu param_no=%u param_count=%u type=%u", stmt->stmt_id, param_no, stmt->param_count, type);
|
||||
|
||||
if (stmt->state < MYSQLND_STMT_PREPARED) {
|
||||
SET_STMT_ERROR(stmt, CR_NO_PREPARE_STMT, UNKNOWN_SQLSTATE, mysqlnd_stmt_not_prepared);
|
||||
SET_CLIENT_ERROR(stmt->error_info, CR_NO_PREPARE_STMT, UNKNOWN_SQLSTATE, mysqlnd_stmt_not_prepared);
|
||||
DBG_ERR("not prepared");
|
||||
DBG_RETURN(FAIL);
|
||||
}
|
||||
|
||||
if (param_no >= stmt->param_count) {
|
||||
SET_STMT_ERROR(stmt, CR_INVALID_PARAMETER_NO, UNKNOWN_SQLSTATE, "Invalid parameter number");
|
||||
SET_CLIENT_ERROR(stmt->error_info, CR_INVALID_PARAMETER_NO, UNKNOWN_SQLSTATE, "Invalid parameter number");
|
||||
DBG_ERR("invalid param_no");
|
||||
DBG_RETURN(FAIL);
|
||||
}
|
||||
|
@ -1612,7 +1612,7 @@ MYSQLND_METHOD(mysqlnd_stmt, refresh_bind_param)(MYSQLND_STMT * const s)
|
|||
DBG_INF_FMT("stmt=%lu param_count=%u", stmt->stmt_id, stmt->param_count);
|
||||
|
||||
if (stmt->state < MYSQLND_STMT_PREPARED) {
|
||||
SET_STMT_ERROR(stmt, CR_NO_PREPARE_STMT, UNKNOWN_SQLSTATE, mysqlnd_stmt_not_prepared);
|
||||
SET_CLIENT_ERROR(stmt->error_info, CR_NO_PREPARE_STMT, UNKNOWN_SQLSTATE, mysqlnd_stmt_not_prepared);
|
||||
DBG_ERR("not prepared");
|
||||
DBG_RETURN(FAIL);
|
||||
}
|
||||
|
@ -1641,7 +1641,7 @@ MYSQLND_METHOD(mysqlnd_stmt, bind_result)(MYSQLND_STMT * const s,
|
|||
DBG_INF_FMT("stmt=%lu field_count=%u", stmt->stmt_id, stmt->field_count);
|
||||
|
||||
if (stmt->state < MYSQLND_STMT_PREPARED) {
|
||||
SET_STMT_ERROR(stmt, CR_NO_PREPARE_STMT, UNKNOWN_SQLSTATE, mysqlnd_stmt_not_prepared);
|
||||
SET_CLIENT_ERROR(stmt->error_info, CR_NO_PREPARE_STMT, UNKNOWN_SQLSTATE, mysqlnd_stmt_not_prepared);
|
||||
if (result_bind) {
|
||||
s->m->free_result_bind(s, result_bind);
|
||||
}
|
||||
|
@ -1697,13 +1697,13 @@ MYSQLND_METHOD(mysqlnd_stmt, bind_one_result)(MYSQLND_STMT * const s, unsigned i
|
|||
DBG_INF_FMT("stmt=%lu field_count=%u", stmt->stmt_id, stmt->field_count);
|
||||
|
||||
if (stmt->state < MYSQLND_STMT_PREPARED) {
|
||||
SET_STMT_ERROR(stmt, CR_NO_PREPARE_STMT, UNKNOWN_SQLSTATE, mysqlnd_stmt_not_prepared);
|
||||
SET_CLIENT_ERROR(stmt->error_info, CR_NO_PREPARE_STMT, UNKNOWN_SQLSTATE, mysqlnd_stmt_not_prepared);
|
||||
DBG_ERR("not prepared");
|
||||
DBG_RETURN(FAIL);
|
||||
}
|
||||
|
||||
if (param_no >= stmt->field_count) {
|
||||
SET_STMT_ERROR(stmt, CR_INVALID_PARAMETER_NO, UNKNOWN_SQLSTATE, "Invalid parameter number");
|
||||
SET_CLIENT_ERROR(stmt->error_info, CR_INVALID_PARAMETER_NO, UNKNOWN_SQLSTATE, "Invalid parameter number");
|
||||
DBG_ERR("invalid param_no");
|
||||
DBG_RETURN(FAIL);
|
||||
}
|
||||
|
@ -1946,7 +1946,7 @@ MYSQLND_METHOD(mysqlnd_stmt, attr_set)(MYSQLND_STMT * const s,
|
|||
case STMT_ATTR_CURSOR_TYPE: {
|
||||
unsigned int ival = *(unsigned int *) value;
|
||||
if (ival > (zend_ulong) CURSOR_TYPE_READ_ONLY) {
|
||||
SET_STMT_ERROR(stmt, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, "Not implemented");
|
||||
SET_CLIENT_ERROR(stmt->error_info, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, "Not implemented");
|
||||
DBG_INF("FAIL");
|
||||
DBG_RETURN(FAIL);
|
||||
}
|
||||
|
@ -1958,7 +1958,7 @@ MYSQLND_METHOD(mysqlnd_stmt, attr_set)(MYSQLND_STMT * const s,
|
|||
if (ival == 0) {
|
||||
ival = MYSQLND_DEFAULT_PREFETCH_ROWS;
|
||||
} else if (ival > 1) {
|
||||
SET_STMT_ERROR(stmt, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, "Not implemented");
|
||||
SET_CLIENT_ERROR(stmt->error_info, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, "Not implemented");
|
||||
DBG_INF("FAIL");
|
||||
DBG_RETURN(FAIL);
|
||||
}
|
||||
|
@ -1966,7 +1966,7 @@ MYSQLND_METHOD(mysqlnd_stmt, attr_set)(MYSQLND_STMT * const s,
|
|||
break;
|
||||
}
|
||||
default:
|
||||
SET_STMT_ERROR(stmt, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, "Not implemented");
|
||||
SET_CLIENT_ERROR(stmt->error_info, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, "Not implemented");
|
||||
DBG_RETURN(FAIL);
|
||||
}
|
||||
DBG_INF("PASS");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue