diff options
author | unknown <konstantin@mysql.com> | 2005-11-25 13:57:13 +0300 |
---|---|---|
committer | unknown <konstantin@mysql.com> | 2005-11-25 13:57:13 +0300 |
commit | 61e454c0a9758a2c12fc8b949706d6f356a02041 (patch) | |
tree | cee4e8f13e8c0b9e324e58db5a2e995b60fe5ea0 /sql | |
parent | 1be7a7afa58d241895e73a45292c4a111c98a74c (diff) | |
parent | 2a1ae3a5e3cbc7bb076c91ba0f8b5e6242319b28 (diff) | |
download | mariadb-git-61e454c0a9758a2c12fc8b949706d6f356a02041.tar.gz |
Merge mysql.com:/opt/local/work/mysql-4.1-root
into mysql.com:/opt/local/work/mysql-5.0-root
mysql-test/r/ndb_alter_table.result:
Auto merged
mysql-test/r/ndb_basic.result:
Auto merged
mysql-test/t/select.test:
Auto merged
sql/handler.cc:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/table.cc:
Auto merged
vio/vio.c:
Auto merged
vio/viossl.c:
Auto merged
include/my_base.h:
Manual merge.
mysql-test/r/ps.result:
Manual merge.
mysql-test/r/select.result:
Manual merge.
mysql-test/t/ndb_alter_table.test:
Manual merge.
mysql-test/t/ndb_basic.test:
Manual merge.
mysql-test/t/ps.test:
Manual merge.
sql-common/client.c:
k
sql/ha_ndbcluster.cc:
Manual merge.
sql/item.cc:
Manual merge.
sql/sql_table.cc:
Manual merge.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/ha_ndbcluster.cc | 22 | ||||
-rw-r--r-- | sql/item.cc | 12 | ||||
-rw-r--r-- | sql/mysql_priv.h | 2 | ||||
-rw-r--r-- | sql/sql_table.cc | 30 | ||||
-rw-r--r-- | sql/table.cc | 6 |
5 files changed, 53 insertions, 19 deletions
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index cdd406d473c..1156ba1317f 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -3332,17 +3332,20 @@ int ha_ndbcluster::external_lock(THD *thd, int lock_type) DBUG_PRINT("info", ("Table schema version: %d", tab->getObjectVersion())); } - if (m_table != (void *)tab) - { - m_table= (void *)tab; - m_table_version = tab->getObjectVersion(); - } - else if (m_table_version < tab->getObjectVersion()) + if (m_table_version < tab->getObjectVersion()) { /* The table has been altered, caller has to retry */ - DBUG_RETURN(my_errno= HA_ERR_TABLE_DEF_CHANGED); + NdbError err= ndb->getNdbError(NDB_INVALID_SCHEMA_OBJECT); + DBUG_RETURN(ndb_to_mysql_error(&err)); + } + if (m_table != (void *)tab) + { + m_table= (void *)tab; + m_table_version = tab->getObjectVersion(); + if (!(my_errno= build_index_list(ndb, table, ILBP_OPEN))) + DBUG_RETURN(my_errno); } m_table_info= tab_info; } @@ -3880,9 +3883,8 @@ int ha_ndbcluster::create(const char *name, uint pack_length, length, i, pk_length= 0; const void *data, *pack_data; char name2[FN_HEADLEN]; - bool create_from_engine= test(info->table_options & - HA_OPTION_CREATE_FROM_ENGINE); - + bool create_from_engine= (info->table_options & HA_OPTION_CREATE_FROM_ENGINE); + DBUG_ENTER("ha_ndbcluster::create"); DBUG_PRINT("enter", ("name: %s", name)); fn_format(name2, name, "", "",2); // Remove the .frm extension diff --git a/sql/item.cc b/sql/item.cc index 6d5855cd0ca..a091552aa34 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -5260,7 +5260,7 @@ Item_result item_cmp_type(Item_result a,Item_result b) void resolve_const_item(THD *thd, Item **ref, Item *comp_item) { Item *item= *ref; - Item *new_item; + Item *new_item= NULL; if (item->basic_const_item()) return; // Can't be better Item_result res_type=item_cmp_type(comp_item->result_type(), @@ -5293,7 +5293,16 @@ void resolve_const_item(THD *thd, Item **ref, Item *comp_item) break; } case ROW_RESULT: + if (item->type() == Item::ROW_ITEM && comp_item->type() == Item::ROW_ITEM) { + /* + Substitute constants only in Item_rows. Don't affect other Items + with ROW_RESULT (eg Item_singlerow_subselect). + + For such Items more optimal is to detect if it is constant and replace + it with Item_row. This would optimize queries like this: + SELECT * FROM t1 WHERE (a,b) = (SELECT a,b FROM t2 LIMIT 1); + */ Item_row *item_row= (Item_row*) item; Item_row *comp_item_row= (Item_row*) comp_item; uint col; @@ -5311,6 +5320,7 @@ void resolve_const_item(THD *thd, Item **ref, Item *comp_item) resolve_const_item(thd, item_row->addr(col), comp_item_row->el(col)); break; } + /* Fallthrough */ case REAL_RESULT: { // It must REAL_RESULT double result= item->val_real(); diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 4f5a0032531..6a1a65b963a 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1362,7 +1362,7 @@ int calc_weekday(long daynr,bool sunday_first_day_of_week); uint calc_week(TIME *l_time, uint week_behaviour, uint *year); void find_date(char *pos,uint *vek,uint flag); TYPELIB *convert_strings_to_array_type(my_string *typelibs, my_string *end); -TYPELIB *typelib(List<String> &strings); +TYPELIB *typelib(MEM_ROOT *mem_root, List<String> &strings); ulong get_form_pos(File file, uchar *head, TYPELIB *save_names); ulong make_new_entry(File file,uchar *fileinfo,TYPELIB *formnames, const char *newname); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index e8ffdc23ec5..03ed0fe4e66 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -725,7 +725,14 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, */ if (!interval) { - interval= sql_field->interval= typelib(sql_field->interval_list); + /* + Create the typelib in prepared statement memory if we're + executing one. + */ + MEM_ROOT *stmt_root= thd->current_arena->mem_root; + + interval= sql_field->interval= typelib(stmt_root, + sql_field->interval_list); List_iterator<String> it(sql_field->interval_list); String conv, *tmp; for (uint i= 0; (tmp= it++); i++) @@ -736,7 +743,7 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, { uint cnv_errs; conv.copy(tmp->ptr(), tmp->length(), tmp->charset(), cs, &cnv_errs); - interval->type_names[i]= strmake_root(thd->mem_root, conv.ptr(), + interval->type_names[i]= strmake_root(stmt_root, conv.ptr(), conv.length()); interval->type_lengths[i]= conv.length(); } @@ -756,8 +763,23 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, */ if (sql_field->def && cs != sql_field->def->collation.collation) { - if (!(sql_field->def= - sql_field->def->safe_charset_converter(cs))) + Item_arena backup_arena; + bool need_to_change_arena= + !thd->current_arena->is_conventional_execution(); + if (need_to_change_arena) + { + /* Asser that we don't do that at every PS execute */ + DBUG_ASSERT(thd->current_arena->is_first_stmt_execute() || + thd->current_arena->is_first_sp_execute()); + thd->set_n_backup_item_arena(thd->current_arena, &backup_arena); + } + + sql_field->def= sql_field->def->safe_charset_converter(cs); + + if (need_to_change_arena) + thd->restore_backup_item_arena(thd->current_arena, &backup_arena); + + if (! sql_field->def) { /* Could not convert */ my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->field_name); diff --git a/sql/table.cc b/sql/table.cc index 8068a839052..8b22610a95e 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1247,15 +1247,15 @@ fix_type_pointers(const char ***array, TYPELIB *point_to_type, uint types, } /* fix_type_pointers */ -TYPELIB *typelib(List<String> &strings) +TYPELIB *typelib(MEM_ROOT *mem_root, List<String> &strings) { - TYPELIB *result=(TYPELIB*) sql_alloc(sizeof(TYPELIB)); + TYPELIB *result= (TYPELIB*) alloc_root(mem_root, sizeof(TYPELIB)); if (!result) return 0; result->count=strings.elements; result->name=""; uint nbytes= (sizeof(char*) + sizeof(uint)) * (result->count + 1); - if (!(result->type_names= (const char**) sql_alloc(nbytes))) + if (!(result->type_names= (const char**) alloc_root(mem_root, nbytes))) return 0; result->type_lengths= (uint*) (result->type_names + result->count + 1); List_iterator<String> it(strings); |