Bug #58075 Add MAX_NUM_XXX to three enum types
Submitted: 9 Nov 2010 8:59 Modified: 14 Jan 2011 13:59
Reporter: Magnus Blåudd Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.5.7-rc OS:Any
Assigned to: Magnus Blåudd CPU Architecture:Any
Tags: SEAGULL

[9 Nov 2010 8:59] Magnus Blåudd
Description:
Add MAX_NUM_XXX identifiers to three enums to make it possible to calculate max bitmask size for the enums during compile time.

How to repeat:
.

Suggested fix:
=== modified file 'include/mysql_com.h'
--- include/mysql_com.h	2010-08-05 12:53:09 +0000
+++ include/mysql_com.h	2010-11-09 08:57:43 +0000
@@ -340,7 +340,10 @@ enum enum_field_types { MYSQL_TYPE_DECIM
 			MYSQL_TYPE_BLOB=252,
 			MYSQL_TYPE_VAR_STRING=253,
 			MYSQL_TYPE_STRING=254,
-			MYSQL_TYPE_GEOMETRY=255
+			MYSQL_TYPE_GEOMETRY=255,
+
+			MYSQL_NUM_FIELD_TYPES /* Always last */
+
 
 };
 
@@ -465,7 +468,8 @@ struct rand_struct {
   /* The following is for user defined functions */
 
 enum Item_result {STRING_RESULT=0, REAL_RESULT, INT_RESULT, ROW_RESULT,
-                  DECIMAL_RESULT};
+                  DECIMAL_RESULT,
+                  MYSQL_NUM_ITEM_RESULTS /* Always last */ };
 
 typedef struct st_udf_args
 {

=== modified file 'sql/item.h'
--- sql/item.h	2010-08-19 11:55:35 +0000
+++ sql/item.h	2010-11-09 08:55:24 +0000
@@ -522,7 +522,8 @@ public:
              SUBSELECT_ITEM, ROW_ITEM, CACHE_ITEM, TYPE_HOLDER,
              PARAM_ITEM, TRIGGER_FIELD_ITEM, DECIMAL_ITEM,
              XPATH_NODESET, XPATH_NODESET_CMP,
-             VIEW_FIXER_ITEM};
+             VIEW_FIXER_ITEM,
+             MAX_NUM_ITEMS /* Always last */ };
 
   enum cond_result { COND_UNDEF,COND_OK,COND_TRUE,COND_FALSE };
[9 Nov 2010 9:07] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/123188
[10 Nov 2010 9:00] Gustaf Thorslund
Would it be possible to introduce this in some standard way? Like calling it END (last + 1 as in .end() in C++ is supposed to be) or <ENUM_NAME>_END. In the first case the END wound need to be prefixed with enum type when needed, but that might not hurt.

Trying to see how it's done currently in the code I fail to find examples. (just looked in includes/)

/Gustaf
[14 Jan 2011 13:53] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/128764
[14 Jan 2011 13:59] Magnus Blåudd
Have reritten ha_ndbcluster so it no longer need these enum values. Closing as won't fix.