diff options
| author | Nikita Popov <nikita.ppv@gmail.com> | 2021-03-02 10:58:35 +0100 |
|---|---|---|
| committer | Nikita Popov <nikita.ppv@gmail.com> | 2021-03-02 10:59:34 +0100 |
| commit | 3a867b982755501b514d19418086972a0cc693e7 (patch) | |
| tree | b659eff4fa0fb3029ceed0e78dc52f9cd20672db /ext/mysqlnd | |
| parent | c28751c69c9e2f923dd923fee5e1d4a3c970308a (diff) | |
| download | php-git-3a867b982755501b514d19418086972a0cc693e7.tar.gz | |
Fixed bug #80808
If the ZEROFILL flag is set for a field, do not convert it into
an integer (text protocol) or convert it explicitly into a padded
string (binary protocol).
Diffstat (limited to 'ext/mysqlnd')
| -rw-r--r-- | ext/mysqlnd/mysqlnd_ps_codec.c | 5 | ||||
| -rw-r--r-- | ext/mysqlnd/mysqlnd_wireprotocol.c | 3 |
2 files changed, 7 insertions, 1 deletions
diff --git a/ext/mysqlnd/mysqlnd_ps_codec.c b/ext/mysqlnd/mysqlnd_ps_codec.c index e695d6ba79..eba4805b9d 100644 --- a/ext/mysqlnd/mysqlnd_ps_codec.c +++ b/ext/mysqlnd/mysqlnd_ps_codec.c @@ -74,6 +74,11 @@ ps_fetch_from_1_to_8_bytes(zval * zv, const MYSQLND_FIELD * const field, const u case 1:uval = (uint64_t) uint1korr(*row);break; } + if (field->flags & ZEROFILL_FLAG) { + DBG_INF("stringify due to zerofill"); + tmp_len = sprintf((char *)&tmp, "%0*" PRIu64, (int) field->length, uval); + DBG_INF_FMT("value=%s", tmp); + } else #if SIZEOF_ZEND_LONG==4 if (uval > INT_MAX) { DBG_INF("stringify"); diff --git a/ext/mysqlnd/mysqlnd_wireprotocol.c b/ext/mysqlnd/mysqlnd_wireprotocol.c index 8cb94b6598..ed36c8404b 100644 --- a/ext/mysqlnd/mysqlnd_wireprotocol.c +++ b/ext/mysqlnd/mysqlnd_wireprotocol.c @@ -1600,7 +1600,8 @@ php_mysqlnd_rowp_read_text_protocol(MYSQLND_ROW_BUFFER * row_buffer, zval * fiel } else if (Z_TYPE_P(current_field) == IS_STRING) { /* nothing to do here, as we want a string and ps_fetch_from_1_to_8_bytes() has given us one */ } - } else if (as_int_or_float && perm_bind.php_type == IS_LONG) { + } else if (as_int_or_float && perm_bind.php_type == IS_LONG + && !(fields_metadata[i].flags & ZEROFILL_FLAG)) { zend_uchar save = *(p + len); /* We have to make it ASCIIZ temporarily */ *(p + len) = '\0'; |
