Lines Matching refs:S
37 static void pdo_mysql_free_result(pdo_mysql_stmt *S) in pdo_mysql_free_result() argument
39 if (S->result) { in pdo_mysql_free_result()
41 if (S->bound_result) { in pdo_mysql_free_result()
44 unsigned column_count = mysql_num_fields(S->result); in pdo_mysql_free_result()
46 efree(S->bound_result[i].buffer); in pdo_mysql_free_result()
49 efree(S->bound_result); in pdo_mysql_free_result()
50 efree(S->out_null); in pdo_mysql_free_result()
51 efree(S->out_length); in pdo_mysql_free_result()
52 S->bound_result = NULL; in pdo_mysql_free_result()
55 if (S->current_row) { in pdo_mysql_free_result()
56 unsigned column_count = mysql_num_fields(S->result); in pdo_mysql_free_result()
58 zval_ptr_dtor_nogc(&S->current_row[i]); in pdo_mysql_free_result()
60 efree(S->current_row); in pdo_mysql_free_result()
61 S->current_row = NULL; in pdo_mysql_free_result()
64 mysql_free_result(S->result); in pdo_mysql_free_result()
65 S->result = NULL; in pdo_mysql_free_result()
71 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_stmt_dtor() local
74 PDO_DBG_INF_FMT("stmt=%p", S->stmt); in pdo_mysql_stmt_dtor()
76 pdo_mysql_free_result(S); in pdo_mysql_stmt_dtor()
77 if (S->einfo.errmsg) { in pdo_mysql_stmt_dtor()
78 pefree(S->einfo.errmsg, stmt->dbh->is_persistent); in pdo_mysql_stmt_dtor()
79 S->einfo.errmsg = NULL; in pdo_mysql_stmt_dtor()
81 if (S->stmt) { in pdo_mysql_stmt_dtor()
82 mysql_stmt_close(S->stmt); in pdo_mysql_stmt_dtor()
83 S->stmt = NULL; in pdo_mysql_stmt_dtor()
87 if (S->params) { in pdo_mysql_stmt_dtor()
88 efree(S->params); in pdo_mysql_stmt_dtor()
90 if (S->in_null) { in pdo_mysql_stmt_dtor()
91 efree(S->in_null); in pdo_mysql_stmt_dtor()
93 if (S->in_length) { in pdo_mysql_stmt_dtor()
94 efree(S->in_length); in pdo_mysql_stmt_dtor()
98 if (!S->done && !Z_ISUNDEF(stmt->database_object_handle) in pdo_mysql_stmt_dtor()
101 while (mysql_more_results(S->H->server)) { in pdo_mysql_stmt_dtor()
103 if (mysql_next_result(S->H->server) != 0) { in pdo_mysql_stmt_dtor()
107 res = mysql_store_result(S->H->server); in pdo_mysql_stmt_dtor()
114 efree(S); in pdo_mysql_stmt_dtor()
121 pdo_mysql_stmt *S = stmt->driver_data; in pdo_mysql_stmt_set_row_count() local
122 zend_long row_count = (zend_long) mysql_stmt_affected_rows(S->stmt); in pdo_mysql_stmt_set_row_count()
131 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_fill_stmt_from_result() local
132 pdo_mysql_db_handle *H = S->H; in pdo_mysql_fill_stmt_from_result()
141 S->result = mysql_use_result(H->server); in pdo_mysql_fill_stmt_from_result()
143 S->result = mysql_store_result(H->server); in pdo_mysql_fill_stmt_from_result()
145 if (NULL == S->result) { in pdo_mysql_fill_stmt_from_result()
150 stmt->row_count = (zend_long) mysql_num_rows(S->result); in pdo_mysql_fill_stmt_from_result()
151 php_pdo_stmt_set_column_count(stmt, (int) mysql_num_fields(S->result)); in pdo_mysql_fill_stmt_from_result()
152 S->fields = mysql_fetch_fields(S->result); in pdo_mysql_fill_stmt_from_result()
163 pdo_mysql_stmt *S = stmt->driver_data; in pdo_mysql_stmt_after_execute_prepared() local
164 pdo_mysql_db_handle *H = S->H; in pdo_mysql_stmt_after_execute_prepared()
168 php_pdo_stmt_set_column_count(stmt, mysql_stmt_field_count(S->stmt)); in pdo_mysql_stmt_after_execute_prepared()
170 mysqlnd_stmt_bind_one_result(S->stmt, i); in pdo_mysql_stmt_after_execute_prepared()
173 S->result = mysqlnd_stmt_result_metadata(S->stmt); in pdo_mysql_stmt_after_execute_prepared()
174 if (S->result) { in pdo_mysql_stmt_after_execute_prepared()
175 S->fields = mysql_fetch_fields(S->result); in pdo_mysql_stmt_after_execute_prepared()
178 if (mysql_stmt_store_result(S->stmt)) { in pdo_mysql_stmt_after_execute_prepared()
186 S->result = mysql_stmt_result_metadata(S->stmt); in pdo_mysql_stmt_after_execute_prepared()
187 if (S->result) { in pdo_mysql_stmt_after_execute_prepared()
188 int calc_max_length = H->buffered && S->max_length == 1; in pdo_mysql_stmt_after_execute_prepared()
189 S->fields = mysql_fetch_fields(S->result); in pdo_mysql_stmt_after_execute_prepared()
191 php_pdo_stmt_set_column_count(stmt, (int)mysql_num_fields(S->result)); in pdo_mysql_stmt_after_execute_prepared()
192 S->bound_result = ecalloc(stmt->column_count, sizeof(MYSQL_BIND)); in pdo_mysql_stmt_after_execute_prepared()
193 S->out_null = ecalloc(stmt->column_count, sizeof(my_bool)); in pdo_mysql_stmt_after_execute_prepared()
194 S->out_length = ecalloc(stmt->column_count, sizeof(zend_ulong)); in pdo_mysql_stmt_after_execute_prepared()
198 if (calc_max_length && S->fields[i].type == FIELD_TYPE_BLOB) { in pdo_mysql_stmt_after_execute_prepared()
200 mysql_stmt_attr_set(S->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &on); in pdo_mysql_stmt_after_execute_prepared()
203 switch (S->fields[i].type) { in pdo_mysql_stmt_after_execute_prepared()
205 S->bound_result[i].buffer_length = MAX_MEDIUMINT_WIDTH + 1; in pdo_mysql_stmt_after_execute_prepared()
208 S->bound_result[i].buffer_length = MAX_INT_WIDTH + 1; in pdo_mysql_stmt_after_execute_prepared()
211 S->bound_result[i].buffer_length = MAX_BIGINT_WIDTH + 1; in pdo_mysql_stmt_after_execute_prepared()
214 S->bound_result[i].buffer_length = MAX_TINYINT_WIDTH + 1; in pdo_mysql_stmt_after_execute_prepared()
217 S->bound_result[i].buffer_length = MAX_SMALLINT_WIDTH + 1; in pdo_mysql_stmt_after_execute_prepared()
220 S->bound_result[i].buffer_length = in pdo_mysql_stmt_after_execute_prepared()
221 S->fields[i].max_length? S->fields[i].max_length: in pdo_mysql_stmt_after_execute_prepared()
222 S->fields[i].length; in pdo_mysql_stmt_after_execute_prepared()
224 if (S->bound_result[i].buffer_length > H->max_buffer_size) { in pdo_mysql_stmt_after_execute_prepared()
225 S->bound_result[i].buffer_length = H->max_buffer_size; in pdo_mysql_stmt_after_execute_prepared()
233 …if (S->fields[i].max_length == 0 && S->bound_result[i].buffer_length < 128 && MYSQL_TYPE_VAR_STRIN… in pdo_mysql_stmt_after_execute_prepared()
234 S->bound_result[i].buffer_length = 128; in pdo_mysql_stmt_after_execute_prepared()
237 S->out_length[i] = 0; in pdo_mysql_stmt_after_execute_prepared()
239 S->bound_result[i].buffer = emalloc(S->bound_result[i].buffer_length); in pdo_mysql_stmt_after_execute_prepared()
240 S->bound_result[i].is_null = &S->out_null[i]; in pdo_mysql_stmt_after_execute_prepared()
241 S->bound_result[i].length = &S->out_length[i]; in pdo_mysql_stmt_after_execute_prepared()
242 S->bound_result[i].buffer_type = MYSQL_TYPE_STRING; in pdo_mysql_stmt_after_execute_prepared()
245 if (mysql_stmt_bind_result(S->stmt, S->bound_result)) { in pdo_mysql_stmt_after_execute_prepared()
252 if (mysql_stmt_store_result(S->stmt)) { in pdo_mysql_stmt_after_execute_prepared()
267 pdo_mysql_stmt *S = stmt->driver_data; in pdo_mysql_stmt_execute_prepared_libmysql() local
272 if (mysql_stmt_bind_param(S->stmt, S->params) || mysql_stmt_execute(S->stmt)) { in pdo_mysql_stmt_execute_prepared_libmysql()
273 if (S->params) { in pdo_mysql_stmt_execute_prepared_libmysql()
274 memset(S->params, 0, S->num_params * sizeof(MYSQL_BIND)); in pdo_mysql_stmt_execute_prepared_libmysql()
277 if (mysql_stmt_errno(S->stmt) == 2057) { in pdo_mysql_stmt_execute_prepared_libmysql()
279 S->stmt = NULL; in pdo_mysql_stmt_execute_prepared_libmysql()
292 pdo_mysql_stmt *S = stmt->driver_data; in pdo_mysql_stmt_execute_prepared_mysqlnd() local
296 if (mysql_stmt_execute(S->stmt)) { in pdo_mysql_stmt_execute_prepared_mysqlnd()
308 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_stmt_execute() local
309 pdo_mysql_db_handle *H = S->H; in pdo_mysql_stmt_execute()
311 PDO_DBG_INF_FMT("stmt=%p", S->stmt); in pdo_mysql_stmt_execute()
314 pdo_mysql_free_result(S); in pdo_mysql_stmt_execute()
315 S->done = 0; in pdo_mysql_stmt_execute()
317 if (S->stmt) { in pdo_mysql_stmt_execute()
320 if (num_bound_params < (uint32_t) S->num_params) { in pdo_mysql_stmt_execute()
341 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_stmt_next_rowset() local
342 pdo_mysql_db_handle *H = S->H; in pdo_mysql_stmt_next_rowset()
344 PDO_DBG_INF_FMT("stmt=%p", S->stmt); in pdo_mysql_stmt_next_rowset()
347 pdo_mysql_free_result(S); in pdo_mysql_stmt_next_rowset()
349 if (S->stmt) { in pdo_mysql_stmt_next_rowset()
350 mysql_stmt_free_result(S->stmt); in pdo_mysql_stmt_next_rowset()
351 if (mysql_stmt_next_result(S->stmt)) { in pdo_mysql_stmt_next_rowset()
353 S->done = 1; in pdo_mysql_stmt_next_rowset()
360 S->done = 1; in pdo_mysql_stmt_next_rowset()
391 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_stmt_param_hook() local
394 PDO_DBG_INF_FMT("stmt=%p", S->stmt); in pdo_mysql_stmt_param_hook()
396 if (S->stmt && param->is_param) { in pdo_mysql_stmt_param_hook()
400 if (param->paramno < 0 || param->paramno >= S->num_params) { in pdo_mysql_stmt_param_hook()
406 b = &S->params[param->paramno]; in pdo_mysql_stmt_param_hook()
408 b->is_null = &S->in_null[param->paramno]; in pdo_mysql_stmt_param_hook()
409 b->length = &S->in_length[param->paramno]; in pdo_mysql_stmt_param_hook()
423 mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_NULL); in pdo_mysql_stmt_param_hook()
477 mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_VAR_STRING); in pdo_mysql_stmt_param_hook()
481 mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_LONGLONG); in pdo_mysql_stmt_param_hook()
483 mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_LONG); in pdo_mysql_stmt_param_hook()
488 mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_TINY); in pdo_mysql_stmt_param_hook()
491 mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_DOUBLE); in pdo_mysql_stmt_param_hook()
553 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_stmt_fetch() local
555 if (!S->result) { in pdo_mysql_stmt_fetch()
563 PDO_DBG_INF_FMT("stmt=%p", S->stmt); in pdo_mysql_stmt_fetch()
564 if (S->stmt) { in pdo_mysql_stmt_fetch()
565 if (FAIL == mysqlnd_stmt_fetch(S->stmt, &fetched_anything) || !fetched_anything) { in pdo_mysql_stmt_fetch()
574 if (mysqlnd_fetch_row_zval(S->result, &row_data, &fetched_anything) == FAIL) { in pdo_mysql_stmt_fetch()
583 if (!S->current_row) { in pdo_mysql_stmt_fetch()
584 S->current_row = ecalloc(stmt->column_count, sizeof(zval)); in pdo_mysql_stmt_fetch()
587 zval_ptr_dtor_nogc(&S->current_row[i]); in pdo_mysql_stmt_fetch()
588 ZVAL_COPY_VALUE(&S->current_row[i], &row_data[i]); in pdo_mysql_stmt_fetch()
594 if (S->stmt) { in pdo_mysql_stmt_fetch()
595 ret = mysql_stmt_fetch(S->stmt); in pdo_mysql_stmt_fetch()
613 if ((S->current_data = mysql_fetch_row(S->result)) == NULL) { in pdo_mysql_stmt_fetch()
614 if (!S->H->buffered && mysql_errno(S->H->server)) { in pdo_mysql_stmt_fetch()
620 S->current_lengths = mysql_fetch_lengths(S->result); in pdo_mysql_stmt_fetch()
628 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_stmt_describe() local
633 PDO_DBG_INF_FMT("stmt=%p", S->stmt); in pdo_mysql_stmt_describe()
634 if (!S->result) { in pdo_mysql_stmt_describe()
651 if (S->H->fetch_table_names) { in pdo_mysql_stmt_describe()
652 cols[i].name = strpprintf(0, "%s.%s", S->fields[i].table, S->fields[i].name); in pdo_mysql_stmt_describe()
655 cols[i].name = zend_string_copy(S->fields[i].sname); in pdo_mysql_stmt_describe()
657 cols[i].name = zend_string_init(S->fields[i].name, S->fields[i].name_length, 0); in pdo_mysql_stmt_describe()
661 cols[i].precision = S->fields[i].decimals; in pdo_mysql_stmt_describe()
662 cols[i].maxlen = S->fields[i].length; in pdo_mysql_stmt_describe()
671 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_stmt_get_col() local
674 PDO_DBG_INF_FMT("stmt=%p", S->stmt); in pdo_mysql_stmt_get_col()
675 if (!S->result) { in pdo_mysql_stmt_get_col()
684 if (S->stmt) { in pdo_mysql_stmt_get_col()
685 ZVAL_COPY(result, &S->stmt->data->result_bind[colno].zv); in pdo_mysql_stmt_get_col()
687 ZVAL_COPY(result, &S->current_row[colno]); in pdo_mysql_stmt_get_col()
691 if (S->stmt) { in pdo_mysql_stmt_get_col()
692 if (S->out_null[colno]) { in pdo_mysql_stmt_get_col()
696 size_t length = S->out_length[colno]; in pdo_mysql_stmt_get_col()
697 if (length > S->bound_result[colno].buffer_length) { in pdo_mysql_stmt_get_col()
700 length = S->out_length[colno] = S->bound_result[colno].buffer_length; in pdo_mysql_stmt_get_col()
702 ZVAL_STRINGL_FAST(result, S->bound_result[colno].buffer, length); in pdo_mysql_stmt_get_col()
706 if (S->current_data == NULL) { in pdo_mysql_stmt_get_col()
709 if (S->current_data[colno]) { in pdo_mysql_stmt_get_col()
710 ZVAL_STRINGL_FAST(result, S->current_data[colno], S->current_lengths[colno]); in pdo_mysql_stmt_get_col()
767 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_stmt_col_meta() local
773 PDO_DBG_INF_FMT("stmt=%p", S->stmt); in pdo_mysql_stmt_col_meta()
774 if (!S->result) { in pdo_mysql_stmt_col_meta()
785 F = S->fields + colno; in pdo_mysql_stmt_col_meta()
837 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_stmt_cursor_closer() local
840 PDO_DBG_INF_FMT("stmt=%p", S->stmt); in pdo_mysql_stmt_cursor_closer()
842 S->done = 1; in pdo_mysql_stmt_cursor_closer()
843 pdo_mysql_free_result(S); in pdo_mysql_stmt_cursor_closer()
844 if (S->stmt) { in pdo_mysql_stmt_cursor_closer()
845 mysql_stmt_free_result(S->stmt); in pdo_mysql_stmt_cursor_closer()
848 while (mysql_more_results(S->H->server)) { in pdo_mysql_stmt_cursor_closer()
850 if (mysql_next_result(S->H->server) != 0) { in pdo_mysql_stmt_cursor_closer()
854 res = mysql_store_result(S->H->server); in pdo_mysql_stmt_cursor_closer()