diff options
author | monty@mashka.mysql.fi <> | 2002-11-25 12:19:28 +0200 |
---|---|---|
committer | monty@mashka.mysql.fi <> | 2002-11-25 12:19:28 +0200 |
commit | 5dbea1b7a26ca1b171546d1ad042113af5d9bd74 (patch) | |
tree | af2db8bb2a2a932f016529fbf7508121528d132a /sql | |
parent | 96212cc300843e6509fbf38083f902f8aebece2a (diff) | |
parent | 05c732e7796f54a5d7facf0adf5f1bbf592b7ecf (diff) | |
download | mariadb-git-5dbea1b7a26ca1b171546d1ad042113af5d9bd74.tar.gz |
Merge with 4.0
Diffstat (limited to 'sql')
-rw-r--r-- | sql/handler.cc | 2 | ||||
-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/mysqld.cc | 3 | ||||
-rw-r--r-- | sql/opt_range.cc | 18 | ||||
-rw-r--r-- | sql/sql_delete.cc | 10 | ||||
-rw-r--r-- | sql/sql_insert.cc | 9 | ||||
-rw-r--r-- | sql/sql_update.cc | 10 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 19 |
11 files changed, 57 insertions, 34 deletions
diff --git a/sql/handler.cc b/sql/handler.cc index b2cf86a6abc..cdd007f2cc2 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -314,7 +314,7 @@ int ha_commit_trans(THD *thd, THD_TRANS* trans) } #endif #ifdef HAVE_QUERY_CACHE - if (transaction_commited) + if (transaction_commited && thd->transaction.changed_tables) query_cache.invalidate(thd->transaction.changed_tables); #endif /*HAVE_QUERY_CACHE*/ if (error && trans == &thd->transaction.all && mysql_bin_log.is_open()) diff --git a/sql/item_create.cc b/sql/item_create.cc index e4c9a160686..3b10ba29ba6 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -432,6 +432,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 b659a6d69d2..31e8afbe5a8 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -1123,5 +1123,5 @@ 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 }; diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index 07cdfde115b..7765769c1d3 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -513,6 +513,7 @@ public: bool get_date(TIME *res,bool fuzzy_date); }; + class Item_extract :public Item_int_func { const interval_type int_type; @@ -526,10 +527,12 @@ class Item_extract :public Item_int_func void fix_length_and_dec(); }; + 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; } @@ -537,6 +540,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: @@ -553,6 +564,7 @@ public: } }; + class Item_time_typecast :public Item_typecast { public: @@ -569,6 +581,7 @@ public: } }; + class Item_datetime_typecast :public Item_typecast { public: diff --git a/sql/lex.h b/sql/lex.h index 0d0d60fe204..1f83423a0ba 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -221,6 +221,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}, @@ -417,7 +419,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)}, { "CENTROID", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_centroid)}, { "CHAR_LENGTH", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_char_length)}, diff --git a/sql/mysqld.cc b/sql/mysqld.cc index ebda24b404a..86da0e846a0 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4498,7 +4498,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), else { struct hostent *ent; - if (!argument || !argument[0]) + if (argument || argument[0]) ent=gethostbyname(argument); else { @@ -4687,7 +4687,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), } return 0; } - /* Initiates DEBUG - but no debugging here ! */ static void get_options(int argc,char **argv) diff --git a/sql/opt_range.cc b/sql/opt_range.cc index b6f81ab07eb..1e5bb5a4cf9 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -937,8 +937,11 @@ get_mm_leaf(PARAM *param, Field *field, KEY_PART *key_part, if (!(res= value->val_str(&tmp))) DBUG_RETURN(&null_element); - // Check if this was a function. This should have be optimized away - // in the sql_select.cc + /* + TODO: + Check if this was a function. This should have be optimized away + in the sql_select.cc + */ if (res != &tmp) { tmp.copy(*res); // Get own copy @@ -1007,8 +1010,10 @@ get_mm_leaf(PARAM *param, Field *field, KEY_PART *key_part, type != Item_func::EQUAL_FUNC) DBUG_RETURN(0); // Can't optimize this - /* We can't always use indexes when comparing a string index to a number */ - /* cmp_type() is checked to allow compare of dates to numbers */ + /* + We can't always use indexes when comparing a string index to a number + cmp_type() is checked to allow compare of dates to numbers + */ if (field->result_type() == STRING_RESULT && value->result_type() != STRING_RESULT && field->cmp_type() != value->result_type()) @@ -1016,6 +1021,7 @@ get_mm_leaf(PARAM *param, Field *field, KEY_PART *key_part, if (value->save_in_field(field) > 0) { + /* This happens when we try to insert a NULL field in a not null column */ // TODO; Check if we can we remove the following block. if (type == Item_func::EQUAL_FUNC) { @@ -1027,7 +1033,7 @@ get_mm_leaf(PARAM *param, Field *field, KEY_PART *key_part, *str = 1; DBUG_RETURN(new SEL_ARG(field,str,str)); } - DBUG_RETURN(&null_element); // NULL is never true + DBUG_RETURN(&null_element); // cmp with NULL is never true } // Get local copy of key char *str= (char*) alloc_root(param->mem_root, @@ -1035,7 +1041,7 @@ get_mm_leaf(PARAM *param, Field *field, KEY_PART *key_part, if (!str) DBUG_RETURN(0); if (maybe_null) - *str=0; // Not NULL + *str= (char) field->is_real_null(); // Set to 1 if null field->get_key_image(str+maybe_null,key_part->part_length, key_part->image_type); if (!(tree=new SEL_ARG(field,str,str))) DBUG_RETURN(0); diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index c9e10b5b0b5..16d6b6d4631 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -180,14 +180,12 @@ cleanup: if (ha_autocommit_or_rollback(thd,error >= 0)) error=1; } + /* - Only invalidate the query cache if something changed or if we - didn't commit the transacion (query cache is automaticly - invalidated on commit) + Store table for future invalidation or invalidate it in + the query cache if something changed */ - if (deleted && - (!transactional_table || - thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) + if (deleted) { query_cache_invalidate3(thd, table_list, 1); } diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 6cb146afb33..c8a29dcd8da 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -319,13 +319,10 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List<Item> &fields, error=ha_autocommit_or_rollback(thd,error); /* - Only invalidate the query cache if something changed or if we - didn't commit the transacion (query cache is automaticly - invalidated on commit) + Store table for future invalidation or invalidate it in + the query cache if something changed */ - if ((info.copied || info.deleted) && - (!transactional_table || - thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) + if (info.copied || info.deleted) { query_cache_invalidate3(thd, table_list, 1); } diff --git a/sql/sql_update.cc b/sql/sql_update.cc index e3e0bca9856..f2a24eda530 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -319,14 +319,12 @@ int mysql_update(THD *thd, if (ha_autocommit_or_rollback(thd, error >= 0)) error=1; } + /* - Only invalidate the query cache if something changed or if we - didn't commit the transacion (query cache is automaticly - invalidated on commit) + Store table for future invalidation or invalidate it in + the query cache if something changed */ - if (updated && - (!transactional_table || - thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) + if (updated) { query_cache_invalidate3(thd, table_list, 1); } diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index f79bf37d2f7..d645fbf7408 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -991,7 +991,7 @@ field_list: field_list_item: - field_spec + field_spec check_constraint | field_spec references { Lex->col_list.empty(); /* Alloced by sql_alloc */ @@ -1013,10 +1013,16 @@ field_list_item: lex->fk_match_option)); 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 */ @@ -2270,13 +2276,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>); } @@ -2813,7 +2821,7 @@ table_name: { if (!Select->add_table_to_list($1, NULL, 1)) YYABORT; }; if_exists: - /* empty */ { $$=0; } + /* empty */ { $$= 0; } | IF EXISTS { $$= 1; } ; @@ -3587,7 +3595,6 @@ keyword: | CHANGED {} | CHARSET {} | CHECKSUM_SYM {} - | CHECK_SYM {} | CIPHER_SYM {} | CLIENT_SYM {} | CLOSE_SYM {} |