From: Andrey Hristov Date: Tue, 27 Apr 2010 10:53:27 +0000 (+0000) Subject: Move the macro to mysqlnd_enum_n_def.h, because it can be reused X-Git-Tag: php-5.3.3RC1~252 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=be5920b3e9f31cc7fa732308a5836b457deabda7;p=php Move the macro to mysqlnd_enum_n_def.h, because it can be reused in other places. Also, premultiply the values by 4 and add some reserve for future releases of the server. --- diff --git a/ext/mysqlnd/mysqlnd.c b/ext/mysqlnd/mysqlnd.c index bae82d4849..4f5bdf992c 100644 --- a/ext/mysqlnd/mysqlnd.c +++ b/ext/mysqlnd/mysqlnd.c @@ -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'; diff --git a/ext/mysqlnd/mysqlnd_enum_n_def.h b/ext/mysqlnd/mysqlnd_enum_n_def.h index cf624a677a..c99f3b01bd 100644 --- a/ext/mysqlnd/mysqlnd_enum_n_def.h +++ b/ext/mysqlnd/mysqlnd_enum_n_def.h @@ -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"