Commit 04e73d25 authored by Sergei Golubchik's avatar Sergei Golubchik

small changes to WL#43:

  consistency: don't use "index" and "key" interchangeably
  => rename "key" to "index"
  consistency: all option types are logical, besides ULL
  => rename ULL to NUMBER
  don't accept floats where integers are expected
  accept hexadecimal where integers are expected
parent 9c9d3c89
...@@ -101,6 +101,17 @@ drop table t1; ...@@ -101,6 +101,17 @@ drop table t1;
SET SQL_MODE=''; SET SQL_MODE='';
CREATE TABLE t1 (a int) ENGINE=example ULL=10000000000000000000 one_or_two='ttt' YESNO=SSS; CREATE TABLE t1 (a int) ENGINE=example ULL=10000000000000000000 one_or_two='ttt' YESNO=SSS;
ERROR HY000: Incorrect value '10000000000000000000' for option 'ULL' ERROR HY000: Incorrect value '10000000000000000000' for option 'ULL'
CREATE TABLE t1 (a int) ENGINE=example ULL=10.00;
ERROR 42000: Only integers allowed as number here near '10.00' at line 1
CREATE TABLE t1 (a int) ENGINE=example ULL=1e2;
ERROR 42000: Only integers allowed as number here near '1e2' at line 1
CREATE TABLE t1 (a int) ENGINE=example ULL=0x1234;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=EXAMPLE DEFAULT CHARSET=latin1 `ULL`=4660
DROP TABLE t1;
SET @@SQL_MODE=@OLD_SQL_MODE; SET @@SQL_MODE=@OLD_SQL_MODE;
select 1; select 1;
1 1
......
...@@ -110,6 +110,17 @@ drop table t1; ...@@ -110,6 +110,17 @@ drop table t1;
SET SQL_MODE=''; SET SQL_MODE='';
--error ER_BAD_OPTION_VALUE --error ER_BAD_OPTION_VALUE
CREATE TABLE t1 (a int) ENGINE=example ULL=10000000000000000000 one_or_two='ttt' YESNO=SSS; CREATE TABLE t1 (a int) ENGINE=example ULL=10000000000000000000 one_or_two='ttt' YESNO=SSS;
--error ER_PARSE_ERROR
CREATE TABLE t1 (a int) ENGINE=example ULL=10.00;
--error ER_PARSE_ERROR
CREATE TABLE t1 (a int) ENGINE=example ULL=1e2;
CREATE TABLE t1 (a int) ENGINE=example ULL=0x1234;
SHOW CREATE TABLE t1;
DROP TABLE t1;
SET @@SQL_MODE=@OLD_SQL_MODE; SET @@SQL_MODE=@OLD_SQL_MODE;
# #
......
...@@ -555,19 +555,19 @@ struct handler_log_file_data { ...@@ -555,19 +555,19 @@ struct handler_log_file_data {
/* /*
Definitions for engine-specific table/field/index options in the CREATE TABLE. Definitions for engine-specific table/field/index options in the CREATE TABLE.
Options are declared with HA_*OPTION_* macros (HA_TOPTION_ULL, HA_FOPTION_ENUM, Options are declared with HA_*OPTION_* macros (HA_TOPTION_NUMBER,
HA_KOPTION_STRING, etc). HA_FOPTION_ENUM, HA_IOPTION_STRING, etc).
Every macros takes the option name, and the name of the underlying field of Every macros takes the option name, and the name of the underlying field of
the appropriate C structure. The "appropriate C structure" is the appropriate C structure. The "appropriate C structure" is
ha_table_option_struct for table level options, ha_table_option_struct for table level options,
ha_field_option_struct for field level options, ha_field_option_struct for field level options,
ha_key_option_struct for key level options. The engine either ha_index_option_struct for key level options. The engine either
defines a structure of this name, or uses #define's to map defines a structure of this name, or uses #define's to map
these "appropriate" names to the actual structure type name. these "appropriate" names to the actual structure type name.
ULL options use a ulonglong as the backing store. ULL options use a ulonglong as the backing store.
HA_*OPTION_ULL() takes the option name, the structure field name, HA_*OPTION_NUMBER() takes the option name, the structure field name,
the default value for the option, min, max, and blk_siz values. the default value for the option, min, max, and blk_siz values.
STRING options use a char* as a backing store. STRING options use a char* as a backing store.
...@@ -595,7 +595,7 @@ enum ha_option_type { HA_OPTION_TYPE_ULL, /* unsigned long long */ ...@@ -595,7 +595,7 @@ enum ha_option_type { HA_OPTION_TYPE_ULL, /* unsigned long long */
HA_OPTION_TYPE_ENUM, /* uint */ HA_OPTION_TYPE_ENUM, /* uint */
HA_OPTION_TYPE_BOOL}; /* bool */ HA_OPTION_TYPE_BOOL}; /* bool */
#define HA_xOPTION_ULL(name, struc, field, def, min, max, blk_siz) \ #define HA_xOPTION_NUMBER(name, struc, field, def, min, max, blk_siz) \
{ HA_OPTION_TYPE_ULL, name, sizeof(name)-1, \ { HA_OPTION_TYPE_ULL, name, sizeof(name)-1, \
offsetof(struc, field), def, min, max, blk_siz, 0 } offsetof(struc, field), def, min, max, blk_siz, 0 }
#define HA_xOPTION_STRING(name, struc, field) \ #define HA_xOPTION_STRING(name, struc, field) \
...@@ -610,8 +610,8 @@ enum ha_option_type { HA_OPTION_TYPE_ULL, /* unsigned long long */ ...@@ -610,8 +610,8 @@ enum ha_option_type { HA_OPTION_TYPE_ULL, /* unsigned long long */
offsetof(struc, field), def, 0, 1, 0, 0 } offsetof(struc, field), def, 0, 1, 0, 0 }
#define HA_xOPTION_END { HA_OPTION_TYPE_ULL, 0, 0, 0, 0, 0, 0, 0, 0 } #define HA_xOPTION_END { HA_OPTION_TYPE_ULL, 0, 0, 0, 0, 0, 0, 0, 0 }
#define HA_TOPTION_ULL(name, field, def, min, max, blk_siz) \ #define HA_TOPTION_NUMBER(name, field, def, min, max, blk_siz) \
HA_xOPTION_ULL(name, ha_table_option_struct, field, def, min, max, blk_siz) HA_xOPTION_NUMBER(name, ha_table_option_struct, field, def, min, max, blk_siz)
#define HA_TOPTION_STRING(name, field) \ #define HA_TOPTION_STRING(name, field) \
HA_xOPTION_STRING(name, ha_table_option_struct, field) HA_xOPTION_STRING(name, ha_table_option_struct, field)
#define HA_TOPTION_ENUM(name, field, values, def) \ #define HA_TOPTION_ENUM(name, field, values, def) \
...@@ -620,8 +620,8 @@ enum ha_option_type { HA_OPTION_TYPE_ULL, /* unsigned long long */ ...@@ -620,8 +620,8 @@ enum ha_option_type { HA_OPTION_TYPE_ULL, /* unsigned long long */
HA_xOPTION_BOOL(name, ha_table_option_struct, field, def) HA_xOPTION_BOOL(name, ha_table_option_struct, field, def)
#define HA_TOPTION_END HA_xOPTION_END #define HA_TOPTION_END HA_xOPTION_END
#define HA_FOPTION_ULL(name, field, def, min, max, blk_siz) \ #define HA_FOPTION_NUMBER(name, field, def, min, max, blk_siz) \
HA_xOPTION_ULL(name, ha_field_option_struct, field, def, min, max, blk_siz) HA_xOPTION_NUMBER(name, ha_field_option_struct, field, def, min, max, blk_siz)
#define HA_FOPTION_STRING(name, field) \ #define HA_FOPTION_STRING(name, field) \
HA_xOPTION_STRING(name, ha_field_option_struct, field) HA_xOPTION_STRING(name, ha_field_option_struct, field)
#define HA_FOPTION_ENUM(name, field, values, def) \ #define HA_FOPTION_ENUM(name, field, values, def) \
...@@ -630,15 +630,15 @@ enum ha_option_type { HA_OPTION_TYPE_ULL, /* unsigned long long */ ...@@ -630,15 +630,15 @@ enum ha_option_type { HA_OPTION_TYPE_ULL, /* unsigned long long */
HA_xOPTION_BOOL(name, ha_field_option_struct, field, def) HA_xOPTION_BOOL(name, ha_field_option_struct, field, def)
#define HA_FOPTION_END HA_xOPTION_END #define HA_FOPTION_END HA_xOPTION_END
#define HA_KOPTION_ULL(name, field, def, min, max, blk_siz) \ #define HA_IOPTION_NUMBER(name, field, def, min, max, blk_siz) \
HA_xOPTION_ULL(name, ha_key_option_struct, field, def, min, max, blk_siz) HA_xOPTION_NUMBER(name, ha_index_option_struct, field, def, min, max, blk_siz)
#define HA_KOPTION_STRING(name, field) \ #define HA_IOPTION_STRING(name, field) \
HA_xOPTION_STRING(name, ha_key_option_struct, field) HA_xOPTION_STRING(name, ha_index_option_struct, field)
#define HA_KOPTION_ENUM(name, field, values, def) \ #define HA_IOPTION_ENUM(name, field, values, def) \
HA_xOPTION_ENUM(name, ha_key_option_struct, field, values, def) HA_xOPTION_ENUM(name, ha_index_option_struct, field, values, def)
#define HA_KOPTION_BOOL(name, field, values, def) \ #define HA_IOPTION_BOOL(name, field, values, def) \
HA_xOPTION_BOOL(name, ha_key_option_struct, field, values, def) HA_xOPTION_BOOL(name, ha_index_option_struct, field, values, def)
#define HA_KOPTION_END HA_xOPTION_END #define HA_IOPTION_END HA_xOPTION_END
typedef struct st_ha_create_table_option { typedef struct st_ha_create_table_option {
enum ha_option_type type; enum ha_option_type type;
...@@ -1060,7 +1060,7 @@ typedef struct st_ha_create_information ...@@ -1060,7 +1060,7 @@ typedef struct st_ha_create_information
/* the following three are only for ALTER TABLE, check_if_incompatible_data() */ /* the following three are only for ALTER TABLE, check_if_incompatible_data() */
void *option_struct; ///< structure with parsed table options void *option_struct; ///< structure with parsed table options
void **fileds_option_struct; ///< array of field option structures void **fileds_option_struct; ///< array of field option structures
void **keys_option_struct; ///< array of key option structures void **indexes_option_struct; ///< array of index option structures
} HA_CREATE_INFO; } HA_CREATE_INFO;
......
...@@ -5783,7 +5783,7 @@ compare_tables(TABLE *table, ...@@ -5783,7 +5783,7 @@ compare_tables(TABLE *table,
if ((create_info->fileds_option_struct= if ((create_info->fileds_option_struct=
(void**)thd->calloc(sizeof(void*) * table->s->fields)) == NULL || (void**)thd->calloc(sizeof(void*) * table->s->fields)) == NULL ||
(create_info->keys_option_struct= (create_info->indexes_option_struct=
(void**)thd->calloc(sizeof(void*) * table->s->keys)) == NULL) (void**)thd->calloc(sizeof(void*) * table->s->keys)) == NULL)
DBUG_RETURN(1); DBUG_RETURN(1);
...@@ -5984,7 +5984,7 @@ compare_tables(TABLE *table, ...@@ -5984,7 +5984,7 @@ compare_tables(TABLE *table,
else else
{ {
DBUG_ASSERT(i < table->s->keys); DBUG_ASSERT(i < table->s->keys);
create_info->keys_option_struct[i]= new_key->option_struct; create_info->indexes_option_struct[i]= new_key->option_struct;
} }
} }
......
...@@ -4769,7 +4769,7 @@ create_table_option: ...@@ -4769,7 +4769,7 @@ create_table_option:
engine_option_value($1, $3, false, &Lex->create_info.option_list, engine_option_value($1, $3, false, &Lex->create_info.option_list,
&Lex->option_list_last); &Lex->option_list_last);
} }
| IDENT_sys equal ulonglong_num | IDENT_sys equal real_ulonglong_num
{ {
new (YYTHD->mem_root) new (YYTHD->mem_root)
engine_option_value($1, $3, &Lex->create_info.option_list, engine_option_value($1, $3, &Lex->create_info.option_list,
...@@ -5434,7 +5434,7 @@ attribute: ...@@ -5434,7 +5434,7 @@ attribute:
engine_option_value($1, $3, false, &Lex->option_list, engine_option_value($1, $3, false, &Lex->option_list,
&Lex->option_list_last); &Lex->option_list_last);
} }
| IDENT_sys equal ulonglong_num | IDENT_sys equal real_ulonglong_num
{ {
new (YYTHD->mem_root) new (YYTHD->mem_root)
engine_option_value($1, $3, &Lex->option_list, engine_option_value($1, $3, &Lex->option_list,
...@@ -5746,7 +5746,7 @@ all_key_opt: ...@@ -5746,7 +5746,7 @@ all_key_opt:
engine_option_value($1, $3, false, &Lex->option_list, engine_option_value($1, $3, false, &Lex->option_list,
&Lex->option_list_last); &Lex->option_list_last);
} }
| IDENT_sys equal ulonglong_num | IDENT_sys equal real_ulonglong_num
{ {
new (YYTHD->mem_root) new (YYTHD->mem_root)
engine_option_value($1, $3, &Lex->option_list, engine_option_value($1, $3, &Lex->option_list,
...@@ -9472,6 +9472,7 @@ ulonglong_num: ...@@ -9472,6 +9472,7 @@ ulonglong_num:
real_ulonglong_num: real_ulonglong_num:
NUM { int error; $$= (ulonglong) my_strtoll10($1.str, (char**) 0, &error); } NUM { int error; $$= (ulonglong) my_strtoll10($1.str, (char**) 0, &error); }
| ULONGLONG_NUM { int error; $$= (ulonglong) my_strtoll10($1.str, (char**) 0, &error); } | ULONGLONG_NUM { int error; $$= (ulonglong) my_strtoll10($1.str, (char**) 0, &error); }
| HEX_NUM { $$= strtoull($1.str, (char**) 0, 16); }
| LONG_NUM { int error; $$= (ulonglong) my_strtoll10($1.str, (char**) 0, &error); } | LONG_NUM { int error; $$= (ulonglong) my_strtoll10($1.str, (char**) 0, &error); }
| dec_num_error { MYSQL_YYABORT; } | dec_num_error { MYSQL_YYABORT; }
; ;
......
...@@ -151,7 +151,7 @@ ha_create_table_option example_table_option_list[]= ...@@ -151,7 +151,7 @@ ha_create_table_option example_table_option_list[]=
range of values 0..UINT_MAX32, and a "block size" of 10 range of values 0..UINT_MAX32, and a "block size" of 10
(any value must be divisible by 10). (any value must be divisible by 10).
*/ */
HA_TOPTION_ULL("ULL", ullparam, UINT_MAX32, 0, UINT_MAX32, 10), HA_TOPTION_NUMBER("ULL", ullparam, UINT_MAX32, 0, UINT_MAX32, 10),
/* /*
one option that takes an arbitrary string one option that takes an arbitrary string
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment