diff --git a/extra/yassl/src/handshake.cpp b/extra/yassl/src/handshake.cpp index 45dfb6fa032..d7df438b8df 100644 --- a/extra/yassl/src/handshake.cpp +++ b/extra/yassl/src/handshake.cpp @@ -656,7 +656,11 @@ DoProcessReply(SSL& ssl, mySTL::auto_ptr buffered) { ssl.getSocket().wait(); // wait for input if blocking uint ready = ssl.getSocket().get_ready(); - if (!ready) return buffered; + if (!ready) { + // Nothing to receive after blocking wait => error + ssl.SetError(receive_error); + return buffered= null_buffer; + } // add buffered data if its there uint buffSz = buffered.get() ? buffered.get()->get_size() : 0; diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index 20e6c61c46b..8c0a1dfe753 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -1059,6 +1059,24 @@ where table_name="v1"; table_type VIEW drop view v1; +create temporary table t1(f1 int, index(f1)); +show columns from t1; +Field Type Null Key Default Extra +f1 int(11) YES MUL NULL +describe t1; +Field Type Null Key Default Extra +f1 int(11) YES MUL NULL +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 1 f1 1 f1 A NULL NULL NULL YES BTREE +drop table t1; +create table t1(f1 binary(32), f2 varbinary(64)); +select character_maximum_length, character_octet_length +from information_schema.columns where table_name='t1'; +character_maximum_length character_octet_length +32 32 +64 64 +drop table t1; select * from information_schema.engines WHERE ENGINE="MyISAM"; ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS MyISAM ENABLED Default engine as of MySQL 3.23 with great performance NO NO NO diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result index ff92fc543d4..e0048515fed 100644 --- a/mysql-test/r/trigger.result +++ b/mysql-test/r/trigger.result @@ -780,3 +780,9 @@ end// CALL p2(); drop procedure p2; drop table t1; +create trigger t1_bi before insert on test.t1 for each row set @a:=0; +ERROR 3D000: No database selected +create trigger test.t1_bi before insert on t1 for each row set @a:=0; +ERROR 3D000: No database selected +drop trigger t1_bi; +ERROR 3D000: No database selected diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 3d209e91236..4f6cfe4a310 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -2456,3 +2456,19 @@ f1() 42 drop view v2,v1; drop function f1; +create table t1 (id numeric, warehouse_id numeric); +create view v1 as select id from t1; +create view v2 as +select t1.warehouse_id, v1.id as receipt_id +from t1, v1 where t1.id = v1.id; +insert into t1 (id, warehouse_id) values(3, 2); +insert into t1 (id, warehouse_id) values(4, 2); +insert into t1 (id, warehouse_id) values(5, 1); +select v2.receipt_id as alias1, v2.receipt_id as alias2 from v2 +order by v2.receipt_id; +alias1 alias2 +3 3 +4 4 +5 5 +drop view v2, v1; +drop table t1; diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index 1f4933c9bb4..d61088a3a28 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -749,6 +749,25 @@ select table_type from information_schema.tables where table_name="v1"; drop view v1; +# +# Bug #14387 SHOW COLUMNS doesn't work on temporary tables +# Bug #15224 SHOW INDEX from temporary table doesn't work +# Bug #12770 DESC cannot display the info. about temporary table +# +create temporary table t1(f1 int, index(f1)); +show columns from t1; +describe t1; +show indexes from t1; +drop table t1; + +# +# Bug#14271 I_S: columns has no size for (var)binary columns +# +create table t1(f1 binary(32), f2 varbinary(64)); +select character_maximum_length, character_octet_length +from information_schema.columns where table_name='t1'; +drop table t1; + # # Show engines # diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test index d4fa5268762..b4074897689 100644 --- a/mysql-test/t/trigger.test +++ b/mysql-test/t/trigger.test @@ -13,6 +13,8 @@ drop procedure if exists p1; # Create additional connections used through test connect (addconroot1, localhost, root,,); connect (addconroot2, localhost, root,,); +# Connection without current database set +connect (addconwithoutdb, localhost, root,,*NO-ONE*); connection default; create table t1 (i int); @@ -946,3 +948,16 @@ CALL p2(); drop procedure p2; drop table t1; +# +# Test for bug #14863 "Triggers: crash if create and there is no current +# database". We should not crash and give proper error when database for +# trigger or its table is not specified and there is no current database. +# +connection addconwithoutdb; +--error ER_NO_DB_ERROR +create trigger t1_bi before insert on test.t1 for each row set @a:=0; +--error ER_NO_DB_ERROR +create trigger test.t1_bi before insert on t1 for each row set @a:=0; +--error ER_NO_DB_ERROR +drop trigger t1_bi; +connection default; diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 3a0e33f6aae..4ab2f49280d 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -2323,3 +2323,22 @@ CREATE VIEW v2 AS SELECT f1(); select * from v2; drop view v2,v1; drop function f1; + +# +# Bug#14861: aliased column names are not preserved. +# +create table t1 (id numeric, warehouse_id numeric); +create view v1 as select id from t1; +create view v2 as +select t1.warehouse_id, v1.id as receipt_id +from t1, v1 where t1.id = v1.id; + +insert into t1 (id, warehouse_id) values(3, 2); +insert into t1 (id, warehouse_id) values(4, 2); +insert into t1 (id, warehouse_id) values(5, 1); + +select v2.receipt_id as alias1, v2.receipt_id as alias2 from v2 +order by v2.receipt_id; + +drop view v2, v1; +drop table t1; diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index ab9663db475..12123001463 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -5372,7 +5372,7 @@ ER_WSAS_FAILED eng "WSAStartup Failed" ger "WSAStartup fehlgeschlagen" ER_DIFF_GROUPS_PROC - eng "Can't handle procedures with differents groups yet" + eng "Can't handle procedures with different groups yet" ger "Kann Prozeduren mit unterschiedlichen Gruppen noch nicht verarbeiten" ER_NO_GROUP_FOR_PROC eng "Select must have a group with this procedure" diff --git a/sql/sql_select.cc b/sql/sql_select.cc index f2833f94400..ed54aba91d3 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -8218,7 +8218,7 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, uint convert_blob_length) { Item::Type orig_type= type; - Item *orig_item; + Item *orig_item= 0; if (type != Item::FIELD_ITEM && item->real_item()->type() == Item::FIELD_ITEM && @@ -8271,10 +8271,12 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, } else result= create_tmp_field_from_field(thd, (*from_field= field->field), - item->name, table, - modify_item ? field : - NULL, - convert_blob_length); + orig_item ? orig_item->name : + item->name, + table, + modify_item ? field : + NULL, + convert_blob_length); if (orig_type == Item::REF_ITEM && orig_modify) ((Item_ref*)orig_item)->set_result_field(result); return result; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 7abd625c2a9..ad99191fcb1 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2260,6 +2260,13 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) bool res; lex->all_selects_list= lsel; + /* + Restore thd->temporary_tables to be able to process + temporary tables(only for 'show index' & 'show columns'). + This should be changed when processing of temporary tables for + I_S tables will be done. + */ + thd->temporary_tables= open_tables_state_backup.temporary_tables; res= open_normal_and_derived_tables(thd, show_table_list, MYSQL_LOCK_IGNORE_FLUSH); /* @@ -2279,6 +2286,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) show_table_list->view_db.str : show_table_list->db), show_table_list->alias)); + thd->temporary_tables= 0; close_thread_tables(thd); show_table_list->table= 0; goto err; @@ -2799,7 +2807,9 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables, table->field[6]->store((const char*) pos, strlen((const char*) pos), cs); is_blob= (field->type() == FIELD_TYPE_BLOB); - if (field->has_charset() || is_blob) + if (field->has_charset() || is_blob || + field->real_type() == MYSQL_TYPE_VARCHAR || // For varbinary type + field->real_type() == MYSQL_TYPE_STRING) // For binary type { longlong char_max_len= is_blob ? (longlong) field->max_length() / field->charset()->mbminlen : diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index e91736fd48b..7b501364701 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -78,10 +78,6 @@ const char * const trigname_file_ext= ".TRN"; static File_option trigname_file_parameters[]= { { - /* - FIXME: Length specified for "trigger_table" key is erroneous, problem - caused by this are reported as BUG#14090 and should be fixed ASAP. - */ {(char *) STRING_WITH_LEN("trigger_table")}, offsetof(struct st_trigname, trigger_table), FILE_OPTIONS_ESTRING @@ -155,6 +151,17 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) But do we want this ? */ + /* + Note that once we will have check for TRIGGER privilege in place we won't + need second part of condition below, since check_access() function also + checks that db is specified. + */ + if (!thd->lex->spname->m_db.length || create && !tables->db_length) + { + my_error(ER_NO_DB_ERROR, MYF(0)); + DBUG_RETURN(TRUE); + } + if (!create && !(tables= add_table_for_trigger(thd, thd->lex->spname))) DBUG_RETURN(TRUE); @@ -285,6 +292,9 @@ end: definer. The caller is responsible to provide memory for storing LEX_STRING object. + NOTE + Assumes that trigger name is fully qualified. + RETURN VALUE False - success True - error @@ -308,8 +318,7 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables, /* Trigger must be in the same schema as target table. */ if (my_strcasecmp(table_alias_charset, table->s->db.str, - lex->spname->m_db.str ? lex->spname->m_db.str : - thd->db)) + lex->spname->m_db.str)) { my_error(ER_TRG_IN_WRONG_SCHEMA, MYF(0)); return 1; @@ -1010,7 +1019,6 @@ bool Table_triggers_list::get_trigger_info(THD *thd, trg_event_type event, static TABLE_LIST *add_table_for_trigger(THD *thd, sp_name *trig) { - const char *db= !trig->m_db.str ? thd->db : trig->m_db.str; LEX *lex= thd->lex; char path_buff[FN_REFLEN]; LEX_STRING path; @@ -1018,7 +1026,7 @@ static TABLE_LIST *add_table_for_trigger(THD *thd, sp_name *trig) struct st_trigname trigname; DBUG_ENTER("add_table_for_trigger"); - strxnmov(path_buff, FN_REFLEN-1, mysql_data_home, "/", db, "/", + strxnmov(path_buff, FN_REFLEN-1, mysql_data_home, "/", trig->m_db.str, "/", trig->m_name.str, trigname_file_ext, NullS); path.length= unpack_filename(path_buff, path_buff); path.str= path_buff; @@ -1047,7 +1055,7 @@ static TABLE_LIST *add_table_for_trigger(THD *thd, sp_name *trig) /* We need to reset statement table list to be PS/SP friendly. */ lex->query_tables= 0; lex->query_tables_last= &lex->query_tables; - DBUG_RETURN(sp_add_to_query_tables(thd, lex, db, + DBUG_RETURN(sp_add_to_query_tables(thd, lex, trig->m_db.str, trigname.trigger_table.str, TL_WRITE)); } diff --git a/storage/ndb/src/kernel/blocks/backup/Backup.cpp b/storage/ndb/src/kernel/blocks/backup/Backup.cpp index 87b4bdb4a5d..716173be55d 100644 --- a/storage/ndb/src/kernel/blocks/backup/Backup.cpp +++ b/storage/ndb/src/kernel/blocks/backup/Backup.cpp @@ -3883,7 +3883,7 @@ Backup::checkFile(Signal* signal, BackupFilePtr filePtr) req->userReference = reference(); req->varIndex = 0; req->offset = tmp - c_startOfPages; - req->size = sz; // Avrunda uppot + req->size = sz; // Round up sendSignal(NDBFS_REF, GSN_FSAPPENDREQ, signal, FsAppendReq::SignalLength, JBA); diff --git a/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp b/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp index 0f97bc3dfe4..cd923b83978 100644 --- a/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp +++ b/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp @@ -11188,7 +11188,11 @@ void Dbdih::initCommonData() cnoReplicas = 1; ndb_mgm_get_int_parameter(p, CFG_DB_NO_REPLICAS, &cnoReplicas); - cnoReplicas = cnoReplicas > 4 ? 4 : cnoReplicas; + if (cnoReplicas > 4) + { + progError(__LINE__, NDBD_EXIT_INVALID_CONFIG, + "Only up to four replicas are supported. Check NoOfReplicas."); + } cgcpDelay = 2000; ndb_mgm_get_int_parameter(p, CFG_DB_GCP_INTERVAL, &cgcpDelay); @@ -11778,14 +11782,14 @@ void Dbdih::execCHECKNODEGROUPSREQ(Signal* signal) break; case CheckNodeGroups::GetNodeGroupMembers: { ok = true; - Uint32 ownNodeGoup = + Uint32 ownNodeGroup = Sysfile::getNodeGroup(sd->nodeId, SYSFILE->nodeGroups); - sd->output = ownNodeGoup; + sd->output = ownNodeGroup; sd->mask.clear(); NodeGroupRecordPtr ngPtr; - ngPtr.i = ownNodeGoup; + ngPtr.i = ownNodeGroup; ptrAss(ngPtr, nodeGroupRecord); for (Uint32 j = 0; j < ngPtr.p->nodeCount; j++) { jam(); @@ -11793,7 +11797,7 @@ void Dbdih::execCHECKNODEGROUPSREQ(Signal* signal) } #if 0 for (int i = 0; i < MAX_NDB_NODES; i++) { - if (ownNodeGoup == + if (ownNodeGroup == Sysfile::getNodeGroup(i, SYSFILE->nodeGroups)) { sd->mask.set(i); } diff --git a/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp b/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp index 7505065456d..c9e13186909 100644 --- a/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp +++ b/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp @@ -17687,60 +17687,54 @@ void Dblqh::execCREATE_TRIG_REQ(Signal* signal) { jamEntry(); - NodeId myNodeId = getOwnNodeId(); - BlockReference tupref = calcTupBlockRef(myNodeId); - sendSignal(tupref, GSN_CREATE_TRIG_REQ, signal, CreateTrigReq::SignalLength, JBB); + sendSignal(DBTUP_REF, GSN_CREATE_TRIG_REQ, signal, + CreateTrigReq::SignalLength, JBB); } void Dblqh::execCREATE_TRIG_CONF(Signal* signal) { jamEntry(); - NodeId myNodeId = getOwnNodeId(); - BlockReference dictref = calcDictBlockRef(myNodeId); - sendSignal(dictref, GSN_CREATE_TRIG_CONF, signal, CreateTrigConf::SignalLength, JBB); + sendSignal(DBDICT_REF, GSN_CREATE_TRIG_CONF, signal, + CreateTrigConf::SignalLength, JBB); } void Dblqh::execCREATE_TRIG_REF(Signal* signal) { jamEntry(); - NodeId myNodeId = getOwnNodeId(); - BlockReference dictref = calcDictBlockRef(myNodeId); - sendSignal(dictref, GSN_CREATE_TRIG_REF, signal, CreateTrigRef::SignalLength, JBB); + sendSignal(DBDICT_REF, GSN_CREATE_TRIG_REF, signal, + CreateTrigRef::SignalLength, JBB); } void Dblqh::execDROP_TRIG_REQ(Signal* signal) { jamEntry(); - NodeId myNodeId = getOwnNodeId(); - BlockReference tupref = calcTupBlockRef(myNodeId); - sendSignal(tupref, GSN_DROP_TRIG_REQ, signal, DropTrigReq::SignalLength, JBB); + sendSignal(DBTUP_REF, GSN_DROP_TRIG_REQ, signal, + DropTrigReq::SignalLength, JBB); } void Dblqh::execDROP_TRIG_CONF(Signal* signal) { jamEntry(); - NodeId myNodeId = getOwnNodeId(); - BlockReference dictref = calcDictBlockRef(myNodeId); - sendSignal(dictref, GSN_DROP_TRIG_CONF, signal, DropTrigConf::SignalLength, JBB); + sendSignal(DBDICT_REF, GSN_DROP_TRIG_CONF, signal, + DropTrigConf::SignalLength, JBB); } void Dblqh::execDROP_TRIG_REF(Signal* signal) { jamEntry(); - NodeId myNodeId = getOwnNodeId(); - BlockReference dictref = calcDictBlockRef(myNodeId); - sendSignal(dictref, GSN_DROP_TRIG_REF, signal, DropTrigRef::SignalLength, JBB); + sendSignal(DBDICT_REF, GSN_DROP_TRIG_REF, signal, + DropTrigRef::SignalLength, JBB); } Uint32 Dblqh::calcPageCheckSum(LogPageRecordPtr logP){ diff --git a/storage/ndb/tools/ndb_size.pl b/storage/ndb/tools/ndb_size.pl index ece0901e0b2..e0085c619f0 100644 --- a/storage/ndb/tools/ndb_size.pl +++ b/storage/ndb/tools/ndb_size.pl @@ -146,9 +146,9 @@ foreach(@{$tables}) elsif($type =~ /varchar/ || $type =~ /varbinary/) { my $fixed= 1+$size; - my @dynamic=$dbh->selectrow_array("select avg(length(" - .$dbh->quote($name) - .")) from `".$table.'`'); + my @dynamic=$dbh->selectrow_array("select avg(length(`" + .$name. + ."`)) from `".$table.'`'); $dynamic[0]=0 if !$dynamic[0]; @realsize= ($fixed,$fixed,ceil($dynamic[0])); }