Lines Matching refs:result

34 MYSQLND_METHOD(mysqlnd_result_buffered_zval, initialize_result_set_rest)(MYSQLND_RES_BUFFERED * const result,
41 const uint64_t row_count = result->row_count;
43 zval *data_begin = ((MYSQLND_RES_BUFFERED_ZVAL *) result)->data;
48 if (!data_cursor || row_count == result->initialized_rows) {
55 enum_func_status rc = result->m.row_decoder(&result->row_buffers[current_row_num],
65 ++result->initialized_rows;
89 MYSQLND_METHOD(mysqlnd_result_buffered_c, initialize_result_set_rest)(MYSQLND_RES_BUFFERED * const result,
97 const uint64_t row_count = result->row_count;
101 if (result->initialized_rows < row_count) {
102 zend_uchar * initialized = ((MYSQLND_RES_BUFFERED_C *) result)->initialized;
109 for (row = 0; row < result->row_count; row++) {
115 rc = result->m.row_decoder(&result->row_buffers[row], current_row, field_count, meta->fields, int_and_float_native, stats);
121 result->initialized_rows++;
181 MYSQLND_METHOD(mysqlnd_result_unbuffered, free_result)(MYSQLND_RES_UNBUFFERED * const result, MYSQLND_STATS * const global_stats)
184 result->m.free_last_data(result, global_stats);
187 if (result->row_packet) {
188 PACKET_FREE(result->row_packet);
189 mnd_efree(result->row_packet);
190 result->row_packet = NULL;
269 MYSQLND_METHOD(mysqlnd_res, free_result_buffers)(MYSQLND_RES * result)
272 DBG_INF_FMT("%s", result->unbuf? "unbuffered":(result->stored_data? "buffered":"unknown"));
274 if (result->meta) {
275 ZEND_ASSERT(zend_arena_contains(result->memory_pool->arena, result->meta));
276 result->meta->m->free_metadata(result->meta);
277 result->meta = NULL;
280 if (result->unbuf) {
281 result->unbuf->m.free_result(result->unbuf, result->conn? result->conn->stats : NULL);
282 result->unbuf = NULL;
283 } else if (result->stored_data) {
284 result->stored_data->m.free_result(result->stored_data);
285 result->stored_data = NULL;
288 mysqlnd_mempool_restore_state(result->memory_pool);
289 mysqlnd_mempool_save_state(result->memory_pool);
298 void MYSQLND_METHOD(mysqlnd_res, free_result_contents_internal)(MYSQLND_RES * result)
302 result->m.free_result_buffers(result);
304 if (result->conn) {
305 result->conn->m->free_reference(result->conn);
306 result->conn = NULL;
309 mysqlnd_mempool_destroy(result->memory_pool);
318 void MYSQLND_METHOD(mysqlnd_res, free_result_internal)(MYSQLND_RES * result)
322 result->m.skip_result(result);
323 result->m.free_result_contents(result);
332 MYSQLND_METHOD(mysqlnd_res, read_result_metadata)(MYSQLND_RES * result, MYSQLND_CONN_DATA * conn)
342 if (result->meta) {
343 result->meta->m->free_metadata(result->meta);
344 result->meta = NULL;
347 result->meta = result->m.result_meta_init(result, result->field_count);
348 if (!result->meta) {
356 if (FAIL == result->meta->m->read_metadata(result->meta, conn, result)) {
357 result->meta->m->free_metadata(result->meta);
358 result->meta = NULL;
362 result->field_count = result->meta->field_count;
367 3. If there is a result set, it follows. The last packet will have 'eof' set
368 If PS, then no result set follows.
395 php_error_docref(NULL, E_WARNING, "Error reading result set's header");
404 to find out whether there are more result sets of
405 a multiple-result-set statement pending. Luckily, in 5.0 an
457 MYSQLND_RES * result;
473 result = conn->current_result = conn->m->result_init(rset_header.field_count);
475 if (!stmt->result) {
479 prepared statements can't send result set metadata for these queries
482 result = stmt->result = conn->m->result_init(rset_header.field_count);
485 Update result set metadata if it for some reason changed between
497 result = stmt->result;
499 if (!result) {
505 if (FAIL == (ret = result->m.read_result_metadata(result, conn))) {
519 result->m.free_result_contents(result);
523 stmt->result = NULL;
539 will include many result sets. What actually matters are the bits set at the end
540 of every result set (the EOF packet).
573 MYSQLND_METHOD(mysqlnd_result_buffered_zval, fetch_lengths)(const MYSQLND_RES_BUFFERED * const result)
575 const MYSQLND_RES_BUFFERED_ZVAL * const set = (const MYSQLND_RES_BUFFERED_ZVAL *) result;
578 - unbuffered result
586 ((set->data_cursor - set->data) > (result->row_count * result->field_count) ))
592 DBG_RETURN(result->lengths);
605 MYSQLND_METHOD(mysqlnd_result_buffered_c, fetch_lengths)(const MYSQLND_RES_BUFFERED * const result)
607 const MYSQLND_RES_BUFFERED_C * const set = (const MYSQLND_RES_BUFFERED_C *) result;
615 DBG_RETURN(result->lengths);
622 MYSQLND_METHOD(mysqlnd_result_unbuffered, fetch_lengths)(const MYSQLND_RES_UNBUFFERED * const result)
625 return (result->last_row_data || result->eof_reached)? result->lengths : NULL;
632 MYSQLND_METHOD(mysqlnd_res, fetch_lengths)(const MYSQLND_RES * const result)
636 ret = result->stored_data && result->stored_data->m.fetch_lengths ?
637 result->stored_data->m.fetch_lengths(result->stored_data) :
638 (result->unbuf && result->unbuf->m.fetch_lengths ?
639 result->unbuf->m.fetch_lengths(result->unbuf) :
649 MYSQLND_METHOD(mysqlnd_result_unbuffered, fetch_row_c)(MYSQLND_RES * result, void * param, unsigned int flags, zend_bool * fetched_anything)
653 MYSQLND_PACKET_ROW *row_packet = result->unbuf->row_packet;
654 MYSQLND_RES_METADATA * const meta = result->meta;
655 MYSQLND_CONN_DATA * const conn = result->conn;
661 if (result->unbuf->eof_reached) {
676 checkpoint = result->memory_pool->checkpoint;
677 mysqlnd_mempool_save_state(result->memory_pool);
681 result->m.unbuffered_free_last_data() before it. The function returns always true.
684 result->unbuf->m.free_last_data(result->unbuf, conn->stats);
686 result->unbuf->last_row_data = row_packet->fields;
687 result->unbuf->last_row_buffer = row_packet->row_buffer;
696 enum_func_status rc = result->unbuf->m.row_decoder(&result->unbuf->last_row_buffer,
697 result->unbuf->last_row_data,
703 mysqlnd_mempool_restore_state(result->memory_pool);
704 result->memory_pool->checkpoint = checkpoint;
711 size_t * lengths = result->unbuf->lengths;
714 zval * data = &result->unbuf->last_row_data[i];
739 result->unbuf->row_count++;
747 result->unbuf->eof_reached = TRUE; /* so next time we won't get an error */
751 result->unbuf->eof_reached = TRUE;
757 result->row_packet will be cleaned when
758 destroying the result object
765 result->unbuf->m.free_last_data(result->unbuf, conn->stats);
768 mysqlnd_mempool_restore_state(result->memory_pool);
769 result->memory_pool->checkpoint = checkpoint;
779 MYSQLND_METHOD(mysqlnd_result_unbuffered, fetch_row)(MYSQLND_RES * result, void * param, const unsigned int flags, zend_bool * fetched_anything)
783 MYSQLND_PACKET_ROW *row_packet = result->unbuf->row_packet;
784 const MYSQLND_RES_METADATA * const meta = result->meta;
785 MYSQLND_CONN_DATA * const conn = result->conn;
791 if (result->unbuf->eof_reached) {
806 checkpoint = result->memory_pool->checkpoint;
807 mysqlnd_mempool_save_state(result->memory_pool);
811 result->m.unbuffered_free_last_data() before it. The function returns always true.
814 result->unbuf->m.free_last_data(result->unbuf, conn->stats);
816 result->unbuf->last_row_data = row_packet->fields;
817 result->unbuf->last_row_buffer = row_packet->row_buffer;
826 enum_func_status rc = result->unbuf->m.row_decoder(&result->unbuf->last_row_buffer,
827 result->unbuf->last_row_data,
833 mysqlnd_mempool_restore_state(result->memory_pool);
834 result->memory_pool->checkpoint = checkpoint;
840 size_t * lengths = result->unbuf->lengths;
843 zval * data = &result->unbuf->last_row_data[i];
877 result->unbuf->row_count++;
885 result->unbuf->eof_reached = TRUE; /* so next time we won't get an error */
889 result->unbuf->eof_reached = TRUE;
895 result->row_packet will be cleaned when
896 destroying the result object
903 result->unbuf->m.free_last_data(result->unbuf, conn->stats);
906 mysqlnd_mempool_restore_state(result->memory_pool);
907 result->memory_pool->checkpoint = checkpoint;
917 MYSQLND_METHOD(mysqlnd_res, use_result)(MYSQLND_RES * const result, const zend_bool ps)
919 MYSQLND_CONN_DATA * const conn = result->conn;
925 result->type = MYSQLND_RES_NORMAL;
927 result->type = MYSQLND_RES_PS_UNBUF;
930 result->unbuf = mysqlnd_result_unbuffered_init(result, result->field_count, ps);
931 if (!result->unbuf) {
945 row_packet->result_set_memory_pool = result->unbuf->result_set_memory_pool;
946 row_packet->field_count = result->field_count;
948 row_packet->fields_metadata = result->meta->fields;
950 result->unbuf->row_packet = row_packet;
953 DBG_RETURN(result);
963 MYSQLND_METHOD(mysqlnd_result_buffered, fetch_row_c)(MYSQLND_RES * result, void * param, unsigned int flags, zend_bool * const fetched_anything)
967 const MYSQLND_RES_METADATA * const meta = result->meta;
969 MYSQLND_CONN_DATA * const conn = result->conn;
972 if (result->stored_data->type == MYSQLND_BUFFERED_TYPE_ZVAL) {
973 MYSQLND_RES_BUFFERED_ZVAL * set = (MYSQLND_RES_BUFFERED_ZVAL *) result->stored_data;
977 (set->data_cursor - set->data) < (result->stored_data->row_count * field_count))
1040 } else if (result->stored_data->type == MYSQLND_BUFFERED_TYPE_C) {
1056 MYSQLND_METHOD(mysqlnd_result_buffered_zval, fetch_row)(MYSQLND_RES * result, void * param, const unsigned int flags, zend_bool * const fetched_anything)
1060 const MYSQLND_RES_METADATA * const meta = result->meta;
1062 MYSQLND_RES_BUFFERED_ZVAL * set = (MYSQLND_RES_BUFFERED_ZVAL *) result->stored_data;
1063 MYSQLND_CONN_DATA * const conn = result->conn;
1143 MYSQLND_METHOD(mysqlnd_result_buffered_c, fetch_row)(MYSQLND_RES * result, void * param, const unsigned int flags, zend_bool * fetched_anything)
1147 const MYSQLND_RES_METADATA * const meta = result->meta;
1149 MYSQLND_CONN_DATA * const conn = result->conn;
1151 MYSQLND_RES_BUFFERED_C * set = (MYSQLND_RES_BUFFERED_C *) result->stored_data;
1167 rc = result->stored_data->m.row_decoder(&result->stored_data->row_buffers[set->current_row],
1251 MYSQLND_METHOD(mysqlnd_res, fetch_row)(MYSQLND_RES * result, void * param, const unsigned int flags, zend_bool *fetched_anything)
1253 const mysqlnd_fetch_row_func f = result->stored_data? result->stored_data->m.fetch_row:(result->unbuf? result->unbuf->m.fetch_row:NULL);
1255 return f(result, param, flags, fetched_anything);
1265 MYSQLND_METHOD(mysqlnd_res, store_result_fetch_data)(MYSQLND_CONN_DATA * const conn, MYSQLND_RES * result,
1273 MYSQLND_RES_BUFFERED * set = result->stored_data;
1287 row_packet.result_set_memory_pool = result->stored_data->result_set_memory_pool;
1389 DBG_INF_FMT("rows=%llu", (unsigned long long)result->stored_data->row_count);
1397 MYSQLND_METHOD(mysqlnd_res, store_result)(MYSQLND_RES * result,
1408 result->conn = conn->m->get_reference(conn);
1409 result->type = MYSQLND_RES_NORMAL;
1414 result->stored_data = (MYSQLND_RES_BUFFERED *) mysqlnd_result_buffered_zval_init(result, result->field_count, flags & MYSQLND_STORE_PS);
1415 if (!result->stored_data) {
1419 row_buffers = &result->stored_data->row_buffers;
1421 result->stored_data = (MYSQLND_RES_BUFFERED *) mysqlnd_result_buffered_c_init(result, result->field_count, flags & MYSQLND_STORE_PS);
1422 if (!result->stored_data) {
1426 row_buffers = &result->stored_data->row_buffers;
1428 ret = result->m.store_result_fetch_data(conn, result, result->meta, row_buffers, flags & MYSQLND_STORE_PS);
1431 if (result->stored_data) {
1432 COPY_CLIENT_ERROR(conn->error_info, result->stored_data->error_info);
1439 const MYSQLND_RES_METADATA * const meta = result->meta;
1440 MYSQLND_RES_BUFFERED_ZVAL * set = (MYSQLND_RES_BUFFERED_ZVAL *) result->stored_data;
1459 MYSQLND_RES_BUFFERED_C * set = (MYSQLND_RES_BUFFERED_C *) result->stored_data;
1466 UPSERT_STATUS_SET_AFFECTED_ROWS(conn->upsert_status, result->stored_data->row_count);
1468 DBG_RETURN(result);
1475 MYSQLND_METHOD(mysqlnd_res, skip_result)(MYSQLND_RES * const result)
1482 A PS could be prepared - there is metadata and thus a stmt->result but the
1485 if (result->unbuf && !result->unbuf->eof_reached) {
1486 MYSQLND_CONN_DATA * const conn = result->conn;
1487 DBG_INF("skipping result");
1490 result->type == MYSQLND_RES_NORMAL? STAT_FLUSHED_NORMAL_SETS:
1493 while ((PASS == result->m.fetch_row(result, NULL, 0, &fetched_anything)) && fetched_anything == TRUE) {
1504 MYSQLND_METHOD(mysqlnd_res, free_result)(MYSQLND_RES * result, const zend_bool implicit)
1508 MYSQLND_INC_CONN_STATISTIC(result->conn? result->conn->stats : NULL,
1512 result->m.free_result_internal(result);
1520 MYSQLND_METHOD(mysqlnd_res, data_seek)(MYSQLND_RES * const result, const uint64_t row)
1525 DBG_RETURN(result->stored_data? result->stored_data->m.data_seek(result->stored_data, row) : FAIL);
1532 MYSQLND_METHOD(mysqlnd_result_buffered_zval, data_seek)(MYSQLND_RES_BUFFERED * const result, const uint64_t row)
1534 MYSQLND_RES_BUFFERED_ZVAL * set = (MYSQLND_RES_BUFFERED_ZVAL *) result;
1541 set->data_cursor = set->data + row * result->field_count;
1550 MYSQLND_METHOD(mysqlnd_result_buffered_c, data_seek)(MYSQLND_RES_BUFFERED * const result, const uint64_t row)
1552 MYSQLND_RES_BUFFERED_C * set = (MYSQLND_RES_BUFFERED_C *) result;
1568 MYSQLND_METHOD(mysqlnd_result_unbuffered, num_rows)(const MYSQLND_RES_UNBUFFERED * const result)
1571 return result->eof_reached? result->row_count : 0;
1578 MYSQLND_METHOD(mysqlnd_result_buffered, num_rows)(const MYSQLND_RES_BUFFERED * const result)
1580 return result->row_count;
1587 MYSQLND_METHOD(mysqlnd_res, num_rows)(const MYSQLND_RES * const result)
1589 return result->stored_data?
1590 result->stored_data->m.num_rows(result->stored_data) :
1591 (result->unbuf? result->unbuf->m.num_rows(result->unbuf) : 0);
1598 MYSQLND_METHOD(mysqlnd_res, num_fields)(const MYSQLND_RES * const result)
1600 return result->field_count;
1607 MYSQLND_METHOD(mysqlnd_res, fetch_field)(MYSQLND_RES * const result)
1611 if (result->meta) {
1613 We optimize the result set, so we don't convert all the data from raw buffer format to
1622 if (result->stored_data && (result->stored_data->initialized_rows < result->stored_data->row_count)) {
1623 const MYSQLND_CONN_DATA * const conn = result->conn;
1624 DBG_INF_FMT("We have decode the whole result set to be able to satisfy this meta request");
1626 if (PASS != result->stored_data->m.initialize_result_set_rest(result->stored_data,
1627 result->meta,
1634 DBG_RETURN(result->meta->m->fetch_field(result->meta));
1644 MYSQLND_METHOD(mysqlnd_res, fetch_field_direct)(MYSQLND_RES * const result, const MYSQLND_FIELD_OFFSET fieldnr)
1648 if (result->meta) {
1650 We optimize the result set, so we don't convert all the data from raw buffer format to
1659 if (result->stored_data && (result->stored_data->initialized_rows < result->stored_data->row_count)) {
1660 const MYSQLND_CONN_DATA * const conn = result->conn;
1661 DBG_INF_FMT("We have decode the whole result set to be able to satisfy this meta request");
1663 if (PASS != result->stored_data->m.initialize_result_set_rest(result->stored_data,
1664 result->meta,
1671 DBG_RETURN(result->meta->m->fetch_field_direct(result->meta, fieldnr));
1682 MYSQLND_METHOD(mysqlnd_res, fetch_fields)(MYSQLND_RES * const result)
1686 if (result->meta) {
1687 if (result->stored_data && (result->stored_data->initialized_rows < result->stored_data->row_count)) {
1688 const MYSQLND_CONN_DATA * const conn = result->conn;
1690 if (PASS != result->stored_data->m.initialize_result_set_rest(result->stored_data,
1691 result->meta,
1698 DBG_RETURN(result->meta->m->fetch_fields(result->meta));
1708 MYSQLND_METHOD(mysqlnd_res, field_seek)(MYSQLND_RES * const result, const MYSQLND_FIELD_OFFSET field_offset)
1710 return result->meta? result->meta->m->field_seek(result->meta, field_offset) : 0;
1717 MYSQLND_METHOD(mysqlnd_res, field_tell)(const MYSQLND_RES * const result)
1719 return result->meta? result->meta->m->field_tell(result->meta) : 0;
1726 MYSQLND_METHOD(mysqlnd_res, fetch_into)(MYSQLND_RES * result, const unsigned int flags,
1739 array_size = result->field_count;
1744 if (FAIL == result->m.fetch_row(result, (void *)return_value, flags, &fetched_anything)) {
1771 MYSQLND_METHOD(mysqlnd_res, fetch_row_c)(MYSQLND_RES * result)
1777 if (result->stored_data && result->stored_data->m.fetch_row == MYSQLND_METHOD(mysqlnd_result_buffered_zval, fetch_row)) {
1778 MYSQLND_METHOD(mysqlnd_result_buffered, fetch_row_c)(result, (void *) &ret, 0, &fetched_anything);
1779 } else if (result->unbuf && result->unbuf->m.fetch_row == MYSQLND_METHOD(mysqlnd_result_unbuffered, fetch_row)) {
1780 MYSQLND_METHOD(mysqlnd_result_unbuffered, fetch_row_c)(result, (void *) &ret, 0, &fetched_anything);
1783 php_error_docref(NULL, E_ERROR, "result->m.fetch_row has invalid value. Report to the developers");
1792 MYSQLND_METHOD(mysqlnd_res, fetch_all)(MYSQLND_RES * result, const unsigned int flags, zval *return_value ZEND_FILE_LINE_DC)
1796 MYSQLND_RES_BUFFERED *set = result->stored_data;
1800 if ((!result->unbuf && !set)) {
1802 if (result->conn) {
1803 SET_CLIENT_ERROR(result->conn->error_info, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, "fetch_all can be used only with buffered sets");
1813 mysqlnd_fetch_into(result, flags, &row, MYSQLND_MYSQLI);
1828 MYSQLND_METHOD(mysqlnd_res, fetch_field_data)(MYSQLND_RES * result, const unsigned int offset, zval *return_value)
1840 mysqlnd_fetch_into(result, MYSQLND_FETCH_NUM, &row, MYSQLND_MYSQL);
1942 mysqlnd_result_unbuffered_init(MYSQLND_RES *result, const unsigned int field_count, const zend_bool ps)
1945 MYSQLND_MEMORY_POOL * pool = result->memory_pool;
1976 mysqlnd_result_buffered_zval_init(MYSQLND_RES * result, const unsigned int field_count, const zend_bool ps)
1979 MYSQLND_MEMORY_POOL * pool = result->memory_pool;
2017 mysqlnd_result_buffered_c_init(MYSQLND_RES * result, const unsigned int field_count, const zend_bool ps)
2020 MYSQLND_MEMORY_POOL * pool = result->memory_pool;