Lines Matching refs:stmt
38 static void mysqlnd_stmt_separate_result_bind(MYSQLND_STMT * const stmt);
41 const MYSQLND_STMT_DATA *stmt, unsigned max_rows) in mysqlnd_stmt_send_cursor_fetch_command() argument
43 MYSQLND_CONN_DATA *conn = stmt->conn; in mysqlnd_stmt_send_cursor_fetch_command()
47 int4store(buf, stmt->stmt_id); in mysqlnd_stmt_send_cursor_fetch_command()
51 COPY_CLIENT_ERROR(stmt->error_info, *conn->error_info); in mysqlnd_stmt_send_cursor_fetch_command()
57 static bool mysqlnd_stmt_check_state(const MYSQLND_STMT_DATA *stmt) in mysqlnd_stmt_check_state() argument
59 const MYSQLND_CONN_DATA *conn = stmt->conn; in mysqlnd_stmt_check_state()
60 if (stmt->state != MYSQLND_STMT_WAITING_USE_OR_STORE) { in mysqlnd_stmt_check_state()
63 if (stmt->cursor_exists) { in mysqlnd_stmt_check_state()
75 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
76 MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL; in MYSQLND_METHOD()
80 if (!stmt || !conn || !stmt->result) { in MYSQLND_METHOD()
83 DBG_INF_FMT("stmt=" ZEND_ULONG_FMT, stmt->stmt_id); in MYSQLND_METHOD()
86 if (!stmt->field_count) { in MYSQLND_METHOD()
91 if (!mysqlnd_stmt_check_state(stmt)) { in MYSQLND_METHOD()
92 …SET_CLIENT_ERROR(stmt->error_info, CR_COMMANDS_OUT_OF_SYNC, UNKNOWN_SQLSTATE, mysqlnd_out_of_sync); in MYSQLND_METHOD()
96 stmt->default_rset_handler = s->m->store_result; in MYSQLND_METHOD()
98 SET_EMPTY_ERROR(stmt->error_info); in MYSQLND_METHOD()
102 if (stmt->cursor_exists) { in MYSQLND_METHOD()
103 if (mysqlnd_stmt_send_cursor_fetch_command(stmt, -1) == FAIL) { in MYSQLND_METHOD()
108 result = stmt->result; in MYSQLND_METHOD()
112 result->stored_data = mysqlnd_result_buffered_init(result, result->field_count, stmt); in MYSQLND_METHOD()
124 UPSERT_STATUS_SET_AFFECTED_ROWS(stmt->upsert_status, stmt->result->stored_data->row_count); in MYSQLND_METHOD()
126 stmt->state = MYSQLND_STMT_USE_OR_STORE_CALLED; in MYSQLND_METHOD()
129 COPY_CLIENT_ERROR(stmt->error_info, result->stored_data->error_info); in MYSQLND_METHOD()
130 stmt->result->m.free_result_contents(stmt->result); in MYSQLND_METHOD()
131 stmt->result = NULL; in MYSQLND_METHOD()
132 stmt->state = MYSQLND_STMT_PREPARED; in MYSQLND_METHOD()
145 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
146 MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL; in MYSQLND_METHOD()
150 if (!stmt || !conn || !stmt->result) { in MYSQLND_METHOD()
153 DBG_INF_FMT("stmt=" ZEND_ULONG_FMT, stmt->stmt_id); in MYSQLND_METHOD()
156 if (!stmt->field_count) { in MYSQLND_METHOD()
161 if (!mysqlnd_stmt_check_state(stmt)) { in MYSQLND_METHOD()
162 …SET_CLIENT_ERROR(stmt->error_info, CR_COMMANDS_OUT_OF_SYNC, UNKNOWN_SQLSTATE, mysqlnd_out_of_sync); in MYSQLND_METHOD()
166 SET_EMPTY_ERROR(stmt->error_info); in MYSQLND_METHOD()
170 if (stmt->cursor_exists) { in MYSQLND_METHOD()
171 if (mysqlnd_stmt_send_cursor_fetch_command(stmt, -1) == FAIL) { in MYSQLND_METHOD()
177 result = conn->m->result_init(stmt->result->field_count); in MYSQLND_METHOD()
183 result->meta = stmt->result->meta->m->clone_metadata(result, stmt->result->meta); in MYSQLND_METHOD()
189 if (result->m.store_result(result, conn, stmt)) { in MYSQLND_METHOD()
190 UPSERT_STATUS_SET_AFFECTED_ROWS(stmt->upsert_status, result->stored_data->row_count); in MYSQLND_METHOD()
191 stmt->state = MYSQLND_STMT_PREPARED; in MYSQLND_METHOD()
194 COPY_CLIENT_ERROR(stmt->error_info, *conn->error_info); in MYSQLND_METHOD()
195 stmt->state = MYSQLND_STMT_PREPARED; in MYSQLND_METHOD()
213 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
214 MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL; in MYSQLND_METHOD()
217 …DBG_RETURN((stmt && conn && (conn->m->get_server_status(conn) & SERVER_MORE_RESULTS_EXISTS))? TRUE… in MYSQLND_METHOD()
226 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
227 MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL; in MYSQLND_METHOD()
230 if (!stmt || !conn || !stmt->result) { in MYSQLND_METHOD()
233 DBG_INF_FMT("stmt=" ZEND_ULONG_FMT, stmt->stmt_id); in MYSQLND_METHOD()
255 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in mysqlnd_stmt_skip_metadata() local
256 MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL; in mysqlnd_stmt_skip_metadata()
264 if (!stmt || !conn) { in mysqlnd_stmt_skip_metadata()
271 DBG_INF_FMT("stmt=" ZEND_ULONG_FMT, stmt->stmt_id); in mysqlnd_stmt_skip_metadata()
278 for (;i < stmt->param_count; i++) { in mysqlnd_stmt_skip_metadata()
296 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in mysqlnd_stmt_read_prepare_response() local
297 MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL; in mysqlnd_stmt_read_prepare_response()
302 if (!stmt || !conn) { in mysqlnd_stmt_read_prepare_response()
305 DBG_INF_FMT("stmt=" ZEND_ULONG_FMT, stmt->stmt_id); in mysqlnd_stmt_read_prepare_response()
314 COPY_CLIENT_ERROR(stmt->error_info, prepare_resp.error_info); in mysqlnd_stmt_read_prepare_response()
319 stmt->stmt_id = prepare_resp.stmt_id; in mysqlnd_stmt_read_prepare_response()
321 UPSERT_STATUS_SET_AFFECTED_ROWS(stmt->upsert_status, 0); /* be like libmysql */ in mysqlnd_stmt_read_prepare_response()
322 stmt->field_count = conn->field_count = prepare_resp.field_count; in mysqlnd_stmt_read_prepare_response()
323 stmt->param_count = prepare_resp.param_count; in mysqlnd_stmt_read_prepare_response()
336 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in mysqlnd_stmt_prepare_read_eof() local
337 MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL; in mysqlnd_stmt_prepare_read_eof()
342 if (!stmt || !conn) { in mysqlnd_stmt_prepare_read_eof()
345 DBG_INF_FMT("stmt=" ZEND_ULONG_FMT, stmt->stmt_id); in mysqlnd_stmt_prepare_read_eof()
349 if (stmt->result) { in mysqlnd_stmt_prepare_read_eof()
350 stmt->result->m.free_result_contents(stmt->result); in mysqlnd_stmt_prepare_read_eof()
356 memset(stmt, 0, sizeof(MYSQLND_STMT_DATA)); in mysqlnd_stmt_prepare_read_eof()
357 stmt->state = MYSQLND_STMT_INITTED; in mysqlnd_stmt_prepare_read_eof()
360 UPSERT_STATUS_SET_SERVER_STATUS(stmt->upsert_status, fields_eof.server_status); in mysqlnd_stmt_prepare_read_eof()
361 UPSERT_STATUS_SET_WARNINGS(stmt->upsert_status, fields_eof.warning_count); in mysqlnd_stmt_prepare_read_eof()
362 stmt->state = MYSQLND_STMT_PREPARED; in mysqlnd_stmt_prepare_read_eof()
374 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
375 MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL; in MYSQLND_METHOD()
378 if (!stmt || !conn) { in MYSQLND_METHOD()
381 DBG_INF_FMT("stmt=" ZEND_ULONG_FMT, stmt->stmt_id); in MYSQLND_METHOD()
384 UPSERT_STATUS_SET_AFFECTED_ROWS_TO_ERROR(stmt->upsert_status); in MYSQLND_METHOD()
387 SET_EMPTY_ERROR(stmt->error_info); in MYSQLND_METHOD()
390 if (stmt->state > MYSQLND_STMT_INITTED) { in MYSQLND_METHOD()
409 stmt_to_prepare = stmt; in MYSQLND_METHOD()
410 stmt = tmp_swap_data; in MYSQLND_METHOD()
421 COPY_CLIENT_ERROR(stmt->error_info, *conn->error_info); in MYSQLND_METHOD()
430 if (stmt->param_count) { in MYSQLND_METHOD()
443 if (stmt->field_count) { in MYSQLND_METHOD()
444 MYSQLND_RES * result = conn->m->result_init(stmt->field_count); in MYSQLND_METHOD()
450 stmt->result = result; in MYSQLND_METHOD()
463 stmt->state = MYSQLND_STMT_PREPARED; in MYSQLND_METHOD()
478 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in mysqlnd_stmt_execute_parse_response() local
479 MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL; in mysqlnd_stmt_execute_parse_response()
483 if (!stmt || !conn) { in mysqlnd_stmt_execute_parse_response()
490 COPY_CLIENT_ERROR(stmt->error_info, *conn->error_info); in mysqlnd_stmt_execute_parse_response()
491 UPSERT_STATUS_RESET(stmt->upsert_status); in mysqlnd_stmt_execute_parse_response()
492 …UPSERT_STATUS_SET_AFFECTED_ROWS(stmt->upsert_status, UPSERT_STATUS_GET_AFFECTED_ROWS(conn->upsert_… in mysqlnd_stmt_execute_parse_response()
496 stmt->state = MYSQLND_STMT_PREPARED; in mysqlnd_stmt_execute_parse_response()
497 stmt->send_types_to_server = 1; in mysqlnd_stmt_execute_parse_response()
506 SET_EMPTY_ERROR(stmt->error_info); in mysqlnd_stmt_execute_parse_response()
508 UPSERT_STATUS_SET_WARNINGS(stmt->upsert_status, UPSERT_STATUS_GET_WARNINGS(conn->upsert_status)); in mysqlnd_stmt_execute_parse_response()
509 …UPSERT_STATUS_SET_AFFECTED_ROWS(stmt->upsert_status, UPSERT_STATUS_GET_AFFECTED_ROWS(conn->upsert_… in mysqlnd_stmt_execute_parse_response()
510 …UPSERT_STATUS_SET_SERVER_STATUS(stmt->upsert_status, UPSERT_STATUS_GET_SERVER_STATUS(conn->upsert_… in mysqlnd_stmt_execute_parse_response()
511 …UPSERT_STATUS_SET_LAST_INSERT_ID(stmt->upsert_status, UPSERT_STATUS_GET_LAST_INSERT_ID(conn->upser… in mysqlnd_stmt_execute_parse_response()
513 stmt->state = MYSQLND_STMT_EXECUTED; in mysqlnd_stmt_execute_parse_response()
519 stmt->result->type = MYSQLND_RES_PS_BUF; in mysqlnd_stmt_execute_parse_response()
520 if (!stmt->result->conn) { in mysqlnd_stmt_execute_parse_response()
525 stmt->result->conn = conn->m->get_reference(conn); in mysqlnd_stmt_execute_parse_response()
531 if (stmt->result_bind && conn->field_count != stmt->field_count) { in mysqlnd_stmt_execute_parse_response()
532 if (conn->field_count < stmt->field_count) { in mysqlnd_stmt_execute_parse_response()
534 for (unsigned i = conn->field_count; i < stmt->field_count; i++) { in mysqlnd_stmt_execute_parse_response()
535 zval_ptr_dtor(&stmt->result_bind[i].zv); in mysqlnd_stmt_execute_parse_response()
538 stmt->result_bind = in mysqlnd_stmt_execute_parse_response()
539 mnd_erealloc(stmt->result_bind, conn->field_count * sizeof(MYSQLND_RESULT_BIND)); in mysqlnd_stmt_execute_parse_response()
540 if (conn->field_count > stmt->field_count) { in mysqlnd_stmt_execute_parse_response()
542 for (unsigned i = stmt->field_count; i < conn->field_count; i++) { in mysqlnd_stmt_execute_parse_response()
543 ZVAL_UNDEF(&stmt->result_bind[i].zv); in mysqlnd_stmt_execute_parse_response()
544 stmt->result_bind[i].bound = false; in mysqlnd_stmt_execute_parse_response()
549 stmt->field_count = stmt->result->field_count = conn->field_count; in mysqlnd_stmt_execute_parse_response()
550 if (stmt->field_count) { in mysqlnd_stmt_execute_parse_response()
551 stmt->state = MYSQLND_STMT_WAITING_USE_OR_STORE; in mysqlnd_stmt_execute_parse_response()
557 DBG_INF_FMT("server_status=%u cursor=%u", UPSERT_STATUS_GET_SERVER_STATUS(stmt->upsert_status), in mysqlnd_stmt_execute_parse_response()
558 UPSERT_STATUS_GET_SERVER_STATUS(stmt->upsert_status) & SERVER_STATUS_CURSOR_EXISTS); in mysqlnd_stmt_execute_parse_response()
560 if (stmt->flags & CURSOR_TYPE_READ_ONLY) { in mysqlnd_stmt_execute_parse_response()
561 if (UPSERT_STATUS_GET_SERVER_STATUS(stmt->upsert_status) & SERVER_STATUS_CURSOR_EXISTS) { in mysqlnd_stmt_execute_parse_response()
563 stmt->cursor_exists = TRUE; in mysqlnd_stmt_execute_parse_response()
566 stmt->default_rset_handler = s->m->use_result; in mysqlnd_stmt_execute_parse_response()
581 stmt->default_rset_handler = s->m->store_result; in mysqlnd_stmt_execute_parse_response()
587 stmt->default_rset_handler = s->m->use_result; in mysqlnd_stmt_execute_parse_response()
593 if (UPSERT_STATUS_GET_SERVER_STATUS(stmt->upsert_status) & SERVER_PS_OUT_PARAMS) { in mysqlnd_stmt_execute_parse_response()
601 …%u cursor=%u", UPSERT_STATUS_GET_SERVER_STATUS(stmt->upsert_status), UPSERT_STATUS_GET_SERVER_STAT… in mysqlnd_stmt_execute_parse_response()
603 …if (ret == PASS && conn->last_query_type == QUERY_UPSERT && UPSERT_STATUS_GET_AFFECTED_ROWS(stmt->… in mysqlnd_stmt_execute_parse_response()
604 …_W_VALUE(conn->stats, STAT_ROWS_AFFECTED_PS, UPSERT_STATUS_GET_AFFECTED_ROWS(stmt->upsert_status)); in mysqlnd_stmt_execute_parse_response()
632 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
633 MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL; in MYSQLND_METHOD()
640 if (!stmt || !conn) { in MYSQLND_METHOD()
643 DBG_INF_FMT("stmt=" ZEND_ULONG_FMT, stmt->stmt_id); in MYSQLND_METHOD()
645 UPSERT_STATUS_SET_AFFECTED_ROWS_TO_ERROR(stmt->upsert_status); in MYSQLND_METHOD()
648 if (stmt->result && stmt->state >= MYSQLND_STMT_PREPARED && stmt->field_count) { in MYSQLND_METHOD()
657 if (stmt->result) { in MYSQLND_METHOD()
658 stmt->result->m.free_result_buffers(stmt->result); in MYSQLND_METHOD()
661 stmt->state = MYSQLND_STMT_PREPARED; in MYSQLND_METHOD()
662 } else if (stmt->state < MYSQLND_STMT_PREPARED) { in MYSQLND_METHOD()
664 …SET_CLIENT_ERROR(stmt->error_info, CR_COMMANDS_OUT_OF_SYNC, UNKNOWN_SQLSTATE, mysqlnd_out_of_sync); in MYSQLND_METHOD()
669 if (stmt->param_count) { in MYSQLND_METHOD()
671 if (!stmt->param_bind) { in MYSQLND_METHOD()
672 …SET_CLIENT_ERROR(stmt->error_info, CR_PARAMS_NOT_BOUND, UNKNOWN_SQLSTATE, "No data supplied for pa… in MYSQLND_METHOD()
676 for (i = 0; i < stmt->param_count; i++) { in MYSQLND_METHOD()
677 if (Z_ISUNDEF(stmt->param_bind[i].zv)) { in MYSQLND_METHOD()
685 SET_CLIENT_ERROR(stmt->error_info, CR_PARAMS_NOT_BOUND, UNKNOWN_SQLSTATE, msg); in MYSQLND_METHOD()
699 …SET_CLIENT_ERROR(stmt->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, "Couldn't generate the requ… in MYSQLND_METHOD()
707 COPY_CLIENT_ERROR(stmt->error_info, *conn->error_info); in MYSQLND_METHOD()
711 stmt->execute_count++; in MYSQLND_METHOD()
722 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
723 MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL; in MYSQLND_METHOD()
727 if (!stmt || !conn || !stmt->result) { in MYSQLND_METHOD()
730 DBG_INF_FMT("stmt=" ZEND_ULONG_FMT, stmt->stmt_id); in MYSQLND_METHOD()
732 if (!stmt->field_count || !mysqlnd_stmt_check_state(stmt)) { in MYSQLND_METHOD()
738 SET_EMPTY_ERROR(stmt->error_info); in MYSQLND_METHOD()
741 result = stmt->result; in MYSQLND_METHOD()
743 result->m.use_result(stmt->result, stmt); in MYSQLND_METHOD()
744 if (stmt->cursor_exists) { in MYSQLND_METHOD()
747 stmt->state = MYSQLND_STMT_USE_OR_STORE_CALLED; in MYSQLND_METHOD()
760 MYSQLND_STMT_DATA * stmt = result->unbuf->stmt; in mysqlnd_fetch_stmt_row_cursor() local
761 MYSQLND_CONN_DATA * conn = stmt->conn; in mysqlnd_fetch_stmt_row_cursor()
767 if (!stmt->conn || !result->conn) { in mysqlnd_fetch_stmt_row_cursor()
771 DBG_INF_FMT("stmt=" ZEND_ULONG_FMT " flags=%u", stmt->stmt_id, flags); in mysqlnd_fetch_stmt_row_cursor()
773 if (stmt->state < MYSQLND_STMT_USER_FETCHING) { in mysqlnd_fetch_stmt_row_cursor()
783 SET_EMPTY_ERROR(stmt->error_info); in mysqlnd_fetch_stmt_row_cursor()
787 if (mysqlnd_stmt_send_cursor_fetch_command(stmt, 1) == FAIL) { in mysqlnd_fetch_stmt_row_cursor()
794 UPSERT_STATUS_RESET(stmt->upsert_status); in mysqlnd_fetch_stmt_row_cursor()
824 UPSERT_STATUS_SET_WARNINGS(stmt->upsert_status, row_packet->warning_count); in mysqlnd_fetch_stmt_row_cursor()
827 UPSERT_STATUS_SET_SERVER_STATUS(stmt->upsert_status, row_packet->server_status); in mysqlnd_fetch_stmt_row_cursor()
832 UPSERT_STATUS_SET_WARNINGS(stmt->upsert_status, row_packet->warning_count); in mysqlnd_fetch_stmt_row_cursor()
835 UPSERT_STATUS_SET_SERVER_STATUS(stmt->upsert_status, row_packet->server_status); in mysqlnd_fetch_stmt_row_cursor()
854 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
855 MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL; in MYSQLND_METHOD()
858 if (!stmt || !stmt->conn) { in MYSQLND_METHOD()
861 DBG_INF_FMT("stmt=" ZEND_ULONG_FMT, stmt->stmt_id); in MYSQLND_METHOD()
863 if (!stmt->result || stmt->state < MYSQLND_STMT_WAITING_USE_OR_STORE) { in MYSQLND_METHOD()
864 …SET_CLIENT_ERROR(stmt->error_info, CR_COMMANDS_OUT_OF_SYNC, UNKNOWN_SQLSTATE, mysqlnd_out_of_sync); in MYSQLND_METHOD()
867 } else if (stmt->state == MYSQLND_STMT_WAITING_USE_OR_STORE) { in MYSQLND_METHOD()
870 stmt->default_rset_handler(s); in MYSQLND_METHOD()
872 stmt->state = MYSQLND_STMT_USER_FETCHING; in MYSQLND_METHOD()
874 SET_EMPTY_ERROR(stmt->error_info); in MYSQLND_METHOD()
877 if (stmt->result_bind) { in MYSQLND_METHOD()
879 ret = stmt->result->m.fetch_row(stmt->result, &row_data, 0, fetched_anything); in MYSQLND_METHOD()
881 unsigned field_count = stmt->result->field_count; in MYSQLND_METHOD()
883 zval *resultzv = &stmt->result_bind[i].zv; in MYSQLND_METHOD()
884 if (stmt->result_bind[i].bound == TRUE) { in MYSQLND_METHOD()
893 ret = stmt->result->m.fetch_row(stmt->result, NULL, 0, fetched_anything); in MYSQLND_METHOD()
905 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
906 MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL; in MYSQLND_METHOD()
909 if (!stmt || !conn) { in MYSQLND_METHOD()
912 DBG_INF_FMT("stmt=" ZEND_ULONG_FMT, stmt->stmt_id); in MYSQLND_METHOD()
914 SET_EMPTY_ERROR(stmt->error_info); in MYSQLND_METHOD()
917 if (stmt->stmt_id) { in MYSQLND_METHOD()
918 MYSQLND_CONN_DATA * conn = stmt->conn; in MYSQLND_METHOD()
919 if (stmt->param_bind) { in MYSQLND_METHOD()
923 for (i = 0; i < stmt->param_count; i++) { in MYSQLND_METHOD()
924 if (stmt->param_bind[i].flags & MYSQLND_PARAM_BIND_BLOB_USED) { in MYSQLND_METHOD()
925 stmt->param_bind[i].flags &= ~MYSQLND_PARAM_BIND_BLOB_USED; in MYSQLND_METHOD()
939 size_t stmt_id = stmt->stmt_id; in MYSQLND_METHOD()
941 ret = stmt->conn->command->stmt_reset(stmt->conn, stmt_id); in MYSQLND_METHOD()
943 COPY_CLIENT_ERROR(stmt->error_info, *conn->error_info); in MYSQLND_METHOD()
946 *stmt->upsert_status = *conn->upsert_status; in MYSQLND_METHOD()
959 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
960 MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL; in MYSQLND_METHOD()
963 if (!stmt || !conn) { in MYSQLND_METHOD()
966 DBG_INF_FMT("stmt=" ZEND_ULONG_FMT, stmt->stmt_id); in MYSQLND_METHOD()
968 if (stmt->stmt_id) { in MYSQLND_METHOD()
975 if (stmt->state == MYSQLND_STMT_WAITING_USE_OR_STORE) { in MYSQLND_METHOD()
977 stmt->default_rset_handler(s); in MYSQLND_METHOD()
978 stmt->state = MYSQLND_STMT_USER_FETCHING; in MYSQLND_METHOD()
981 if (stmt->result) { in MYSQLND_METHOD()
983 stmt->result->m.skip_result(stmt->result); in MYSQLND_METHOD()
999 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
1000 MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL; in MYSQLND_METHOD()
1004 if (!stmt || !conn) { in MYSQLND_METHOD()
1007 …DBG_INF_FMT("stmt=" ZEND_ULONG_FMT " param_no=%u data_len=" ZEND_ULONG_FMT, stmt->stmt_id, param_n… in MYSQLND_METHOD()
1009 SET_EMPTY_ERROR(stmt->error_info); in MYSQLND_METHOD()
1012 if (stmt->state < MYSQLND_STMT_PREPARED) { in MYSQLND_METHOD()
1013 …SET_CLIENT_ERROR(stmt->error_info, CR_NO_PREPARE_STMT, UNKNOWN_SQLSTATE, mysqlnd_stmt_not_prepared… in MYSQLND_METHOD()
1017 if (!stmt->param_bind) { in MYSQLND_METHOD()
1018 …SET_CLIENT_ERROR(stmt->error_info, CR_COMMANDS_OUT_OF_SYNC, UNKNOWN_SQLSTATE, mysqlnd_out_of_sync); in MYSQLND_METHOD()
1022 if (param_no >= stmt->param_count) { in MYSQLND_METHOD()
1023 …SET_CLIENT_ERROR(stmt->error_info, CR_INVALID_PARAMETER_NO, UNKNOWN_SQLSTATE, "Invalid parameter n… in MYSQLND_METHOD()
1027 if (stmt->param_bind[param_no].type != MYSQL_TYPE_LONG_BLOB) { in MYSQLND_METHOD()
1028 …SET_CLIENT_ERROR(stmt->error_info, CR_INVALID_BUFFER_USE, UNKNOWN_SQLSTATE, mysqlnd_not_bound_as_b… in MYSQLND_METHOD()
1037 stmt->param_bind[param_no].flags |= MYSQLND_PARAM_BIND_BLOB_USED; in MYSQLND_METHOD()
1039 int4store(cmd_buf, stmt->stmt_id); in MYSQLND_METHOD()
1049 COPY_CLIENT_ERROR(stmt->error_info, *conn->error_info); in MYSQLND_METHOD()
1056 SET_OOM_ERROR(stmt->error_info); in MYSQLND_METHOD()
1084 SET_CLIENT_ERROR(stmt->error_info, CR_CONNECTION_ERROR, UNKNOWN_SQLSTATE, in MYSQLND_METHOD()
1101 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
1102 MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL; in MYSQLND_METHOD()
1105 if (!stmt || !conn) { in MYSQLND_METHOD()
1108 DBG_INF_FMT("stmt=" ZEND_ULONG_FMT " param_count=%u", stmt->stmt_id, stmt->param_count); in MYSQLND_METHOD()
1110 if (stmt->state < MYSQLND_STMT_PREPARED) { in MYSQLND_METHOD()
1111 …SET_CLIENT_ERROR(stmt->error_info, CR_NO_PREPARE_STMT, UNKNOWN_SQLSTATE, mysqlnd_stmt_not_prepared… in MYSQLND_METHOD()
1119 SET_EMPTY_ERROR(stmt->error_info); in MYSQLND_METHOD()
1122 if (stmt->param_count) { in MYSQLND_METHOD()
1126 …SET_CLIENT_ERROR(stmt->error_info, CR_COMMANDS_OUT_OF_SYNC, UNKNOWN_SQLSTATE, "Re-binding (still) … in MYSQLND_METHOD()
1129 } else if (stmt->param_bind) { in MYSQLND_METHOD()
1135 for (i = 0; i < stmt->param_count; i++) { in MYSQLND_METHOD()
1140 zval_ptr_dtor(&stmt->param_bind[i].zv); in MYSQLND_METHOD()
1142 if (stmt->param_bind != param_bind) { in MYSQLND_METHOD()
1143 s->m->free_parameter_bind(s, stmt->param_bind); in MYSQLND_METHOD()
1147 stmt->param_bind = param_bind; in MYSQLND_METHOD()
1148 for (i = 0; i < stmt->param_count; i++) { in MYSQLND_METHOD()
1150 DBG_INF_FMT("%u is of type %u", i, stmt->param_bind[i].type); in MYSQLND_METHOD()
1153 Z_TRY_ADDREF(stmt->param_bind[i].zv); in MYSQLND_METHOD()
1154 stmt->param_bind[i].flags = 0; in MYSQLND_METHOD()
1155 if (stmt->param_bind[i].type == MYSQL_TYPE_LONG_BLOB) { in MYSQLND_METHOD()
1156 stmt->param_bind[i].flags &= ~MYSQLND_PARAM_BIND_BLOB_USED; in MYSQLND_METHOD()
1159 stmt->send_types_to_server = 1; in MYSQLND_METHOD()
1160 } else if (param_bind && param_bind != stmt->param_bind) { in MYSQLND_METHOD()
1174 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
1175 MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL; in MYSQLND_METHOD()
1178 if (!stmt || !conn) { in MYSQLND_METHOD()
1181 …"stmt=" ZEND_ULONG_FMT " param_no=%u param_count=%u type=%u", stmt->stmt_id, param_no, stmt->param… in MYSQLND_METHOD()
1183 if (stmt->state < MYSQLND_STMT_PREPARED) { in MYSQLND_METHOD()
1184 …SET_CLIENT_ERROR(stmt->error_info, CR_NO_PREPARE_STMT, UNKNOWN_SQLSTATE, mysqlnd_stmt_not_prepared… in MYSQLND_METHOD()
1189 if (param_no >= stmt->param_count) { in MYSQLND_METHOD()
1190 …SET_CLIENT_ERROR(stmt->error_info, CR_INVALID_PARAMETER_NO, UNKNOWN_SQLSTATE, "Invalid parameter n… in MYSQLND_METHOD()
1194 SET_EMPTY_ERROR(stmt->error_info); in MYSQLND_METHOD()
1197 if (stmt->param_count) { in MYSQLND_METHOD()
1198 if (!stmt->param_bind) { in MYSQLND_METHOD()
1199 stmt->param_bind = mnd_ecalloc(stmt->param_count, sizeof(MYSQLND_PARAM_BIND)); in MYSQLND_METHOD()
1200 if (!stmt->param_bind) { in MYSQLND_METHOD()
1210 zval_ptr_dtor(&stmt->param_bind[param_no].zv); in MYSQLND_METHOD()
1213 stmt->param_bind[param_no].flags &= ~MYSQLND_PARAM_BIND_BLOB_USED; in MYSQLND_METHOD()
1215 ZVAL_COPY_VALUE(&stmt->param_bind[param_no].zv, zv); in MYSQLND_METHOD()
1216 stmt->param_bind[param_no].type = type; in MYSQLND_METHOD()
1218 stmt->send_types_to_server = 1; in MYSQLND_METHOD()
1230 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
1231 MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL; in MYSQLND_METHOD()
1234 if (!stmt || !conn) { in MYSQLND_METHOD()
1237 DBG_INF_FMT("stmt=" ZEND_ULONG_FMT " param_count=%u", stmt->stmt_id, stmt->param_count); in MYSQLND_METHOD()
1239 if (stmt->state < MYSQLND_STMT_PREPARED) { in MYSQLND_METHOD()
1240 …SET_CLIENT_ERROR(stmt->error_info, CR_NO_PREPARE_STMT, UNKNOWN_SQLSTATE, mysqlnd_stmt_not_prepared… in MYSQLND_METHOD()
1245 SET_EMPTY_ERROR(stmt->error_info); in MYSQLND_METHOD()
1248 if (stmt->param_count) { in MYSQLND_METHOD()
1249 stmt->send_types_to_server = 1; in MYSQLND_METHOD()
1261 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
1262 MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL; in MYSQLND_METHOD()
1265 if (!stmt || !conn) { in MYSQLND_METHOD()
1268 DBG_INF_FMT("stmt=" ZEND_ULONG_FMT " field_count=%u", stmt->stmt_id, stmt->field_count); in MYSQLND_METHOD()
1270 if (stmt->state < MYSQLND_STMT_PREPARED) { in MYSQLND_METHOD()
1271 …SET_CLIENT_ERROR(stmt->error_info, CR_NO_PREPARE_STMT, UNKNOWN_SQLSTATE, mysqlnd_stmt_not_prepared… in MYSQLND_METHOD()
1279 SET_EMPTY_ERROR(stmt->error_info); in MYSQLND_METHOD()
1282 if (stmt->field_count) { in MYSQLND_METHOD()
1291 stmt->result_bind = result_bind; in MYSQLND_METHOD()
1292 for (i = 0; i < stmt->field_count; i++) { in MYSQLND_METHOD()
1294 Z_TRY_ADDREF(stmt->result_bind[i].zv); in MYSQLND_METHOD()
1296 DBG_INF_FMT("ref of %p = %u", &stmt->result_bind[i].zv, in MYSQLND_METHOD()
1297 Z_REFCOUNTED(stmt->result_bind[i].zv)? Z_REFCOUNT(stmt->result_bind[i].zv) : 0); in MYSQLND_METHOD()
1303 stmt->result_bind[i].bound = TRUE; in MYSQLND_METHOD()
1318 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
1319 MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL; in MYSQLND_METHOD()
1322 if (!stmt || !conn) { in MYSQLND_METHOD()
1325 DBG_INF_FMT("stmt=" ZEND_ULONG_FMT " field_count=%u", stmt->stmt_id, stmt->field_count); in MYSQLND_METHOD()
1327 if (stmt->state < MYSQLND_STMT_PREPARED) { in MYSQLND_METHOD()
1328 …SET_CLIENT_ERROR(stmt->error_info, CR_NO_PREPARE_STMT, UNKNOWN_SQLSTATE, mysqlnd_stmt_not_prepared… in MYSQLND_METHOD()
1333 if (param_no >= stmt->field_count) { in MYSQLND_METHOD()
1334 …SET_CLIENT_ERROR(stmt->error_info, CR_INVALID_PARAMETER_NO, UNKNOWN_SQLSTATE, "Invalid parameter n… in MYSQLND_METHOD()
1339 SET_EMPTY_ERROR(stmt->error_info); in MYSQLND_METHOD()
1342 if (stmt->field_count) { in MYSQLND_METHOD()
1343 if (!stmt->result_bind) { in MYSQLND_METHOD()
1344 stmt->result_bind = mnd_ecalloc(stmt->field_count, sizeof(MYSQLND_RESULT_BIND)); in MYSQLND_METHOD()
1346 if (stmt->result_bind[param_no].bound) { in MYSQLND_METHOD()
1347 zval_ptr_dtor(&stmt->result_bind[param_no].zv); in MYSQLND_METHOD()
1349 ZVAL_NULL(&stmt->result_bind[param_no].zv); in MYSQLND_METHOD()
1350 stmt->result_bind[param_no].bound = TRUE; in MYSQLND_METHOD()
1362 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
1363 return stmt? UPSERT_STATUS_GET_LAST_INSERT_ID(stmt->upsert_status) : 0; in MYSQLND_METHOD()
1372 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
1373 return stmt? UPSERT_STATUS_GET_AFFECTED_ROWS(stmt->upsert_status) : 0; in MYSQLND_METHOD()
1382 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
1383 return stmt && stmt->result? mysqlnd_num_rows(stmt->result):0; in MYSQLND_METHOD()
1392 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
1393 return stmt? UPSERT_STATUS_GET_WARNINGS(stmt->upsert_status) : 0; in MYSQLND_METHOD()
1402 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
1403 return stmt? UPSERT_STATUS_GET_SERVER_STATUS(stmt->upsert_status) : 0; in MYSQLND_METHOD()
1412 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
1413 return stmt? stmt->field_count : 0; in MYSQLND_METHOD()
1422 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
1423 return stmt? stmt->param_count : 0; in MYSQLND_METHOD()
1432 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
1433 return stmt? stmt->error_info->error_no : 0; in MYSQLND_METHOD()
1442 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
1443 return stmt? stmt->error_info->error : 0; in MYSQLND_METHOD()
1452 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
1453 return stmt && stmt->error_info->sqlstate[0] ? stmt->error_info->sqlstate:MYSQLND_SQLSTATE_NULL; in MYSQLND_METHOD()
1462 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
1463 return stmt && stmt->result? stmt->result->m.seek_data(stmt->result, row) : FAIL; in MYSQLND_METHOD()
1472 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
1473 MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL; in MYSQLND_METHOD()
1477 if (!stmt || ! conn) { in MYSQLND_METHOD()
1480 DBG_INF_FMT("stmt=" ZEND_ULONG_FMT " field_count=%u", stmt->stmt_id, stmt->field_count); in MYSQLND_METHOD()
1482 if (!stmt->field_count || !stmt->result || !stmt->result->meta) { in MYSQLND_METHOD()
1494 result_meta = conn->m->result_init(stmt->field_count); in MYSQLND_METHOD()
1499 result_meta->unbuf = mysqlnd_result_unbuffered_init(result_meta, stmt->field_count, stmt); in MYSQLND_METHOD()
1504 result_meta->meta = stmt->result->meta->m->clone_metadata(result_meta, stmt->result->meta); in MYSQLND_METHOD()
1528 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
1530 if (!stmt) { in MYSQLND_METHOD()
1533 DBG_INF_FMT("stmt=" ZEND_ULONG_FMT " attr_type=%u", stmt->stmt_id, attr_type); in MYSQLND_METHOD()
1542 stmt->update_max_length = bval? TRUE:FALSE; in MYSQLND_METHOD()
1548 SET_CLIENT_ERROR(stmt->error_info, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, "Not implemented"); in MYSQLND_METHOD()
1552 stmt->flags = ival; in MYSQLND_METHOD()
1556 SET_CLIENT_ERROR(stmt->error_info, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, "Not implemented"); in MYSQLND_METHOD()
1571 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
1573 if (!stmt) { in MYSQLND_METHOD()
1576 DBG_INF_FMT("stmt=" ZEND_ULONG_FMT " attr_type=%u", stmt->stmt_id, attr_type); in MYSQLND_METHOD()
1580 *(bool *) value = stmt->update_max_length; in MYSQLND_METHOD()
1584 *(unsigned long *) value = stmt->flags; in MYSQLND_METHOD()
1600 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
1601 MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL; in MYSQLND_METHOD()
1604 if (!stmt || !conn) { in MYSQLND_METHOD()
1607 DBG_INF_FMT("stmt=" ZEND_ULONG_FMT, stmt->stmt_id); in MYSQLND_METHOD()
1609 if (!stmt->result) { in MYSQLND_METHOD()
1618 if (stmt->state == MYSQLND_STMT_WAITING_USE_OR_STORE) { in MYSQLND_METHOD()
1621 stmt->default_rset_handler = s->m->use_result; in MYSQLND_METHOD()
1622 stmt->default_rset_handler(s); in MYSQLND_METHOD()
1625 if (stmt->state > MYSQLND_STMT_WAITING_USE_OR_STORE) { in MYSQLND_METHOD()
1628 stmt->result->m.skip_result(stmt->result); in MYSQLND_METHOD()
1636 stmt->result->m.free_result_buffers(stmt->result); in MYSQLND_METHOD()
1639 if (stmt->state > MYSQLND_STMT_PREPARED) { in MYSQLND_METHOD()
1641 stmt->state = MYSQLND_STMT_PREPARED; in MYSQLND_METHOD()
1653 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in mysqlnd_stmt_separate_result_bind() local
1657 if (!stmt) { in mysqlnd_stmt_separate_result_bind()
1660 …"stmt=" ZEND_ULONG_FMT " result_bind=%p field_count=%u", stmt->stmt_id, stmt->result_bind, stmt->f… in mysqlnd_stmt_separate_result_bind()
1662 if (!stmt->result_bind) { in mysqlnd_stmt_separate_result_bind()
1671 for (i = 0; i < stmt->field_count; i++) { in mysqlnd_stmt_separate_result_bind()
1673 if (stmt->result_bind[i].bound == TRUE) { in mysqlnd_stmt_separate_result_bind()
1674 …DBG_INF_FMT("%u has refcount=%u", i, Z_REFCOUNTED(stmt->result_bind[i].zv)? Z_REFCOUNT(stmt->resul… in mysqlnd_stmt_separate_result_bind()
1675 zval_ptr_dtor(&stmt->result_bind[i].zv); in mysqlnd_stmt_separate_result_bind()
1679 s->m->free_result_bind(s, stmt->result_bind); in mysqlnd_stmt_separate_result_bind()
1680 stmt->result_bind = NULL; in mysqlnd_stmt_separate_result_bind()
1691 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
1693 if (!stmt) { in MYSQLND_METHOD()
1703 if (stmt->result) { in MYSQLND_METHOD()
1704 stmt->result->m.free_result(stmt->result, /* implicit */ TRUE); in MYSQLND_METHOD()
1705 stmt->result = NULL; in MYSQLND_METHOD()
1707 zend_llist_clean(&stmt->error_info->error_list); in MYSQLND_METHOD()
1718 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
1720 if (!stmt) { in MYSQLND_METHOD()
1723 …T("stmt=" ZEND_ULONG_FMT " param_bind=%p param_count=%u", stmt->stmt_id, stmt->param_bind, stmt->p… in MYSQLND_METHOD()
1726 if (stmt->param_bind) { in MYSQLND_METHOD()
1733 for (i = 0; i < stmt->param_count; i++) { in MYSQLND_METHOD()
1738 zval_ptr_dtor(&stmt->param_bind[i].zv); in MYSQLND_METHOD()
1740 s->m->free_parameter_bind(s, stmt->param_bind); in MYSQLND_METHOD()
1741 stmt->param_bind = NULL; in MYSQLND_METHOD()
1754 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD_PRIVATE() local
1755 MYSQLND_CONN_DATA * conn = stmt? stmt->conn : NULL; in MYSQLND_METHOD_PRIVATE()
1759 if (!stmt || !conn) { in MYSQLND_METHOD_PRIVATE()
1762 DBG_INF_FMT("stmt=" ZEND_ULONG_FMT, stmt->stmt_id); in MYSQLND_METHOD_PRIVATE()
1764 SET_EMPTY_ERROR(stmt->error_info); in MYSQLND_METHOD_PRIVATE()
1773 if (stmt->state == MYSQLND_STMT_WAITING_USE_OR_STORE) { in MYSQLND_METHOD_PRIVATE()
1775 stmt->default_rset_handler(s); in MYSQLND_METHOD_PRIVATE()
1776 stmt->state = MYSQLND_STMT_USER_FETCHING; in MYSQLND_METHOD_PRIVATE()
1780 if (stmt->result) { in MYSQLND_METHOD_PRIVATE()
1782 stmt->result->m.skip_result(stmt->result); in MYSQLND_METHOD_PRIVATE()
1789 if (stmt->stmt_id) { in MYSQLND_METHOD_PRIVATE()
1795 const size_t stmt_id = stmt->stmt_id; in MYSQLND_METHOD_PRIVATE()
1799 COPY_CLIENT_ERROR(stmt->error_info, *conn->error_info); in MYSQLND_METHOD_PRIVATE()
1804 switch (stmt->execute_count) { in MYSQLND_METHOD_PRIVATE()
1818 if (stmt->execute_cmd_buffer.buffer) { in MYSQLND_METHOD_PRIVATE()
1819 mnd_efree(stmt->execute_cmd_buffer.buffer); in MYSQLND_METHOD_PRIVATE()
1820 stmt->execute_cmd_buffer.buffer = NULL; in MYSQLND_METHOD_PRIVATE()
1827 stmt->conn = NULL; in MYSQLND_METHOD_PRIVATE()
1838 MYSQLND_STMT_DATA * stmt = (s != NULL) ? s->data:NULL; in MYSQLND_METHOD() local
1842 if (stmt) { in MYSQLND_METHOD()
1843 DBG_INF_FMT("stmt=%p", stmt); in MYSQLND_METHOD()
1849 mnd_efree(stmt); in MYSQLND_METHOD()
1863 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
1865 if (!stmt) { in MYSQLND_METHOD()
1868 DBG_RETURN(mnd_ecalloc(stmt->param_count, sizeof(MYSQLND_PARAM_BIND))); in MYSQLND_METHOD()
1877 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
1879 if (!stmt) { in MYSQLND_METHOD()
1882 DBG_RETURN(mnd_ecalloc(stmt->field_count, sizeof(MYSQLND_RESULT_BIND))); in MYSQLND_METHOD()
1891 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
1892 if (stmt) { in MYSQLND_METHOD()
1903 MYSQLND_STMT_DATA * stmt = s? s->data : NULL; in MYSQLND_METHOD() local
1904 if (stmt) { in MYSQLND_METHOD()