]> granicus.if.org Git - php/commitdiff
Move the macro to mysqlnd_enum_n_def.h, because it can be reused
authorAndrey Hristov <andrey@php.net>
Tue, 27 Apr 2010 10:53:27 +0000 (10:53 +0000)
committerAndrey Hristov <andrey@php.net>
Tue, 27 Apr 2010 10:53:27 +0000 (10:53 +0000)
in other places. Also, premultiply the values by 4 and add some
reserve for future releases of the server.

ext/mysqlnd/mysqlnd.c
ext/mysqlnd/mysqlnd_enum_n_def.h

index bae82d4849ef36b49dad15b50c798418de4eba7f..4f5bdf992c98e0a6e281659c2382e4d008df4d22 100644 (file)
@@ -30,9 +30,6 @@
 /* for php_get_current_user() */
 #include "ext/standard/basic_functions.h"
 
-/* the server doesn't support 4byte utf8, but let's make it forward compatible */
-#define MYSQLND_MAX_ALLOWED_USER_LEN   256  /* 64 char * 4byte */
-#define MYSQLND_MAX_ALLOWED_DB_LEN             256  /* 64 char * 4byte */
 /*
   TODO :
   - Don't bind so tightly the metadata with the result set. This means
@@ -1066,7 +1063,7 @@ MYSQLND_RES *
 MYSQLND_METHOD(mysqlnd_conn, list_fields)(MYSQLND * conn, const char *table, const char *achtung_wild TSRMLS_DC)
 {
        /* db + \0 + wild + \0 (for wild) */
-       char buff[MYSQLND_MAX_ALLOWED_DB_LEN * 4 * 2 + 1 + 1], *p;
+       char buff[MYSQLND_MAX_ALLOWED_DB_LEN * 2 + 1 + 1], *p;
        size_t table_len, wild_len;
        MYSQLND_RES *result = NULL;
        DBG_ENTER("mysqlnd_conn::list_fields");
@@ -1074,14 +1071,14 @@ MYSQLND_METHOD(mysqlnd_conn, list_fields)(MYSQLND * conn, const char *table, con
 
        p = buff;
        if (table && (table_len = strlen(table))) {
-               size_t to_copy = MIN(table_len, MYSQLND_MAX_ALLOWED_DB_LEN * 4);
+               size_t to_copy = MIN(table_len, MYSQLND_MAX_ALLOWED_DB_LEN);
                memcpy(p, table, to_copy);
                p += to_copy;
                *p++ = '\0';
        }
 
        if (achtung_wild && (wild_len = strlen(achtung_wild))) {
-               size_t to_copy = MIN(wild_len, MYSQLND_MAX_ALLOWED_DB_LEN * 4);
+               size_t to_copy = MIN(wild_len, MYSQLND_MAX_ALLOWED_DB_LEN);
                memcpy(p, achtung_wild, to_copy);
                p += to_copy;
                *p++ = '\0';
index cf624a677a70c2d1b35cee048cb2a0886d836cda..c99f3b01bd329996c8fcdb6e3e07cd94e22e5c7e 100644 (file)
@@ -39,6 +39,8 @@
 #define MYSQLND_SQLSTATE_LENGTH                5
 #define MYSQLND_SQLSTATE_NULL          "00000"
 
+#define MYSQLND_MAX_ALLOWED_USER_LEN   1024  /* 64 char * 4byte . MySQL supports now only 16 char, but let it be forward compatible */
+#define MYSQLND_MAX_ALLOWED_DB_LEN             1024  /* 256 char * 4byte. MySQL supports now only 64 char in the tables, but on the FS could be different. Forward compatible. */
 
 #define MYSQLND_NET_CMD_BUFFER_MIN_SIZE                        4096
 #define MYSQLND_NET_CMD_BUFFER_MIN_SIZE_STR            "4096"