Bug #29843 | Problem with averaging ENUM Fields | ||
---|---|---|---|
Submitted: | 17 Jul 2007 11:28 | Modified: | 1 Aug 2007 18:02 |
Reporter: | Danny Keller | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Documentation | Severity: | S3 (Non-critical) |
Version: | 4.1 bk, 5.0 bk, 5.1 bk | OS: | Any (Linux, Windows XAMPP Installation with PHP5, Apache 2) |
Assigned to: | Paul DuBois | CPU Architecture: | Any |
Tags: | average, enum |
[17 Jul 2007 11:28]
Danny Keller
[17 Jul 2007 11:55]
Sveta Smirnova
Thank you for the report. Verified as described. Seems AVG uses index of element in ENUM and not its value: $mysql50 test -T Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3050 Server version: 5.0.48-debug Source distribution Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> SELECT MIN(tablefieldtest) AS minimumtablefieldtest, AVG(tablefieldtest) AS avgtablefieldtest, MAX(tablefieldtest) AS maximumtablefieldtest FROM t33; Field 1: `minimumtablefieldtest` Catalog: `def` Database: `` Table: `` Org_table: `` Type: STRING Collation: latin1_swedish_ci (8) Length: 1 Max_length: 1 Decimals: 0 Flags: ENUM Field 2: `avgtablefieldtest` Catalog: `def` Database: `` Table: `` Org_table: `` Type: DOUBLE Collation: binary (63) Length: 5 Max_length: 3 Decimals: 31 Flags: BINARY NUM Field 3: `maximumtablefieldtest` Catalog: `def` Database: `` Table: `` Org_table: `` Type: STRING Collation: latin1_swedish_ci (8) Length: 1 Max_length: 1 Decimals: 0 Flags: ENUM +-----------------------+-------------------+-----------------------+ | minimumtablefieldtest | avgtablefieldtest | maximumtablefieldtest | +-----------------------+-------------------+-----------------------+ | 0 | 1 | 0 | +-----------------------+-------------------+-----------------------+ 1 row in set (0.00 sec)
[1 Aug 2007 18:02]
Paul DuBois
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products. Updated the ENUM, SET, and group-by functions sections. Functions that require numeric arguments cast the argument to a number if necessary. For ENUM/SET, this cast operation results in use of the underlying numeric value.