From: Andrey Hristov Date: Wed, 1 Sep 2010 14:47:36 +0000 (+0000) Subject: OPT_COMPRESS support for mysqlnd_conn::set_client_option X-Git-Tag: php-5.4.0alpha1~191^2~1007 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b2bcf3ae48ae2325839d55f95f23b3799bf78b28;p=php OPT_COMPRESS support for mysqlnd_conn::set_client_option To be used by mysqli_options --- diff --git a/ext/mysqlnd/mysqlnd.c b/ext/mysqlnd/mysqlnd.c index faac95ea86..4c7789ac0e 100644 --- a/ext/mysqlnd/mysqlnd.c +++ b/ext/mysqlnd/mysqlnd.c @@ -714,6 +714,10 @@ MYSQLND_METHOD(mysqlnd_conn, connect)(MYSQLND * conn, if (mysql_flags & CLIENT_COMPRESS) { mysql_flags &= ~CLIENT_COMPRESS; } +#else + if (conn->net->options.flags & MYSQLND_NET_FLAG_USE_COMPRESSION) { + mysql_flags |= CLIENT_COMPRESS; + } #endif #ifndef MYSQLND_SSL_SUPPORTED if (mysql_flags & CLIENT_SSL) { @@ -2034,9 +2038,7 @@ MYSQLND_METHOD(mysqlnd_conn, set_client_option)(MYSQLND * const conn, DBG_ENTER("mysqlnd_conn::set_client_option"); DBG_INF_FMT("conn=%llu option=%u", conn->thread_id, option); switch (option) { -#ifdef WHEN_SUPPORTED_BY_MYSQLI case MYSQL_OPT_COMPRESS: -#endif #ifdef WHEN_SUPPORTED_BY_MYSQLI case MYSQL_OPT_READ_TIMEOUT: case MYSQL_OPT_WRITE_TIMEOUT: diff --git a/ext/mysqlnd/mysqlnd_enum_n_def.h b/ext/mysqlnd/mysqlnd_enum_n_def.h index 5c6a6f25f3..a6edb3401c 100644 --- a/ext/mysqlnd/mysqlnd_enum_n_def.h +++ b/ext/mysqlnd/mysqlnd_enum_n_def.h @@ -94,6 +94,9 @@ #define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30) + +#define MYSQLND_NET_FLAG_USE_COMPRESSION 1 + typedef enum mysqlnd_extension { MYSQLND_MYSQL = 0, diff --git a/ext/mysqlnd/mysqlnd_net.c b/ext/mysqlnd/mysqlnd_net.c index 207fa53f0c..7a65fa1420 100644 --- a/ext/mysqlnd/mysqlnd_net.c +++ b/ext/mysqlnd/mysqlnd_net.c @@ -665,10 +665,8 @@ MYSQLND_METHOD(mysqlnd_net, set_client_option)(MYSQLND_NET * const net, enum mys net->options.timeout_write = *(unsigned int*) value; break; #endif -#ifdef WHEN_SUPPORTED_BY_MYSQLI case MYSQL_OPT_COMPRESS: -#endif - /* currently not supported. Todo!! */ + net->options.flags |= MYSQLND_NET_FLAG_USE_COMPRESSION; break; default: DBG_RETURN(FAIL); diff --git a/ext/mysqlnd/mysqlnd_structs.h b/ext/mysqlnd/mysqlnd_structs.h index 426a2067ed..e1e4cfcc3f 100644 --- a/ext/mysqlnd/mysqlnd_structs.h +++ b/ext/mysqlnd/mysqlnd_structs.h @@ -156,11 +156,18 @@ typedef struct st_mysqlnd_options The ABI will be broken and the methods structure will be somewhere else in the memory which can crash external code. Feel free to reuse these. */ - char * unused1; +#if SIZEOF_CHAR_P == 4 + uint32_t unused1; +#elif SIZEOF_CHAR_P == 8 + uint64_t unused1; +#else +#error Not supported platform +#endif char * unused2; char * unused3; char * unused4; char * unused5; + enum_mysqlnd_protocol_type protocol; char *charset_name; @@ -190,6 +197,7 @@ typedef struct st_mysqlnd_net_options char *ssl_cipher; char *ssl_passphrase; zend_bool ssl_verify_peer; + uint64_t flags; } MYSQLND_NET_OPTIONS;