andrey                                   Wed, 01 Sep 2010 14:47:36 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=302978

Log:
OPT_COMPRESS support for mysqlnd_conn::set_client_option
To be used by mysqli_options

Changed paths:
    U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd.c
    U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_enum_n_def.h
    U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c
    U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_structs.h
    U   php/php-src/trunk/ext/mysqlnd/mysqlnd.c
    U   php/php-src/trunk/ext/mysqlnd/mysqlnd_enum_n_def.h
    U   php/php-src/trunk/ext/mysqlnd/mysqlnd_net.c
    U   php/php-src/trunk/ext/mysqlnd/mysqlnd_structs.h

Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd.c  2010-09-01 14:42:43 UTC 
(rev 302977)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd.c  2010-09-01 14:47:36 UTC 
(rev 302978)
@@ -714,6 +714,10 @@
        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 @@
        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:

Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_enum_n_def.h
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_enum_n_def.h       
2010-09-01 14:42:43 UTC (rev 302977)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_enum_n_def.h       
2010-09-01 14:47:36 UTC (rev 302978)
@@ -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,

Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c      2010-09-01 
14:42:43 UTC (rev 302977)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_net.c      2010-09-01 
14:47:36 UTC (rev 302978)
@@ -665,10 +665,8 @@
                        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);

Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_structs.h
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_structs.h  2010-09-01 
14:42:43 UTC (rev 302977)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_structs.h  2010-09-01 
14:47:36 UTC (rev 302978)
@@ -156,11 +156,18 @@
          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 @@
        char            *ssl_cipher;
        char            *ssl_passphrase;
        zend_bool       ssl_verify_peer;
+       uint64_t        flags;
 } MYSQLND_NET_OPTIONS;



Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd.c
===================================================================
--- php/php-src/trunk/ext/mysqlnd/mysqlnd.c     2010-09-01 14:42:43 UTC (rev 
302977)
+++ php/php-src/trunk/ext/mysqlnd/mysqlnd.c     2010-09-01 14:47:36 UTC (rev 
302978)
@@ -714,6 +714,10 @@
        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 @@
        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:

Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_enum_n_def.h
===================================================================
--- php/php-src/trunk/ext/mysqlnd/mysqlnd_enum_n_def.h  2010-09-01 14:42:43 UTC 
(rev 302977)
+++ php/php-src/trunk/ext/mysqlnd/mysqlnd_enum_n_def.h  2010-09-01 14:47:36 UTC 
(rev 302978)
@@ -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,

Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_net.c
===================================================================
--- php/php-src/trunk/ext/mysqlnd/mysqlnd_net.c 2010-09-01 14:42:43 UTC (rev 
302977)
+++ php/php-src/trunk/ext/mysqlnd/mysqlnd_net.c 2010-09-01 14:47:36 UTC (rev 
302978)
@@ -665,10 +665,8 @@
                        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);

Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_structs.h
===================================================================
--- php/php-src/trunk/ext/mysqlnd/mysqlnd_structs.h     2010-09-01 14:42:43 UTC 
(rev 302977)
+++ php/php-src/trunk/ext/mysqlnd/mysqlnd_structs.h     2010-09-01 14:47:36 UTC 
(rev 302978)
@@ -156,11 +156,18 @@
          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 @@
        char            *ssl_cipher;
        char            *ssl_passphrase;
        zend_bool       ssl_verify_peer;
+       uint64_t        flags;
 } MYSQLND_NET_OPTIONS;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to