enum_func_status mysqlnd_stmt_execute_batch_generate_request(MYSQLND_STMT * const s, zend_uchar ** request, size_t *request_len, zend_bool * free_buffer);
static void mysqlnd_stmt_separate_result_bind(MYSQLND_STMT * const stmt);
-static void mysqlnd_stmt_separate_one_result_bind(MYSQLND_STMT * const stmt, unsigned int param_no);
+static void mysqlnd_stmt_separate_one_result_bind(MYSQLND_STMT * const stmt, const unsigned int param_no);
/* {{{ mysqlnd_stmt::store_result */
static MYSQLND_RES *
MYSQLND_METHOD(mysqlnd_stmt, store_result)(MYSQLND_STMT * const s)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
enum_func_status ret;
- MYSQLND_CONN_DATA * conn;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
+ MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL;
MYSQLND_RES * result;
DBG_ENTER("mysqlnd_stmt::store_result");
- if (!stmt || !stmt->conn || !stmt->result) {
+ if (!stmt || !conn || !stmt->result) {
DBG_RETURN(NULL);
}
DBG_INF_FMT("stmt=%lu", stmt->stmt_id);
- conn = stmt->conn;
-
/* be compliant with libmysql - NULL will turn */
if (!stmt->field_count) {
DBG_RETURN(NULL);
}
/* Nothing to store for UPSERT/LOAD DATA*/
- if (GET_CONNECTION_STATE(&conn->state) != CONN_FETCHING_DATA ||
- stmt->state != MYSQLND_STMT_WAITING_USE_OR_STORE)
+ if (GET_CONNECTION_STATE(&conn->state) != CONN_FETCHING_DATA || stmt->state != MYSQLND_STMT_WAITING_USE_OR_STORE)
{
- SET_CLIENT_ERROR(conn->error_info, CR_COMMANDS_OUT_OF_SYNC,
- UNKNOWN_SQLSTATE, mysqlnd_out_of_sync);
+ SET_CLIENT_ERROR(conn->error_info, CR_COMMANDS_OUT_OF_SYNC, UNKNOWN_SQLSTATE, mysqlnd_out_of_sync);
DBG_RETURN(NULL);
}
static MYSQLND_RES *
MYSQLND_METHOD(mysqlnd_stmt, get_result)(MYSQLND_STMT * const s)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
- MYSQLND_CONN_DATA * conn;
- MYSQLND_RES *result;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
+ MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL;
+ MYSQLND_RES * result;
DBG_ENTER("mysqlnd_stmt::get_result");
- if (!stmt || !stmt->conn || !stmt->result) {
+ if (!stmt || !conn || !stmt->result) {
DBG_RETURN(NULL);
}
DBG_INF_FMT("stmt=%lu", stmt->stmt_id);
- conn = stmt->conn;
-
/* be compliant with libmysql - NULL will turn */
if (!stmt->field_count) {
DBG_RETURN(NULL);
static zend_bool
MYSQLND_METHOD(mysqlnd_stmt, more_results)(const MYSQLND_STMT * s)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
+ MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL;
DBG_ENTER("mysqlnd_stmt::more_results");
/* (conn->state == CONN_NEXT_RESULT_PENDING) too */
- DBG_RETURN((stmt && stmt->conn && (stmt->conn->m->get_server_status(stmt->conn) & SERVER_MORE_RESULTS_EXISTS))?
- TRUE:
- FALSE);
+ DBG_RETURN((stmt && conn && (conn->m->get_server_status(conn) & SERVER_MORE_RESULTS_EXISTS))? TRUE: FALSE);
}
/* }}} */
static enum_func_status
MYSQLND_METHOD(mysqlnd_stmt, next_result)(MYSQLND_STMT * s)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
- MYSQLND_CONN_DATA * conn;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
+ MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL;
DBG_ENTER("mysqlnd_stmt::next_result");
- if (!stmt || !stmt->conn || !stmt->result) {
+ if (!stmt || !conn || !stmt->result) {
DBG_RETURN(FAIL);
}
- conn = stmt->conn;
DBG_INF_FMT("stmt=%lu", stmt->stmt_id);
if (GET_CONNECTION_STATE(&conn->state) != CONN_NEXT_RESULT_PENDING || !(UPSERT_STATUS_GET_SERVER_STATUS(conn->upsert_status) & SERVER_MORE_RESULTS_EXISTS)) {
static enum_func_status
mysqlnd_stmt_skip_metadata(MYSQLND_STMT * s)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
+ MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL;
/* Follows parameter metadata, we have just to skip it, as libmysql does */
unsigned int i = 0;
enum_func_status ret = FAIL;
MYSQLND_PACKET_RES_FIELD * field_packet;
DBG_ENTER("mysqlnd_stmt_skip_metadata");
- if (!stmt) {
+ if (!stmt || !conn) {
DBG_RETURN(FAIL);
}
DBG_INF_FMT("stmt=%lu", stmt->stmt_id);
- field_packet = stmt->conn->payload_decoder_factory->m.get_result_field_packet(stmt->conn->payload_decoder_factory, FALSE);
+ field_packet = conn->payload_decoder_factory->m.get_result_field_packet(conn->payload_decoder_factory, FALSE);
if (!field_packet) {
SET_OOM_ERROR(stmt->error_info);
- SET_OOM_ERROR(stmt->conn->error_info);
+ SET_OOM_ERROR(conn->error_info);
} else {
ret = PASS;
field_packet->skip_parsing = TRUE;
static enum_func_status
mysqlnd_stmt_read_prepare_response(MYSQLND_STMT * s)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
+ MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL;
MYSQLND_PACKET_PREPARE_RESPONSE * prepare_resp;
enum_func_status ret = FAIL;
DBG_ENTER("mysqlnd_stmt_read_prepare_response");
- if (!stmt) {
+ if (!stmt || !conn) {
DBG_RETURN(FAIL);
}
DBG_INF_FMT("stmt=%lu", stmt->stmt_id);
- prepare_resp = stmt->conn->payload_decoder_factory->m.get_prepare_response_packet(stmt->conn->payload_decoder_factory, FALSE);
+ prepare_resp = conn->payload_decoder_factory->m.get_prepare_response_packet(conn->payload_decoder_factory, FALSE);
if (!prepare_resp) {
SET_OOM_ERROR(stmt->error_info);
- SET_OOM_ERROR(stmt->conn->error_info);
+ SET_OOM_ERROR(conn->error_info);
goto done;
}
if (0xFF == prepare_resp->error_code) {
COPY_CLIENT_ERROR(stmt->error_info, prepare_resp->error_info);
- COPY_CLIENT_ERROR(stmt->conn->error_info, prepare_resp->error_info);
+ COPY_CLIENT_ERROR(conn->error_info, prepare_resp->error_info);
goto done;
}
ret = PASS;
stmt->stmt_id = prepare_resp->stmt_id;
- UPSERT_STATUS_SET_WARNINGS(stmt->conn->upsert_status, prepare_resp->warning_count);
+ UPSERT_STATUS_SET_WARNINGS(conn->upsert_status, prepare_resp->warning_count);
UPSERT_STATUS_SET_AFFECTED_ROWS(stmt->upsert_status, 0); /* be like libmysql */
- stmt->field_count = stmt->conn->field_count = prepare_resp->field_count;
+ stmt->field_count = conn->field_count = prepare_resp->field_count;
stmt->param_count = prepare_resp->param_count;
done:
PACKET_FREE(prepare_resp);
static enum_func_status
mysqlnd_stmt_prepare_read_eof(MYSQLND_STMT * s)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
+ MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL;
MYSQLND_PACKET_EOF * fields_eof;
enum_func_status ret = FAIL;
DBG_ENTER("mysqlnd_stmt_prepare_read_eof");
- if (!stmt) {
+ if (!stmt || !conn) {
DBG_RETURN(FAIL);
}
DBG_INF_FMT("stmt=%lu", stmt->stmt_id);
- fields_eof = stmt->conn->payload_decoder_factory->m.get_eof_packet(stmt->conn->payload_decoder_factory, FALSE);
+ fields_eof = conn->payload_decoder_factory->m.get_eof_packet(conn->payload_decoder_factory, FALSE);
if (!fields_eof) {
SET_OOM_ERROR(stmt->error_info);
- SET_OOM_ERROR(stmt->conn->error_info);
+ SET_OOM_ERROR(conn->error_info);
} else {
if (FAIL == (ret = PACKET_READ(fields_eof))) {
if (stmt->result) {
static enum_func_status
MYSQLND_METHOD(mysqlnd_stmt, prepare)(MYSQLND_STMT * const s, const char * const query, const size_t query_len)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
+ MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL;
MYSQLND_STMT * s_to_prepare = s;
MYSQLND_STMT_DATA * stmt_to_prepare = stmt;
DBG_ENTER("mysqlnd_stmt::prepare");
- if (!stmt || !stmt->conn) {
+ if (!stmt || !conn) {
DBG_RETURN(FAIL);
}
DBG_INF_FMT("stmt=%lu", stmt->stmt_id);
DBG_INF_FMT("query=%s", query);
UPSERT_STATUS_SET_AFFECTED_ROWS_TO_ERROR(stmt->upsert_status);
- UPSERT_STATUS_SET_AFFECTED_ROWS_TO_ERROR(stmt->conn->upsert_status);
+ UPSERT_STATUS_SET_AFFECTED_ROWS_TO_ERROR(conn->upsert_status);
SET_EMPTY_ERROR(stmt->error_info);
- SET_EMPTY_ERROR(stmt->conn->error_info);
+ SET_EMPTY_ERROR(conn->error_info);
if (stmt->state > MYSQLND_STMT_INITTED) {
/* See if we have to clean the wire */
Create a new test statement, which we will prepare, but if anything
fails, we will scrap it.
*/
- s_to_prepare = stmt->conn->m->stmt_init(stmt->conn);
+ s_to_prepare = conn->m->stmt_init(conn);
if (!s_to_prepare) {
goto fail;
}
{
enum_func_status ret = FAIL;
const MYSQLND_CSTRING query_string = {query, query_len};
- struct st_mysqlnd_protocol_command * command = stmt_to_prepare->conn->command_factory(COM_STMT_PREPARE, stmt_to_prepare->conn, query_string);
+ struct st_mysqlnd_protocol_command * command = conn->command_factory(COM_STMT_PREPARE, conn, query_string);
if (command) {
ret = command->run(command);
command->free_command(command);
no metadata at prepare.
*/
if (stmt_to_prepare->field_count) {
- MYSQLND_RES * result = stmt->conn->m->result_init(stmt_to_prepare->field_count, stmt_to_prepare->persistent);
+ MYSQLND_RES * result = conn->m->result_init(stmt_to_prepare->field_count, stmt_to_prepare->persistent);
if (!result) {
- SET_OOM_ERROR(stmt->conn->error_info);
+ SET_OOM_ERROR(conn->error_info);
goto fail;
}
/* Allocate the result now as it is needed for the reading of metadata */
stmt_to_prepare->result = result;
- result->conn = stmt_to_prepare->conn->m->get_reference(stmt_to_prepare->conn);
+ result->conn = conn->m->get_reference(conn);
result->type = MYSQLND_RES_PS_BUF;
- if (FAIL == result->m.read_result_metadata(result, stmt_to_prepare->conn) ||
+ if (FAIL == result->m.read_result_metadata(result, conn) ||
FAIL == mysqlnd_stmt_prepare_read_eof(s_to_prepare))
{
goto fail;
static enum_func_status
mysqlnd_stmt_execute_parse_response(MYSQLND_STMT * const s, enum_mysqlnd_parse_exec_response_type type)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
+ MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL;
enum_func_status ret;
- MYSQLND_CONN_DATA * conn;
DBG_ENTER("mysqlnd_stmt_execute_parse_response");
- if (!stmt || !stmt->conn) {
+ if (!stmt || !conn) {
DBG_RETURN(FAIL);
}
- conn = stmt->conn;
SET_CONNECTION_STATE(&conn->state, CONN_QUERY_SENT);
- ret = stmt->conn->m->query_read_result_set_header(stmt->conn, s);
+ ret = conn->m->query_read_result_set_header(conn, s);
if (ret == FAIL) {
COPY_CLIENT_ERROR(stmt->error_info, *conn->error_info);
UPSERT_STATUS_RESET(stmt->upsert_status);
to resend the types. Next execution will also need to resend the type.
*/
SET_EMPTY_ERROR(stmt->error_info);
- SET_EMPTY_ERROR(stmt->conn->error_info);
+ SET_EMPTY_ERROR(conn->error_info);
UPSERT_STATUS_SET_WARNINGS(stmt->upsert_status, UPSERT_STATUS_GET_WARNINGS(conn->upsert_status));
UPSERT_STATUS_SET_AFFECTED_ROWS(stmt->upsert_status, UPSERT_STATUS_GET_AFFECTED_ROWS(conn->upsert_status));
UPSERT_STATUS_SET_SERVER_STATUS(stmt->upsert_status, UPSERT_STATUS_GET_SERVER_STATUS(conn->upsert_status));
For SHOW we don't create (bypasses PS in server)
a result set at prepare and thus a connection was missing
*/
- stmt->result->conn = stmt->conn->m->get_reference(stmt->conn);
+ stmt->result->conn = conn->m->get_reference(conn);
}
/* Update stmt->field_count as SHOW sets it to 0 at prepare */
/* {{{ mysqlnd_stmt::send_execute */
static enum_func_status
-MYSQLND_METHOD(mysqlnd_stmt, send_execute)(MYSQLND_STMT * const s, enum_mysqlnd_send_execute_type type, zval * read_cb, zval * err_cb)
+MYSQLND_METHOD(mysqlnd_stmt, send_execute)(MYSQLND_STMT * const s, const enum_mysqlnd_send_execute_type type, zval * read_cb, zval * err_cb)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
+ MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL;
enum_func_status ret;
- MYSQLND_CONN_DATA * conn;
zend_uchar *request = NULL;
size_t request_len;
zend_bool free_request;
DBG_ENTER("mysqlnd_stmt::send_execute");
- if (!stmt || !stmt->conn) {
+ if (!stmt || !conn) {
DBG_RETURN(FAIL);
}
- conn = stmt->conn;
DBG_INF_FMT("stmt=%lu", stmt->stmt_id);
UPSERT_STATUS_SET_AFFECTED_ROWS_TO_ERROR(stmt->upsert_status);
- UPSERT_STATUS_SET_AFFECTED_ROWS_TO_ERROR(stmt->conn->upsert_status);
+ UPSERT_STATUS_SET_AFFECTED_ROWS_TO_ERROR(conn->upsert_status);
if (stmt->result && stmt->state >= MYSQLND_STMT_PREPARED && stmt->field_count) {
/*
stmt->state = MYSQLND_STMT_PREPARED;
} else if (stmt->state < MYSQLND_STMT_PREPARED) {
/* Only initted - error */
- SET_CLIENT_ERROR(conn->error_info, 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);
if (stmt->param_count) {
unsigned int i, not_bound = 0;
if (!stmt->param_bind) {
- SET_CLIENT_ERROR(stmt->error_info, CR_PARAMS_NOT_BOUND, UNKNOWN_SQLSTATE,
- "No data supplied for parameters in prepared statement");
+ 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);
}
ret = s->m->generate_execute_request(s, &request, &request_len, &free_request);
if (ret == PASS) {
const MYSQLND_CSTRING payload = {(const char*) request, request_len};
- struct st_mysqlnd_protocol_command * command = stmt->conn->command_factory(COM_STMT_EXECUTE, stmt->conn, payload);
+ struct st_mysqlnd_protocol_command * command = conn->command_factory(COM_STMT_EXECUTE, conn, payload);
ret = FAIL;
if (command) {
ret = command->run(command);
/* {{{ mysqlnd_stmt_fetch_row_buffered */
enum_func_status
-mysqlnd_stmt_fetch_row_buffered(MYSQLND_RES * result, void * param, unsigned int flags, zend_bool * fetched_anything)
+mysqlnd_stmt_fetch_row_buffered(MYSQLND_RES * result, void * param, const unsigned int flags, zend_bool * fetched_anything)
{
MYSQLND_STMT * s = (MYSQLND_STMT *) param;
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
const MYSQLND_RES_METADATA * const meta = result->meta;
unsigned int field_count = meta->field_count;
/* {{{ mysqlnd_stmt_fetch_row_unbuffered */
enum_func_status
-mysqlnd_stmt_fetch_row_unbuffered(MYSQLND_RES * result, void * param, unsigned int flags, zend_bool * fetched_anything)
+mysqlnd_stmt_fetch_row_unbuffered(MYSQLND_RES * result, void * param, const unsigned int flags, zend_bool * fetched_anything)
{
enum_func_status ret;
MYSQLND_STMT * s = (MYSQLND_STMT *) param;
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
MYSQLND_PACKET_ROW * row_packet;
+ MYSQLND_CONN_DATA * conn = result->conn;
const MYSQLND_RES_METADATA * const meta = result->meta;
DBG_ENTER("mysqlnd_stmt_fetch_row_unbuffered");
DBG_INF("EOF already reached");
DBG_RETURN(PASS);
}
- if (GET_CONNECTION_STATE(&result->conn->state) != CONN_FETCHING_DATA) {
- SET_CLIENT_ERROR(result->conn->error_info, CR_COMMANDS_OUT_OF_SYNC,
- UNKNOWN_SQLSTATE, mysqlnd_out_of_sync);
+ if (GET_CONNECTION_STATE(&conn->state) != CONN_FETCHING_DATA) {
+ SET_CLIENT_ERROR(conn->error_info, CR_COMMANDS_OUT_OF_SYNC, UNKNOWN_SQLSTATE, mysqlnd_out_of_sync);
DBG_ERR("command out of sync");
DBG_RETURN(FAIL);
}
unsigned int i, field_count = result->field_count;
if (!row_packet->skip_extraction) {
- result->unbuf->m.free_last_data(result->unbuf, result->conn? result->conn->stats : NULL);
+ result->unbuf->m.free_last_data(result->unbuf, conn->stats);
result->unbuf->last_row_data = row_packet->fields;
result->unbuf->last_row_buffer = row_packet->row_buffer;
result->unbuf->last_row_data,
row_packet->field_count,
row_packet->fields_metadata,
- result->conn->options->int_and_float_native,
- result->conn->stats))
+ conn->options->int_and_float_native,
+ conn->stats))
{
DBG_RETURN(FAIL);
}
zval_dtor(result);
#endif
if (!Z_ISNULL_P(data)) {
- if ((Z_TYPE_P(data) == IS_STRING) &&
- (meta->fields[i].max_length < (zend_ulong) Z_STRLEN_P(data))) {
+ if ((Z_TYPE_P(data) == IS_STRING) && (meta->fields[i].max_length < (zend_ulong) Z_STRLEN_P(data))){
meta->fields[i].max_length = Z_STRLEN_P(data);
}
ZVAL_COPY_VALUE(result, data);
}
}
}
- MYSQLND_INC_CONN_STATISTIC(stmt->conn->stats, STAT_ROWS_FETCHED_FROM_CLIENT_PS_UNBUF);
+ MYSQLND_INC_CONN_STATISTIC(conn->stats, STAT_ROWS_FETCHED_FROM_CLIENT_PS_UNBUF);
} else {
DBG_INF("skipping extraction");
/*
*fetched_anything = TRUE;
} else if (ret == FAIL) {
if (row_packet->error_info.error_no) {
- COPY_CLIENT_ERROR(stmt->conn->error_info, row_packet->error_info);
+ COPY_CLIENT_ERROR(conn->error_info, row_packet->error_info);
COPY_CLIENT_ERROR(stmt->error_info, row_packet->error_info);
}
- SET_CONNECTION_STATE(&result->conn->state, CONN_READY);
+ SET_CONNECTION_STATE(&conn->state, CONN_READY);
result->unbuf->eof_reached = TRUE; /* so next time we won't get an error */
} else if (row_packet->eof) {
DBG_INF("EOF");
/* Mark the connection as usable again */
result->unbuf->eof_reached = TRUE;
- UPSERT_STATUS_RESET(result->conn->upsert_status);
- UPSERT_STATUS_SET_WARNINGS(result->conn->upsert_status, row_packet->warning_count);
- UPSERT_STATUS_SET_SERVER_STATUS(result->conn->upsert_status, row_packet->server_status);
+ UPSERT_STATUS_RESET(conn->upsert_status);
+ UPSERT_STATUS_SET_WARNINGS(conn->upsert_status, row_packet->warning_count);
+ UPSERT_STATUS_SET_SERVER_STATUS(conn->upsert_status, row_packet->server_status);
/*
result->row_packet will be cleaned when
destroying the result object
*/
- if (UPSERT_STATUS_GET_SERVER_STATUS(result->conn->upsert_status) & SERVER_MORE_RESULTS_EXISTS) {
- SET_CONNECTION_STATE(&result->conn->state, CONN_NEXT_RESULT_PENDING);
+ if (UPSERT_STATUS_GET_SERVER_STATUS(conn->upsert_status) & SERVER_MORE_RESULTS_EXISTS) {
+ SET_CONNECTION_STATE(&conn->state, CONN_NEXT_RESULT_PENDING);
} else {
- SET_CONNECTION_STATE(&result->conn->state, CONN_READY);
+ SET_CONNECTION_STATE(&conn->state, CONN_READY);
}
}
static MYSQLND_RES *
MYSQLND_METHOD(mysqlnd_stmt, use_result)(MYSQLND_STMT * s)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
+ MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL;
MYSQLND_RES * result;
- MYSQLND_CONN_DATA * conn;
DBG_ENTER("mysqlnd_stmt::use_result");
- if (!stmt || !stmt->conn || !stmt->result) {
+ if (!stmt || !conn || !stmt->result) {
DBG_RETURN(NULL);
}
DBG_INF_FMT("stmt=%lu", stmt->stmt_id);
- conn = stmt->conn;
-
if (!stmt->field_count ||
(!stmt->cursor_exists && GET_CONNECTION_STATE(&conn->state) != CONN_FETCHING_DATA) ||
(stmt->cursor_exists && GET_CONNECTION_STATE(&conn->state) != CONN_READY) ||
(stmt->state != MYSQLND_STMT_WAITING_USE_OR_STORE))
{
- SET_CLIENT_ERROR(conn->error_info, CR_COMMANDS_OUT_OF_SYNC,
- UNKNOWN_SQLSTATE, mysqlnd_out_of_sync);
+ SET_CLIENT_ERROR(conn->error_info, CR_COMMANDS_OUT_OF_SYNC, UNKNOWN_SQLSTATE, mysqlnd_out_of_sync);
DBG_ERR("command out of sync");
DBG_RETURN(NULL);
}
SET_EMPTY_ERROR(stmt->error_info);
- MYSQLND_INC_CONN_STATISTIC(stmt->conn->stats, STAT_PS_UNBUFFERED_SETS);
+ MYSQLND_INC_CONN_STATISTIC(conn->stats, STAT_PS_UNBUFFERED_SETS);
result = stmt->result;
result->m.use_result(stmt->result, TRUE);
{
enum_func_status ret;
MYSQLND_STMT * s = (MYSQLND_STMT *) param;
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
+ MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL;
zend_uchar buf[MYSQLND_STMT_ID_LENGTH /* statement id */ + 4 /* number of rows to fetch */];
MYSQLND_PACKET_ROW * row_packet;
DBG_ERR("no statement");
DBG_RETURN(FAIL);
}
-
DBG_INF_FMT("stmt=%lu flags=%u", stmt->stmt_id, flags);
if (stmt->state < MYSQLND_STMT_USER_FETCHING) {
/* Only initted - error */
- SET_CLIENT_ERROR(stmt->conn->error_info, CR_COMMANDS_OUT_OF_SYNC, UNKNOWN_SQLSTATE, mysqlnd_out_of_sync);
+ SET_CLIENT_ERROR(conn->error_info, CR_COMMANDS_OUT_OF_SYNC, UNKNOWN_SQLSTATE, mysqlnd_out_of_sync);
DBG_ERR("command out of sync");
DBG_RETURN(FAIL);
}
}
SET_EMPTY_ERROR(stmt->error_info);
- SET_EMPTY_ERROR(stmt->conn->error_info);
+ SET_EMPTY_ERROR(conn->error_info);
int4store(buf, stmt->stmt_id);
int4store(buf + MYSQLND_STMT_ID_LENGTH, 1); /* for now fetch only one row */
{
const MYSQLND_CSTRING payload = {(const char*) buf, sizeof(buf)};
- struct st_mysqlnd_protocol_command * command = stmt->conn->command_factory(COM_STMT_FETCH, stmt->conn, payload);
+ struct st_mysqlnd_protocol_command * command = conn->command_factory(COM_STMT_FETCH, conn, payload);
ret = FAIL;
if (command) {
ret = command->run(command);
command->free_command(command);
if (ret == FAIL) {
- COPY_CLIENT_ERROR(stmt->error_info, *stmt->conn->error_info);
+ COPY_CLIENT_ERROR(stmt->error_info, *conn->error_info);
}
}
if (FAIL == ret) {
}
}
-#if A9
- if (FAIL == stmt->conn->m->send_command(stmt->conn, COM_STMT_FETCH, buf, sizeof(buf),
- PROT_LAST /* we will handle the response packet*/,
- FALSE, TRUE)) {
- COPY_CLIENT_ERROR(stmt->error_info, *stmt->conn->error_info);
- DBG_RETURN(FAIL);
- }
-#endif
row_packet->skip_extraction = stmt->result_bind? FALSE:TRUE;
unsigned int i, field_count = result->field_count;
if (!row_packet->skip_extraction) {
- result->unbuf->m.free_last_data(result->unbuf, result->conn? result->conn->stats : NULL);
+ result->unbuf->m.free_last_data(result->unbuf, conn->stats);
result->unbuf->last_row_data = row_packet->fields;
result->unbuf->last_row_buffer = row_packet->row_buffer;
result->unbuf->last_row_data,
row_packet->field_count,
row_packet->fields_metadata,
- result->conn->options->int_and_float_native,
- result->conn->stats))
+ conn->options->int_and_float_native,
+ conn->stats))
{
DBG_RETURN(FAIL);
}
row_packet->row_buffer->free_chunk(row_packet->row_buffer);
row_packet->row_buffer = NULL;
}
- MYSQLND_INC_CONN_STATISTIC(stmt->conn->stats, STAT_ROWS_FETCHED_FROM_CLIENT_PS_CURSOR);
+ MYSQLND_INC_CONN_STATISTIC(conn->stats, STAT_ROWS_FETCHED_FROM_CLIENT_PS_CURSOR);
result->unbuf->row_count++;
*fetched_anything = TRUE;
} else {
*fetched_anything = FALSE;
UPSERT_STATUS_SET_WARNINGS(stmt->upsert_status, row_packet->warning_count);
- UPSERT_STATUS_SET_WARNINGS(stmt->conn->upsert_status, row_packet->warning_count);
+ UPSERT_STATUS_SET_WARNINGS(conn->upsert_status, row_packet->warning_count);
UPSERT_STATUS_SET_SERVER_STATUS(stmt->upsert_status, row_packet->server_status);
- UPSERT_STATUS_SET_SERVER_STATUS(stmt->conn->upsert_status, row_packet->server_status);
+ UPSERT_STATUS_SET_SERVER_STATUS(conn->upsert_status, row_packet->server_status);
result->unbuf->eof_reached = row_packet->eof;
}
UPSERT_STATUS_SET_WARNINGS(stmt->upsert_status, row_packet->warning_count);
- UPSERT_STATUS_SET_WARNINGS(stmt->conn->upsert_status, row_packet->warning_count);
+ UPSERT_STATUS_SET_WARNINGS(conn->upsert_status, row_packet->warning_count);
UPSERT_STATUS_SET_SERVER_STATUS(stmt->upsert_status, row_packet->server_status);
- UPSERT_STATUS_SET_SERVER_STATUS(stmt->conn->upsert_status, row_packet->server_status);
+ UPSERT_STATUS_SET_SERVER_STATUS(conn->upsert_status, row_packet->server_status);
DBG_INF_FMT("ret=%s fetched=%u server_status=%u warnings=%u eof=%u",
ret == PASS? "PASS":"FAIL", *fetched_anything,
static enum_func_status
MYSQLND_METHOD(mysqlnd_stmt, fetch)(MYSQLND_STMT * const s, zend_bool * const fetched_anything)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
+ MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL;
enum_func_status ret;
DBG_ENTER("mysqlnd_stmt::fetch");
if (!stmt || !stmt->conn) {
if (!stmt->result || stmt->state < MYSQLND_STMT_WAITING_USE_OR_STORE) {
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);
} else if (stmt->state == MYSQLND_STMT_WAITING_USE_OR_STORE) {
stmt->state = MYSQLND_STMT_USER_FETCHING;
SET_EMPTY_ERROR(stmt->error_info);
- SET_EMPTY_ERROR(stmt->conn->error_info);
+ SET_EMPTY_ERROR(conn->error_info);
DBG_INF_FMT("result_bind=%p separated_once=%u", &stmt->result_bind, stmt->result_zvals_separated_once);
/*
static enum_func_status
MYSQLND_METHOD(mysqlnd_stmt, reset)(MYSQLND_STMT * const s)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
enum_func_status ret = PASS;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
+ MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL;
DBG_ENTER("mysqlnd_stmt::reset");
- if (!stmt || !stmt->conn) {
+ if (!stmt || !conn) {
DBG_RETURN(FAIL);
}
DBG_INF_FMT("stmt=%lu", stmt->stmt_id);
SET_EMPTY_ERROR(stmt->error_info);
- SET_EMPTY_ERROR(stmt->conn->error_info);
+ SET_EMPTY_ERROR(conn->error_info);
if (stmt->stmt_id) {
MYSQLND_CONN_DATA * conn = stmt->conn;
static enum_func_status
MYSQLND_METHOD(mysqlnd_stmt, flush)(MYSQLND_STMT * const s)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
enum_func_status ret = PASS;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
+ MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL;
DBG_ENTER("mysqlnd_stmt::flush");
- if (!stmt || !stmt->conn) {
+ if (!stmt || !conn) {
DBG_RETURN(FAIL);
}
DBG_INF_FMT("stmt=%lu", stmt->stmt_id);
MYSQLND_METHOD(mysqlnd_stmt, send_long_data)(MYSQLND_STMT * const s, unsigned int param_no,
const char * const data, zend_ulong data_length)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
enum_func_status ret = FAIL;
- MYSQLND_CONN_DATA * conn;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
+ MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL;
zend_uchar * cmd_buf;
DBG_ENTER("mysqlnd_stmt::send_long_data");
- if (!stmt || !stmt->conn) {
+ if (!stmt || !conn) {
DBG_RETURN(FAIL);
}
DBG_INF_FMT("stmt=%lu param_no=%u data_len=%lu", stmt->stmt_id, param_no, data_length);
- conn = stmt->conn;
-
SET_EMPTY_ERROR(stmt->error_info);
- SET_EMPTY_ERROR(stmt->conn->error_info);
+ SET_EMPTY_ERROR(conn->error_info);
if (stmt->state < MYSQLND_STMT_PREPARED) {
SET_CLIENT_ERROR(stmt->error_info, CR_NO_PREPARE_STMT, UNKNOWN_SQLSTATE, mysqlnd_stmt_not_prepared);
/* COM_STMT_SEND_LONG_DATA doesn't acknowledge with an OK packet */
{
const MYSQLND_CSTRING payload = {(const char *) cmd_buf, packet_len};
- struct st_mysqlnd_protocol_command * command = stmt->conn->command_factory(COM_STMT_SEND_LONG_DATA, stmt->conn, payload);
+ struct st_mysqlnd_protocol_command * command = conn->command_factory(COM_STMT_SEND_LONG_DATA, conn, payload);
ret = FAIL;
if (command) {
ret = command->run(command);
static enum_func_status
MYSQLND_METHOD(mysqlnd_stmt, bind_parameters)(MYSQLND_STMT * const s, MYSQLND_PARAM_BIND * const param_bind)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
+ MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL;
+
DBG_ENTER("mysqlnd_stmt::bind_param");
- if (!stmt || !stmt->conn) {
+ if (!stmt || !conn) {
DBG_RETURN(FAIL);
}
DBG_INF_FMT("stmt=%lu param_count=%u", stmt->stmt_id, stmt->param_count);
}
SET_EMPTY_ERROR(stmt->error_info);
- SET_EMPTY_ERROR(stmt->conn->error_info);
+ SET_EMPTY_ERROR(conn->error_info);
if (stmt->param_count) {
unsigned int i = 0;
MYSQLND_METHOD(mysqlnd_stmt, bind_one_parameter)(MYSQLND_STMT * const s, unsigned int param_no,
zval * const zv, zend_uchar type)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
+ MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL;
+
DBG_ENTER("mysqlnd_stmt::bind_one_parameter");
- if (!stmt || !stmt->conn) {
+ if (!stmt || !conn) {
DBG_RETURN(FAIL);
}
DBG_INF_FMT("stmt=%lu param_no=%u param_count=%u type=%u", stmt->stmt_id, param_no, stmt->param_count, type);
DBG_RETURN(FAIL);
}
SET_EMPTY_ERROR(stmt->error_info);
- SET_EMPTY_ERROR(stmt->conn->error_info);
+ SET_EMPTY_ERROR(conn->error_info);
if (stmt->param_count) {
if (!stmt->param_bind) {
static enum_func_status
MYSQLND_METHOD(mysqlnd_stmt, refresh_bind_param)(MYSQLND_STMT * const s)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
+ MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL;
+
DBG_ENTER("mysqlnd_stmt::refresh_bind_param");
- if (!stmt || !stmt->conn) {
+ if (!stmt || !conn) {
DBG_RETURN(FAIL);
}
DBG_INF_FMT("stmt=%lu param_count=%u", stmt->stmt_id, stmt->param_count);
}
SET_EMPTY_ERROR(stmt->error_info);
- SET_EMPTY_ERROR(stmt->conn->error_info);
+ SET_EMPTY_ERROR(conn->error_info);
if (stmt->param_count) {
stmt->send_types_to_server = 1;
MYSQLND_METHOD(mysqlnd_stmt, bind_result)(MYSQLND_STMT * const s,
MYSQLND_RESULT_BIND * const result_bind)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
+ MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL;
+
DBG_ENTER("mysqlnd_stmt::bind_result");
- if (!stmt || !stmt->conn) {
+ if (!stmt || !conn) {
DBG_RETURN(FAIL);
}
DBG_INF_FMT("stmt=%lu field_count=%u", stmt->stmt_id, stmt->field_count);
}
SET_EMPTY_ERROR(stmt->error_info);
- SET_EMPTY_ERROR(stmt->conn->error_info);
+ SET_EMPTY_ERROR(conn->error_info);
if (stmt->field_count) {
unsigned int i = 0;
static enum_func_status
MYSQLND_METHOD(mysqlnd_stmt, bind_one_result)(MYSQLND_STMT * const s, unsigned int param_no)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
+ MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL;
+
DBG_ENTER("mysqlnd_stmt::bind_result");
- if (!stmt || !stmt->conn) {
+ if (!stmt || !conn) {
DBG_RETURN(FAIL);
}
DBG_INF_FMT("stmt=%lu field_count=%u", stmt->stmt_id, stmt->field_count);
}
SET_EMPTY_ERROR(stmt->error_info);
- SET_EMPTY_ERROR(stmt->conn->error_info);
+ SET_EMPTY_ERROR(conn->error_info);
if (stmt->field_count) {
mysqlnd_stmt_separate_one_result_bind(s, param_no);
static uint64_t
MYSQLND_METHOD(mysqlnd_stmt, insert_id)(const MYSQLND_STMT * const s)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
return stmt? UPSERT_STATUS_GET_LAST_INSERT_ID(stmt->upsert_status) : 0;
}
/* }}} */
static uint64_t
MYSQLND_METHOD(mysqlnd_stmt, affected_rows)(const MYSQLND_STMT * const s)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
return stmt? UPSERT_STATUS_GET_AFFECTED_ROWS(stmt->upsert_status) : 0;
}
/* }}} */
static uint64_t
MYSQLND_METHOD(mysqlnd_stmt, num_rows)(const MYSQLND_STMT * const s)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
return stmt && stmt->result? mysqlnd_num_rows(stmt->result):0;
}
/* }}} */
static unsigned int
MYSQLND_METHOD(mysqlnd_stmt, warning_count)(const MYSQLND_STMT * const s)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
return stmt? UPSERT_STATUS_GET_WARNINGS(stmt->upsert_status) : 0;
}
/* }}} */
static unsigned int
MYSQLND_METHOD(mysqlnd_stmt, server_status)(const MYSQLND_STMT * const s)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
return stmt? UPSERT_STATUS_GET_SERVER_STATUS(stmt->upsert_status) : 0;
}
/* }}} */
static unsigned int
MYSQLND_METHOD(mysqlnd_stmt, field_count)(const MYSQLND_STMT * const s)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
return stmt? stmt->field_count : 0;
}
/* }}} */
static unsigned int
MYSQLND_METHOD(mysqlnd_stmt, param_count)(const MYSQLND_STMT * const s)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
return stmt? stmt->param_count : 0;
}
/* }}} */
static unsigned int
MYSQLND_METHOD(mysqlnd_stmt, errno)(const MYSQLND_STMT * const s)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
return stmt? stmt->error_info->error_no : 0;
}
/* }}} */
static const char *
MYSQLND_METHOD(mysqlnd_stmt, error)(const MYSQLND_STMT * const s)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
return stmt? stmt->error_info->error : 0;
}
/* }}} */
static const char *
MYSQLND_METHOD(mysqlnd_stmt, sqlstate)(const MYSQLND_STMT * const s)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
return stmt && stmt->error_info->sqlstate[0] ? stmt->error_info->sqlstate:MYSQLND_SQLSTATE_NULL;
}
/* }}} */
static enum_func_status
MYSQLND_METHOD(mysqlnd_stmt, data_seek)(const MYSQLND_STMT * const s, uint64_t row)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
return stmt && stmt->result? stmt->result->m.seek_data(stmt->result, row) : FAIL;
}
/* }}} */
static MYSQLND_RES *
MYSQLND_METHOD(mysqlnd_stmt, param_metadata)(MYSQLND_STMT * const s)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
if (!stmt || !stmt->param_count) {
return NULL;
}
static MYSQLND_RES *
MYSQLND_METHOD(mysqlnd_stmt, result_metadata)(MYSQLND_STMT * const s)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
- MYSQLND_RES *result;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
+ MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL;
+ MYSQLND_RES * result_meta = NULL;
DBG_ENTER("mysqlnd_stmt::result_metadata");
- if (!stmt) {
+ if (!stmt || ! conn) {
DBG_RETURN(NULL);
}
DBG_INF_FMT("stmt=%u field_count=%u", stmt->stmt_id, stmt->field_count);
- if (!stmt->field_count || !stmt->conn || !stmt->result || !stmt->result->meta) {
+ if (!stmt->field_count || !stmt->result || !stmt->result->meta) {
DBG_INF("NULL");
DBG_RETURN(NULL);
}
/* stored result, we have to update the max_length before we clone the meta data :( */
stmt->result->stored_data->m.initialize_result_set_rest(stmt->result->stored_data,
stmt->result->meta,
- stmt->conn->stats,
- stmt->conn->options->int_and_float_native);
+ conn->stats,
+ conn->options->int_and_float_native);
}
/*
TODO: This implementation is kind of a hack,
be handled in a better way.
*/
do {
- result = stmt->conn->m->result_init(stmt->field_count, stmt->persistent);
- if (!result) {
+ result_meta = conn->m->result_init(stmt->field_count, stmt->persistent);
+ if (!result_meta) {
break;
}
- result->type = MYSQLND_RES_NORMAL;
- result->unbuf = mysqlnd_result_unbuffered_init(stmt->field_count, TRUE, result->persistent);
- if (!result->unbuf) {
+ result_meta->type = MYSQLND_RES_NORMAL;
+ result_meta->unbuf = mysqlnd_result_unbuffered_init(stmt->field_count, TRUE, result_meta->persistent);
+ if (!result_meta->unbuf) {
break;
}
- result->unbuf->eof_reached = TRUE;
- result->meta = stmt->result->meta->m->clone_metadata(stmt->result->meta, FALSE);
- if (!result->meta) {
+ result_meta->unbuf->eof_reached = TRUE;
+ result_meta->meta = stmt->result->meta->m->clone_metadata(stmt->result->meta, FALSE);
+ if (!result_meta->meta) {
break;
}
- DBG_INF_FMT("result=%p", result);
- DBG_RETURN(result);
+ DBG_INF_FMT("result_meta=%p", result_meta);
+ DBG_RETURN(result_meta);
} while (0);
- SET_OOM_ERROR(stmt->conn->error_info);
- if (result) {
- result->m.free_result(result, TRUE);
+ SET_OOM_ERROR(conn->error_info);
+ if (result_meta) {
+ result_meta->m.free_result(result_meta, TRUE);
}
DBG_RETURN(NULL);
}
enum mysqlnd_stmt_attr attr_type,
const void * const value)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
DBG_ENTER("mysqlnd_stmt::attr_set");
if (!stmt) {
DBG_RETURN(FAIL);
enum mysqlnd_stmt_attr attr_type,
void * const value)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
DBG_ENTER("mysqlnd_stmt::attr_set");
if (!stmt) {
DBG_RETURN(FAIL);
static enum_func_status
MYSQLND_METHOD(mysqlnd_stmt, free_result)(MYSQLND_STMT * const s)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
+ MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL;
+
DBG_ENTER("mysqlnd_stmt::free_result");
- if (!stmt || !stmt->conn) {
+ if (!stmt || !conn) {
DBG_RETURN(FAIL);
}
DBG_INF_FMT("stmt=%lu", stmt->stmt_id);
}
/* Line is free! */
- SET_CONNECTION_STATE(&stmt->conn->state, CONN_READY);
+ SET_CONNECTION_STATE(&conn->state, CONN_READY);
DBG_RETURN(PASS);
}
static void
mysqlnd_stmt_separate_result_bind(MYSQLND_STMT * const s)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
unsigned int i;
DBG_ENTER("mysqlnd_stmt_separate_result_bind");
for (i = 0; i < stmt->field_count; i++) {
/* Let's try with no cache */
if (stmt->result_bind[i].bound == TRUE) {
- DBG_INF_FMT("%u has refcount=%u", i,
- Z_REFCOUNTED(stmt->result_bind[i].zv)? Z_REFCOUNT(stmt->result_bind[i].zv) : 0);
+ DBG_INF_FMT("%u has refcount=%u", i, Z_REFCOUNTED(stmt->result_bind[i].zv)? Z_REFCOUNT(stmt->result_bind[i].zv) : 0);
zval_ptr_dtor(&stmt->result_bind[i].zv);
}
}
/* {{{ mysqlnd_stmt_separate_one_result_bind */
static void
-mysqlnd_stmt_separate_one_result_bind(MYSQLND_STMT * const s, unsigned int param_no)
+mysqlnd_stmt_separate_one_result_bind(MYSQLND_STMT * const s, const unsigned int param_no)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
DBG_ENTER("mysqlnd_stmt_separate_one_result_bind");
if (!stmt) {
DBG_VOID_RETURN;
*/
/* Let's try with no cache */
if (stmt->result_bind[param_no].bound == TRUE) {
- DBG_INF_FMT("%u has refcount=%u", param_no,
- Z_REFCOUNTED(stmt->result_bind[param_no].zv)?
- Z_REFCOUNT(stmt->result_bind[param_no].zv) : 0);
+ DBG_INF_FMT("%u has refcount=%u", param_no, Z_REFCOUNTED(stmt->result_bind[param_no].zv)? Z_REFCOUNT(stmt->result_bind[param_no].zv) : 0);
zval_ptr_dtor(&stmt->result_bind[param_no].zv);
}
static void
MYSQLND_METHOD(mysqlnd_stmt, free_stmt_result)(MYSQLND_STMT * const s)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
DBG_ENTER("mysqlnd_stmt::free_stmt_result");
if (!stmt) {
DBG_VOID_RETURN;
static void
MYSQLND_METHOD(mysqlnd_stmt, free_stmt_content)(MYSQLND_STMT * const s)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
DBG_ENTER("mysqlnd_stmt::free_stmt_content");
if (!stmt) {
DBG_VOID_RETURN;
static enum_func_status
MYSQLND_METHOD_PRIVATE(mysqlnd_stmt, close_on_server)(MYSQLND_STMT * const s, zend_bool implicit)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
- MYSQLND_CONN_DATA * conn;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
+ MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL;
enum_mysqlnd_collected_stats statistic = STAT_LAST;
DBG_ENTER("mysqlnd_stmt::close_on_server");
- if (!stmt || !stmt->conn) {
+ if (!stmt || !conn) {
DBG_RETURN(FAIL);
}
DBG_INF_FMT("stmt=%lu", stmt->stmt_id);
- conn = stmt->conn;
-
SET_EMPTY_ERROR(stmt->error_info);
- SET_EMPTY_ERROR(stmt->conn->error_info);
+ SET_EMPTY_ERROR(conn->error_info);
/*
If the user decided to close the statement right after execute()
s->m->free_stmt_content(s);
- if (stmt->conn) {
- stmt->conn->m->free_reference(stmt->conn);
+ if (conn) {
+ conn->m->free_reference(conn);
stmt->conn = NULL;
}
static MYSQLND_PARAM_BIND *
MYSQLND_METHOD(mysqlnd_stmt, alloc_param_bind)(MYSQLND_STMT * const s)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
DBG_ENTER("mysqlnd_stmt::alloc_param_bind");
if (!stmt) {
DBG_RETURN(NULL);
static MYSQLND_RESULT_BIND *
MYSQLND_METHOD(mysqlnd_stmt, alloc_result_bind)(MYSQLND_STMT * const s)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
DBG_ENTER("mysqlnd_stmt::alloc_result_bind");
if (!stmt) {
DBG_RETURN(NULL);
PHPAPI void
MYSQLND_METHOD(mysqlnd_stmt, free_parameter_bind)(MYSQLND_STMT * const s, MYSQLND_PARAM_BIND * param_bind)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
if (stmt) {
mnd_pefree(param_bind, stmt->persistent);
}
PHPAPI void
MYSQLND_METHOD(mysqlnd_stmt, free_result_bind)(MYSQLND_STMT * const s, MYSQLND_RESULT_BIND * result_bind)
{
- MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
+ MYSQLND_STMT_DATA * stmt = s? s->data : NULL;
if (stmt) {
mnd_pefree(result_bind, stmt->persistent);
}
/* {{{ php_mysqlnd_net_field_length
Get next field's length */
zend_ulong
-php_mysqlnd_net_field_length(zend_uchar **packet)
+php_mysqlnd_net_field_length(const zend_uchar **packet)
{
- register zend_uchar *p= (zend_uchar *)*packet;
+ register const zend_uchar *p= (const zend_uchar *)*packet;
if (*p < 251) {
(*packet)++;
/* {{{ php_mysqlnd_net_field_length_ll
Get next field's length */
uint64_t
-php_mysqlnd_net_field_length_ll(zend_uchar **packet)
+php_mysqlnd_net_field_length_ll(const zend_uchar **packet)
{
- register zend_uchar *p = (zend_uchar *)*packet;
+ register const zend_uchar *p = (zend_uchar *)*packet;
if (*p < 251) {
(*packet)++;
/* {{{ php_mysqlnd_net_store_length */
zend_uchar *
-php_mysqlnd_net_store_length(zend_uchar *packet, uint64_t length)
+php_mysqlnd_net_store_length(zend_uchar *packet, const uint64_t length)
{
if (length < (uint64_t) L64(251)) {
*packet = (zend_uchar) length;
/* {{{ php_mysqlnd_read_error_from_line */
static enum_func_status
-php_mysqlnd_read_error_from_line(zend_uchar *buf, size_t buf_len,
- char *error, int error_buf_len,
- unsigned int *error_no, char *sqlstate)
+php_mysqlnd_read_error_from_line(const zend_uchar * const buf, const size_t buf_len,
+ char *error, const size_t error_buf_len,
+ unsigned int *error_no, char *sqlstate)
{
- zend_uchar *p = buf;
- int error_msg_len= 0;
+ const zend_uchar *p = buf;
+ size_t error_msg_len = 0;
DBG_ENTER("php_mysqlnd_read_error_from_line");
php_mysqlnd_greet_read(void * _packet)
{
zend_uchar buf[2048];
- zend_uchar *p = buf;
- zend_uchar *begin = buf;
- zend_uchar *pad_start = NULL;
+ const zend_uchar * p = buf;
+ const zend_uchar * const begin = buf;
+ const zend_uchar * pad_start = NULL;
MYSQLND_PACKET_GREET *packet= (MYSQLND_PACKET_GREET *) _packet;
MYSQLND_ERROR_INFO * error_info = packet->header.error_info;
MYSQLND_PFC * pfc = packet->header.protocol_frame_codec;
{
zend_uchar buffer[AUTH_WRITE_BUFFER_LEN];
zend_uchar *p = buffer + MYSQLND_HEADER_SIZE; /* start after the header */
- int len;
+ size_t len;
MYSQLND_PACKET_AUTH * packet= (MYSQLND_PACKET_AUTH *) _packet;
MYSQLND_CONN_DATA * conn = packet->header.conn;
MYSQLND_ERROR_INFO * error_info = packet->header.error_info;
}
if (packet->auth_plugin_name) {
- size_t len = MIN(strlen(packet->auth_plugin_name), sizeof(buffer) - (p - buffer) - 1);
+ len = MIN(strlen(packet->auth_plugin_name), sizeof(buffer) - (p - buffer) - 1);
memcpy(p, packet->auth_plugin_name, len);
p+= len;
*p++= '\0';
zend_uchar local_buf[AUTH_RESP_BUFFER_SIZE];
size_t buf_len = vio->cmd_buffer.buffer? vio->cmd_buffer.length: AUTH_RESP_BUFFER_SIZE;
zend_uchar *buf = vio->cmd_buffer.buffer? (zend_uchar *) vio->cmd_buffer.buffer : local_buf;
- zend_uchar *p = buf;
- zend_uchar *begin = buf;
- zend_ulong i;
+ const zend_uchar * p = buf;
+ const zend_uchar * const begin = buf;
DBG_ENTER("php_mysqlnd_auth_response_read");
DBG_INF_FMT("Server salt : [%d][%.*s]", packet->new_auth_protocol_data_len, packet->new_auth_protocol_data_len, packet->new_auth_protocol_data);
}
} else {
+ zend_ulong net_len;
/* Everything was fine! */
packet->affected_rows = php_mysqlnd_net_field_length_ll(&p);
BAIL_IF_NO_MORE_DATA;
BAIL_IF_NO_MORE_DATA;
/* There is a message */
- if (packet->header.size > (size_t) (p - buf) && (i = php_mysqlnd_net_field_length(&p))) {
- packet->message_len = MIN(i, buf_len - (p - begin));
+ if (packet->header.size > (size_t) (p - buf) && (net_len = php_mysqlnd_net_field_length(&p))) {
+ packet->message_len = MIN(net_len, buf_len - (p - begin));
packet->message = mnd_pestrndup((char *)p, packet->message_len, FALSE);
} else {
packet->message = NULL;
MYSQLND_STATS * stats = packet->header.stats;
MYSQLND_CONNECTION_STATE * connection_state = packet->header.connection_state;
zend_uchar * buffer = vio->cmd_buffer.length >= packet->auth_data_len? vio->cmd_buffer.buffer : mnd_emalloc(packet->auth_data_len);
- zend_uchar *p = buffer + MYSQLND_HEADER_SIZE; /* start after the header */
+ zend_uchar * p = buffer + MYSQLND_HEADER_SIZE; /* start after the header */
DBG_ENTER("php_mysqlnd_change_auth_response_write");
MYSQLND_CONNECTION_STATE * connection_state = packet->header.connection_state;
zend_uchar local_buf[OK_BUFFER_SIZE];
size_t buf_len = vio->cmd_buffer.buffer? vio->cmd_buffer.length : OK_BUFFER_SIZE;
- zend_uchar *buf = vio->cmd_buffer.buffer? (zend_uchar *) vio->cmd_buffer.buffer : local_buf;
- zend_uchar *p = buf;
- zend_uchar *begin = buf;
- zend_ulong i;
+ zend_uchar * buf = vio->cmd_buffer.buffer? (zend_uchar *) vio->cmd_buffer.buffer : local_buf;
+ const zend_uchar * p = buf;
+ const zend_uchar * const begin = buf;
+ zend_ulong net_len;
DBG_ENTER("php_mysqlnd_ok_read");
BAIL_IF_NO_MORE_DATA;
/* There is a message */
- if (packet->header.size > (size_t) (p - buf) && (i = php_mysqlnd_net_field_length(&p))) {
- packet->message_len = MIN(i, buf_len - (p - begin));
+ if (packet->header.size > (size_t) (p - buf) && (net_len = php_mysqlnd_net_field_length(&p))) {
+ packet->message_len = MIN(net_len, buf_len - (p - begin));
packet->message = mnd_pestrndup((char *)p, packet->message_len, FALSE);
} else {
packet->message = NULL;
MYSQLND_STATS * stats = packet->header.stats;
MYSQLND_CONNECTION_STATE * connection_state = packet->header.connection_state;
size_t buf_len = vio->cmd_buffer.length;
- zend_uchar *buf = (zend_uchar *) vio->cmd_buffer.buffer;
- zend_uchar *p = buf;
- zend_uchar *begin = buf;
+ zend_uchar * buf = (zend_uchar *) vio->cmd_buffer.buffer;
+ const zend_uchar * p = buf;
+ const zend_uchar * const begin = buf;
DBG_ENTER("php_mysqlnd_eof_read");
MYSQLND_CONNECTION_STATE * connection_state = packet->header.connection_state;
enum_func_status ret = PASS;
size_t buf_len = vio->cmd_buffer.length;
- zend_uchar *buf = (zend_uchar *) vio->cmd_buffer.buffer;
- zend_uchar *p = buf;
- zend_uchar *begin = buf;
+ zend_uchar * buf = (zend_uchar *) vio->cmd_buffer.buffer;
+ const zend_uchar * p = buf;
+ const zend_uchar * const begin = buf;
size_t len;
DBG_ENTER("php_mysqlnd_rset_header_read");
MYSQLND_STATS * stats = packet->header.stats;
MYSQLND_CONNECTION_STATE * connection_state = packet->header.connection_state;
size_t buf_len = vio->cmd_buffer.length, total_len = 0;
- zend_uchar *buf = (zend_uchar *) vio->cmd_buffer.buffer;
- zend_uchar *p = buf;
- zend_uchar *begin = buf;
+ zend_uchar * buf = (zend_uchar *) vio->cmd_buffer.buffer;
+ const zend_uchar * p = buf;
+ const zend_uchar * const begin = buf;
char *root_ptr;
zend_ulong len;
MYSQLND_FIELD *meta;
zend_bool as_int_or_float, MYSQLND_STATS * stats)
{
unsigned int i;
- zend_uchar *p = row_buffer->ptr;
- zend_uchar *null_ptr, bit;
+ const zend_uchar * p = row_buffer->ptr;
+ const zend_uchar * null_ptr;
+ zend_uchar bit;
zval *current_field, *end_field, *start_field;
DBG_ENTER("php_mysqlnd_rowp_read_binary_protocol");
for (i = 0, current_field = start_field; current_field < end_field; current_field++, i++) {
enum_mysqlnd_collected_stats statistic;
- zend_uchar * orig_p = p;
+ const zend_uchar * orig_p = p;
DBG_INF_FMT("Into zval=%p decoding column %u [%s.%s.%s] type=%u field->flags&unsigned=%u flags=%u is_bit=%u",
current_field, i,
for (i = 0, current_field = start_field; current_field < end_field; current_field++, i++) {
/* php_mysqlnd_net_field_length() call should be after *this_field_len_pos = p; */
- zend_ulong len = php_mysqlnd_net_field_length(&p);
+ const zend_ulong len = php_mysqlnd_net_field_length((const zend_uchar **) &p);
/* NULL or NOT NULL, this is the question! */
if (len == MYSQLND_NULL_LENGTH) {
Definitely not nice, _hackish_ :(, but works.
*/
zend_uchar *start = bit_area;
- ps_fetch_from_1_to_8_bytes(current_field, &(fields_metadata[i]), 0, &p, len);
+ ps_fetch_from_1_to_8_bytes(current_field, &(fields_metadata[i]), 0, (const zend_uchar **) &p, len);
/*
We have advanced in ps_fetch_from_1_to_8_bytes. We should go back because
later in this function there will be an advancement.
size_t buf_len = vio->cmd_buffer.length;
zend_uchar *buf = (zend_uchar *) vio->cmd_buffer.buffer;
zend_uchar *p = buf;
- zend_uchar *begin = buf;
+ const zend_uchar * const begin = buf;
unsigned int data_size;
DBG_ENTER("php_mysqlnd_prepare_read");
size_t buf_len = vio->cmd_buffer.length;
zend_uchar *buf = (zend_uchar *) vio->cmd_buffer.buffer;
zend_uchar *p = buf;
- zend_uchar *begin = buf;
+ const zend_uchar * const begin = buf;
DBG_ENTER("php_mysqlnd_chg_user_read");
MYSQLND_CONNECTION_STATE * connection_state = packet->header.connection_state;
zend_uchar buf[SHA256_PK_REQUEST_RESP_BUFFER_SIZE];
zend_uchar *p = buf;
- zend_uchar *begin = buf;
+ const zend_uchar * const begin = buf;
DBG_ENTER("php_mysqlnd_sha256_pk_request_response_read");