PDO MySQL: Use native types for results

Previously, PDO MySQL only fetched data as native int/float if
native prepared statements were used. This patch updates PDO to
have the same behavior for emulated prepared statements, and thus
removes the largest remaining discrepancy between these two modes.

Note that PDO already has a ATTR_STRINGIFY_FETCHES option to control
whether native types are desired or not. The previous output can
be restored by enabling this option.

Most of the tests make use of that option, because this allows the
tests to work under libmysqlclient as well, which currently always
returns string results (independently of whether native or emulated
PS are used).
This commit is contained in:
Nikita Popov 2020-12-15 17:07:27 +01:00
parent 33e904915e
commit c18b1aea28
28 changed files with 161 additions and 61 deletions

View file

@ -120,12 +120,6 @@ typedef struct {
pdo_mysql_db_handle *H;
MYSQL_RES *result;
const MYSQL_FIELD *fields;
MYSQL_ROW current_data;
#ifdef PDO_USE_MYSQLND
const size_t *current_lengths;
#else
unsigned long *current_lengths;
#endif
pdo_mysql_error_info einfo;
#ifdef PDO_USE_MYSQLND
MYSQLND_STMT *stmt;
@ -137,10 +131,14 @@ typedef struct {
#ifndef PDO_USE_MYSQLND
my_bool *in_null;
zend_ulong *in_length;
#endif
PDO_MYSQL_PARAM_BIND *bound_result;
my_bool *out_null;
zend_ulong *out_length;
MYSQL_ROW current_data;
unsigned long *current_lengths;
#else
zval *current_row;
#endif
unsigned max_length:1;
/* Whether all result sets have been fully consumed.
* If this flag is not set, they need to be consumed during destruction. */