diff options
author | unknown <monty@mashka.mysql.fi> | 2002-11-24 15:47:19 +0200 |
---|---|---|
committer | unknown <monty@mashka.mysql.fi> | 2002-11-24 15:47:19 +0200 |
commit | 72da2e4c9463aeb80083fd53cc0e6f5091b5f4f7 (patch) | |
tree | ed4766483373d3e3ccd10186eea178ace4e50ae4 /sql | |
parent | 70a17cd5a7aab52697b494cd8379fb78db15eeea (diff) | |
download | mariadb-git-72da2e4c9463aeb80083fd53cc0e6f5091b5f4f7.tar.gz |
Added new ANSI functions LOCALTIME, LOCALTIMESTAMP and CURRENT_USER
Added CEIL as an alias for CEILING
Cleaned up CHECK constraint handling.
(We don't anymore require braces after CHECK)
Added casting to CHAR.
mysql-test/r/bigint.result:
Moved casting test to cast.test
mysql-test/r/func_time.result:
Test of new functions
mysql-test/t/bigint.test:
Moved casting test to cast.test
mysql-test/t/func_time.test:
Test of new functions
sql/item_create.cc:
Added casting to CHAR
sql/item_func.h:
Added casting to CHAR
sql/item_timefunc.h:
Added casting to CHAR
sql/lex.h:
Added new ANSI functions LOCALTIME, LOCALTIMESTAMP and CURRENT_USER
Added CEIL as an alias for CEILING
sql/sql_yacc.yy:
Cleaned up CHECK constraint handling.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_create.cc | 1 | ||||
-rw-r--r-- | sql/item_func.h | 2 | ||||
-rw-r--r-- | sql/item_timefunc.h | 13 | ||||
-rw-r--r-- | sql/lex.h | 4 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 19 |
5 files changed, 32 insertions, 7 deletions
diff --git a/sql/item_create.cc b/sql/item_create.cc index f28e3248c61..c5f53f0d040 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -425,6 +425,7 @@ Item *create_func_cast(Item *a, Item_cast cast_type) LINT_INIT(res); switch (cast_type) { case ITEM_CAST_BINARY: res= new Item_func_binary(a); break; + case ITEM_CAST_CHAR: res= new Item_char_typecast(a); break; case ITEM_CAST_SIGNED_INT: res= new Item_func_signed(a); break; case ITEM_CAST_UNSIGNED_INT: res= new Item_func_unsigned(a); break; case ITEM_CAST_DATE: res= new Item_date_typecast(a); break; diff --git a/sql/item_func.h b/sql/item_func.h index 2e02d7cfd28..b7e0cee540a 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -1003,7 +1003,7 @@ public: enum Item_cast { ITEM_CAST_BINARY, ITEM_CAST_SIGNED_INT, ITEM_CAST_UNSIGNED_INT, - ITEM_CAST_DATE, ITEM_CAST_TIME, ITEM_CAST_DATETIME + ITEM_CAST_DATE, ITEM_CAST_TIME, ITEM_CAST_DATETIME, ITEM_CAST_CHAR }; Item *create_func_cast(Item *a, Item_cast cast_type); diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index 0fe487b7983..c0255e71d27 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -410,6 +410,7 @@ public: unsigned int size_of() { return sizeof(*this);} }; + class Item_extract :public Item_int_func { const interval_type int_type; @@ -424,10 +425,12 @@ class Item_extract :public Item_int_func unsigned int size_of() { return sizeof(*this);} }; + class Item_typecast :public Item_str_func { public: Item_typecast(Item *a) :Item_str_func(a) {} + const char *func_name() const { return "char"; } String *val_str(String *a) { a=args[0]->val_str(a); null_value=args[0]->null_value; return a; } void fix_length_and_dec() { max_length=args[0]->max_length; } @@ -435,6 +438,14 @@ public: }; +class Item_char_typecast :public Item_typecast +{ +public: + Item_char_typecast(Item *a) :Item_typecast(a) {} + void fix_length_and_dec() { binary=0; max_length=args[0]->max_length; } +}; + + class Item_date_typecast :public Item_typecast { public: @@ -450,6 +461,7 @@ public: } }; + class Item_time_typecast :public Item_typecast { public: @@ -465,6 +477,7 @@ public: } }; + class Item_datetime_typecast :public Item_typecast { public: diff --git a/sql/lex.h b/sql/lex.h index 49b6a3811e5..717e8a355ca 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -210,6 +210,8 @@ static SYMBOL symbols[] = { { "LIMIT", SYM(LIMIT),0,0}, { "LOAD", SYM(LOAD),0,0}, { "LOCAL", SYM(LOCAL_SYM),0,0}, + { "LOCALTIME", SYM(NOW_SYM),0,0}, + { "LOCALTIMESTAMP", SYM(NOW_SYM),0,0}, { "LOCK", SYM(LOCK_SYM),0,0}, { "LOCKS", SYM(LOCKS_SYM),0,0}, { "LOGS", SYM(LOGS_SYM),0,0}, @@ -394,7 +396,9 @@ static SYMBOL sql_functions[] = { { "BIT_OR", SYM(BIT_OR),0,0}, { "BIT_AND", SYM(BIT_AND),0,0}, { "CAST", SYM(CAST_SYM),0,0}, + { "CEIL", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_ceiling)}, { "CEILING", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_ceiling)}, + { "CURRENT_USER", SYM(USER),0,0}, { "BIT_LENGTH", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_bit_length)}, { "CHAR_LENGTH", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_char_length)}, { "CHARACTER_LENGTH", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_char_length)}, diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index f6a0c483bb9..c3c6d8ad66b 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -899,7 +899,7 @@ field_list: field_list_item: - field_spec + field_spec check_constraint | field_spec references { Lex->col_list.empty(); /* Alloced by sql_alloc */ @@ -914,10 +914,16 @@ field_list_item: { Lex->col_list.empty(); /* Alloced by sql_alloc */ } - | opt_constraint CHECK_SYM '(' expr ')' + | opt_constraint check_constraint { Lex->col_list.empty(); /* Alloced by sql_alloc */ - }; + } + ; + +check_constraint: + /* empty */ + | CHECK_SYM expr + ; opt_constraint: /* empty */ @@ -1986,13 +1992,15 @@ in_sum_expr: cast_type: BINARY { $$=ITEM_CAST_BINARY; } + | CHAR_SYM { $$=ITEM_CAST_CHAR; } | SIGNED_SYM { $$=ITEM_CAST_SIGNED_INT; } | SIGNED_SYM INT_SYM { $$=ITEM_CAST_SIGNED_INT; } | UNSIGNED { $$=ITEM_CAST_UNSIGNED_INT; } | UNSIGNED INT_SYM { $$=ITEM_CAST_UNSIGNED_INT; } | DATE_SYM { $$=ITEM_CAST_DATE; } | TIME_SYM { $$=ITEM_CAST_TIME; } - | DATETIME { $$=ITEM_CAST_DATETIME; }; + | DATETIME { $$=ITEM_CAST_DATETIME; } + ; expr_list: { Select->expr_list.push_front(new List<Item>); } @@ -2437,7 +2445,7 @@ table_name: { if (!add_table_to_list($1,NULL,1)) YYABORT; }; if_exists: - /* empty */ { $$=0; } + /* empty */ { $$= 0; } | IF EXISTS { $$= 1; } ; @@ -3154,7 +3162,6 @@ keyword: | CACHE_SYM {} | CHANGED {} | CHECKSUM_SYM {} - | CHECK_SYM {} | CIPHER_SYM {} | CLIENT_SYM {} | CLOSE_SYM {} |