50#define MYSQLND_PS_SKIP_RESULT_W_LEN -1
51#define MYSQLND_PS_SKIP_RESULT_STR -2
53static inline void ps_fetch_over_read_error(
const zend_uchar ** row)
59static inline bool ps_fetch_is_packet_over_read_with_variable_length(
const unsigned int pack_len,
65 size_t length_len = *row -
p;
67 ps_fetch_over_read_error(row);
73static inline bool ps_fetch_is_packet_over_read_with_static_length(
const unsigned int pack_len,
77 ps_fetch_over_read_error(row);
87 const zend_uchar ** row,
unsigned int byte_count)
89 if (
UNEXPECTED(ps_fetch_is_packet_over_read_with_static_length(
pack_len, row, byte_count))) {
94 DBG_ENTER(
"ps_fetch_from_1_to_8_bytes");
95 DBG_INF_FMT(
"zv=%p byte_count=%u",
zv, byte_count);
107 case 1:uval = (uint64_t)
uint1korr(*row);
break;
111 DBG_INF(
"stringify due to zerofill");
114#if SIZEOF_ZEND_LONG==4
116 DBG_INF(
"stringify");
121 if (byte_count < 8 || uval <=
L64(9223372036854775807)) {
124 DBG_INF(
"stringify");
131 switch (byte_count) {
132 case 8:lval = (int64_t)
sint8korr(*row);
break;
137 case 4:lval = (int64_t)
sint4korr(*row);
break;
138 case 3:lval = (int64_t)
sint3korr(*row);
break;
139 case 2:lval = (int64_t)
sint2korr(*row);
break;
140 case 1:lval = (int64_t) *(int8_t*)*row;
break;
143#if SIZEOF_ZEND_LONG==4
144 if ((
L64(2147483647) < (int64_t) lval) || (
L64(-2147483648) > (int64_t) lval)) {
145 DBG_INF(
"stringify");
211 DBG_ENTER(
"ps_fetch_float");
219 DBG_INF_FMT(
"value=%f", fval);
222# define NOT_FIXED_DEC 31
225 dval = mysql_float_to_double(fval, (field->decimals >=
NOT_FIXED_DEC) ? -1 : (
int)field->decimals);
238 DBG_ENTER(
"ps_fetch_double");
247 DBG_INF_FMT(
"value=%f",
value);
260 DBG_ENTER(
"ps_fetch_time");
263 if (
UNEXPECTED(ps_fetch_is_packet_over_read_with_variable_length(pack_len, row,
p, length))) {
270 t.neg = (bool) to[0];
273 t.hour = (
unsigned int) to[5];
274 t.minute = (
unsigned int) to[6];
275 t.second = (
unsigned int) to[7];
290 if (field->decimals > 0 && field->decimals < 7) {
292 (t.neg ?
"-" :
""), t.hour, t.minute, t.second, field->decimals,
293 (uint32_t) (t.second_part /
pow(10, 6 - field->decimals))));
296 (t.neg ?
"-" :
""), t.hour, t.minute, t.second));
310 DBG_ENTER(
"ps_fetch_date");
313 if (
UNEXPECTED(ps_fetch_is_packet_over_read_with_variable_length(pack_len, row,
p, length))) {
325 t.
month = (
unsigned int) to[2];
326 t.
day = (
unsigned int) to[3];
347 DBG_ENTER(
"ps_fetch_datetime");
350 if (
UNEXPECTED(ps_fetch_is_packet_over_read_with_variable_length(pack_len, row,
p, length))) {
360 t.
month = (
unsigned int) to[2];
361 t.
day = (
unsigned int) to[3];
364 t.
hour = (
unsigned int) to[4];
365 t.
minute = (
unsigned int) to[5];
366 t.
second = (
unsigned int) to[6];
378 if (field->decimals > 0 && field->decimals < 7) {
397 if (
UNEXPECTED(ps_fetch_is_packet_over_read_with_variable_length(pack_len, row,
p, length))) {
400 DBG_ENTER(
"ps_fetch_string");
402 DBG_INF(
"copying from the row buffer");
417 if (
UNEXPECTED(ps_fetch_is_packet_over_read_with_variable_length(pack_len, row,
p, length))) {
550mysqlnd_stmt_copy_it(
zval ** copies,
zval * original,
unsigned int param_count,
unsigned int current)
583 const size_t overalloc = 5;
584 size_t left = (*buf_len - (*
p - *
buf));
586 if (
left < (needed_bytes + overalloc)) {
589 *buf_len =
offset + needed_bytes + overalloc;
595 if (*
buf != provided_buffer) {
609mysqlnd_stmt_execute_prepare_param_types(
MYSQLND_STMT_DATA * stmt,
zval ** copies_param,
int * resend_types_next_time)
612 DBG_ENTER(
"mysqlnd_stmt_execute_prepare_param_types");
621 PASS != mysqlnd_stmt_copy_it(copies_param, parameter, stmt->
param_count, i))
631 zval *tmp_data = (*copies_param && !
Z_ISUNDEF((*copies_param)[i]))? &(*copies_param)[i]: parameter;
637 double d = zval_get_double(tmp_data);
669#if SIZEOF_ZEND_LONG==8
681 const zval *tmp_data = (copies && !
Z_ISUNDEF(copies[i]))? &copies[i] : parameter;
706mysqlnd_stmt_execute_calculate_param_values_size(
MYSQLND_STMT_DATA * stmt,
zval ** copies_param,
size_t * data_size)
709 DBG_ENTER(
"mysqlnd_stmt_execute_calculate_param_values_size");
711 unsigned short is_longlong = 0;
725 if (!*copies_param ||
Z_ISUNDEF((*copies_param)[i])) {
726 if (
PASS != mysqlnd_stmt_copy_it(copies_param, the_var, stmt->
param_count, i)) {
740 if (!*copies_param ||
Z_ISUNDEF((*copies_param)[i])) {
741 if (
PASS != mysqlnd_stmt_copy_it(copies_param, the_var, stmt->
param_count, i)) {
753 zval *tmp_data = (*copies_param && !
Z_ISUNDEF((*copies_param)[i]))? &(*copies_param)[i]: the_var;
759 *data_size += 4 + is_longlong;
775 if (!*copies_param ||
Z_ISUNDEF((*copies_param)[i])) {
776 if (
PASS != mysqlnd_stmt_copy_it(copies_param, the_var, stmt->
param_count, i)) {
781 the_var = &((*copies_param)[i]);
784 if (!try_convert_to_string(the_var)) {
807 data = (copies && !
Z_ISUNDEF(copies[i]))? &copies[i]: parameter;
810 (
buf + null_byte_offset)[i/8] |= (
zend_uchar) (1 << (i & 7));
861 (
buf + null_byte_offset)[i/8] |= (
zend_uchar) (1 << (i & 7));
876 size_t data_size = 0;
879 int resend_types_next_time = 0;
880 size_t null_byte_offset;
882 DBG_ENTER(
"mysqlnd_stmt_execute_store_params");
885 unsigned int null_count = (stmt->
param_count + 7) / 8;
886 if (
FAIL == mysqlnd_stmt_execute_check_n_enlarge_buffer(
buf,
p, buf_len, provided_buffer, null_count)) {
891 null_byte_offset = *
p - *
buf;
904 if (
FAIL == mysqlnd_stmt_execute_prepare_param_types(stmt, &copies, &resend_types_next_time)) {
912 if (
FAIL == mysqlnd_stmt_execute_check_n_enlarge_buffer(
buf,
p, buf_len, provided_buffer, stmt->
param_count * 2)) {
916 mysqlnd_stmt_execute_store_types(stmt, copies,
p);
923 if (
FAIL == mysqlnd_stmt_execute_calculate_param_values_size(stmt, &copies, &data_size)) {
928 if (
FAIL == mysqlnd_stmt_execute_check_n_enlarge_buffer(
buf,
p, buf_len, provided_buffer, data_size)) {
934 mysqlnd_stmt_execute_store_param_values(stmt, copies, *
buf,
p, null_byte_offset);
938 mysqlnd_stmt_free_copies(stmt, copies);
940 DBG_INF_FMT(
"ret=%s",
ret ==
PASS?
"PASS":
"FAIL");
956 DBG_ENTER(
"mysqlnd_stmt_execute_generate_request");
972 ret = mysqlnd_stmt_execute_store_params(
s, &cmd_buffer, &
p, &cmd_buffer_length);
976 *request_len = (
p - cmd_buffer);
977 *request = cmd_buffer;
978 DBG_INF_FMT(
"ret=%s",
ret ==
PASS?
"PASS":
"FAIL");
pow(mixed $num, mixed $exponent)
#define float8store(T, V)
memset(ptr, 0, type->size)
zend_ffi_ctype_name_buf buf
PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format,...)
#define mnd_ecalloc(nmemb, size)
#define mnd_emalloc(size)
#define DBG_RETURN(value)
@ MYSQLND_PARAM_BIND_BLOB_USED
enum func_status enum_func_status
mysqlnd_stmt_execute_generate_request
struct st_mysqlnd_perm_bind mysqlnd_ps_fetch_functions[MYSQL_TYPE_LAST+1]
void ps_fetch_from_1_to_8_bytes(zval *zv, const MYSQLND_FIELD *const field, const unsigned int pack_len, const zend_uchar **row, unsigned int byte_count)
#define MYSQLND_PS_SKIP_RESULT_W_LEN
@ MYSQLND_TIMESTAMP_ERROR
@ MYSQLND_TIMESTAMP_DATETIME
void _mysqlnd_init_ps_fetch_subsystem(void)
#define MYSQLND_PS_SKIP_RESULT_STR
struct st_mysqlnd_field MYSQLND_FIELD
struct st_mysqlnd_stmt_data MYSQLND_STMT_DATA
struct st_mysqlnd_stmt MYSQLND_STMT
#define SET_OOM_ERROR(info)
zend_ulong php_mysqlnd_net_field_length(const zend_uchar **packet)
zend_uchar * php_mysqlnd_net_store_length(zend_uchar *packet, const uint64_t length)
unsigned const char * end
enum_param_bind_flags flags
MYSQLND_CMD_BUFFER execute_cmd_buffer
unsigned char send_types_to_server
MYSQLND_ERROR_INFO * error_info
MYSQLND_PARAM_BIND * param_bind
enum mysqlnd_timestamp_type time_type
ZEND_API zend_string * zend_strpprintf(size_t max_len, const char *format,...)
#define ZVAL_STRINGL_FAST(z, s, l)
ZEND_API zend_string *ZEND_FASTCALL zend_u64_to_str(uint64_t num)
ZEND_API zend_string *ZEND_FASTCALL zend_i64_to_str(int64_t num)
ZEND_API void ZEND_FASTCALL convert_to_double(zval *op)
ZEND_API void ZEND_FASTCALL convert_to_long(zval *op)
#define convert_to_string(op)
#define UNEXPECTED(condition)
#define Z_ISREF_P(zval_p)
#define Z_STRVAL_P(zval_p)
#define Z_ISUNDEF_P(zval_p)
#define Z_ISNULL_P(zval_p)
#define Z_STRLEN_P(zval_p)
#define ZVAL_DOUBLE(z, d)
ZEND_API void zval_ptr_dtor(zval *zval_ptr)