andrey Tue, 27 Apr 2010 10:53:27 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=298649
Log: 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. 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/trunk/ext/mysqlnd/mysqlnd.c U php/php-src/trunk/ext/mysqlnd/mysqlnd_enum_n_def.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-04-27 09:50:51 UTC (rev 298648) +++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd.c 2010-04-27 10:53:27 UTC (rev 298649) @@ -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_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 @@ 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'; 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-04-27 09:50:51 UTC (rev 298648) +++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_enum_n_def.h 2010-04-27 10:53:27 UTC (rev 298649) @@ -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" Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd.c =================================================================== --- php/php-src/trunk/ext/mysqlnd/mysqlnd.c 2010-04-27 09:50:51 UTC (rev 298648) +++ php/php-src/trunk/ext/mysqlnd/mysqlnd.c 2010-04-27 10:53:27 UTC (rev 298649) @@ -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_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 @@ 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'; Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_enum_n_def.h =================================================================== --- php/php-src/trunk/ext/mysqlnd/mysqlnd_enum_n_def.h 2010-04-27 09:50:51 UTC (rev 298648) +++ php/php-src/trunk/ext/mysqlnd/mysqlnd_enum_n_def.h 2010-04-27 10:53:27 UTC (rev 298649) @@ -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"
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php