diff options
author | bell@sanja.is.com.ua <> | 2005-03-30 22:11:08 +0300 |
---|---|---|
committer | bell@sanja.is.com.ua <> | 2005-03-30 22:11:08 +0300 |
commit | c64efa6062134675c6cb057fc7412ef1ea3a7a56 (patch) | |
tree | b0584ee1fd2d58e2712a368e83df6dab6bba725d | |
parent | dcdda90a116150f8facceeba75c173451fdc7cf7 (diff) | |
parent | 86e3a378ea6e304af41208401c34fa25f4b049c8 (diff) | |
download | mariadb-git-c64efa6062134675c6cb057fc7412ef1ea3a7a56.tar.gz |
merge
-rw-r--r-- | include/violite.h | 4 | ||||
-rw-r--r-- | mysql-test/r/ctype_cp1251.result | 4 | ||||
-rw-r--r-- | mysql-test/r/group_by.result | 25 | ||||
-rw-r--r-- | mysql-test/t/ctype_cp1251-master.opt | 2 | ||||
-rw-r--r-- | mysql-test/t/ctype_cp1251.test | 4 | ||||
-rw-r--r-- | mysql-test/t/group_by.test | 25 | ||||
-rw-r--r-- | sql/sql_parse.cc | 11 | ||||
-rw-r--r-- | sql/sql_select.cc | 44 | ||||
-rw-r--r-- | sql/table.h | 4 | ||||
-rw-r--r-- | strings/my_strtoll10-x86.s | 2 | ||||
-rw-r--r-- | vio/test-ssl.c | 4 | ||||
-rw-r--r-- | vio/test-sslclient.c | 4 |
12 files changed, 98 insertions, 35 deletions
diff --git a/include/violite.h b/include/violite.h index 855d8a3d490..b89b01f95f4 100644 --- a/include/violite.h +++ b/include/violite.h @@ -138,8 +138,8 @@ int vio_close_shared_memory(Vio * vio); #if defined(HAVE_VIO) && !defined(DONT_MAP_VIO) #define vio_delete(vio) (vio)->viodelete(vio) #define vio_errno(vio) (vio)->vioerrno(vio) -#define vio_read(vio, buf, size) (vio)->read(vio,buf,size) -#define vio_write(vio, buf, size) (vio)->write(vio, buf, size) +#define vio_read(vio, buf, size) ((vio)->read)(vio,buf,size) +#define vio_write(vio, buf, size) ((vio)->write)(vio, buf, size) #define vio_blocking(vio, set_blocking_mode, old_mode)\ (vio)->vioblocking(vio, set_blocking_mode, old_mode) #define vio_is_blocking(vio) (vio)->is_blocking(vio) diff --git a/mysql-test/r/ctype_cp1251.result b/mysql-test/r/ctype_cp1251.result index 647f8c6236c..c65055e726d 100644 --- a/mysql-test/r/ctype_cp1251.result +++ b/mysql-test/r/ctype_cp1251.result @@ -1,6 +1,6 @@ drop table if exists t1; SET NAMES cp1251; -create table t1 (a varchar(10) not null); +create table t1 (a varchar(10) not null) character set cp1251; insert into t1 values ("a"),("ab"),("abc"); select * from t1; a @@ -23,7 +23,7 @@ a b c drop table t1; -create table t1 (a char(15) binary, b binary(15)); +create table t1 (a char(15) binary, b binary(15)) character set cp1251; insert into t1 values ('aaa','bbb'),('AAA','BBB'); select upper(a),upper(b) from t1; upper(a) upper(b) diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result index 7f365eac58a..e4904bb7a04 100644 --- a/mysql-test/r/group_by.result +++ b/mysql-test/r/group_by.result @@ -677,3 +677,28 @@ select sum(a)*sum(b) as d from t1 where a=1 group by c having d > 0; d 10 drop table t1; +create table t1(a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(8),(9); +create table t2 ( +a int, +b varchar(200) NOT NULL, +c varchar(50) NOT NULL, +d varchar(100) NOT NULL, +primary key (a,b(132),c,d), +key a (a,b) +) charset=utf8; +insert into t2 select +x3.a, -- 3 +concat('val-', x3.a + 3*x4.a), -- 12 +concat('val-', @a:=x3.a + 3*x4.a + 12*C.a), -- 120 +concat('val-', @a + 120*D.a) +from t1 x3, t1 x4, t1 C, t1 D where x3.a < 3 and x4.a < 4 and D.a < 4; +delete from t2 where a = 2 and b = 'val-2' limit 30; +explain select c from t2 where a = 2 and b = 'val-2' group by c; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref PRIMARY,a PRIMARY 400 const,const 6 Using where +select c from t2 where a = 2 and b = 'val-2' group by c; +c +val-74 +val-98 +drop table t1,t2; diff --git a/mysql-test/t/ctype_cp1251-master.opt b/mysql-test/t/ctype_cp1251-master.opt deleted file mode 100644 index af089d9f176..00000000000 --- a/mysql-test/t/ctype_cp1251-master.opt +++ /dev/null @@ -1,2 +0,0 @@ ---default-character-set=cp1251 --new - diff --git a/mysql-test/t/ctype_cp1251.test b/mysql-test/t/ctype_cp1251.test index 2d670ec3607..76873e6fa0e 100644 --- a/mysql-test/t/ctype_cp1251.test +++ b/mysql-test/t/ctype_cp1251.test @@ -10,7 +10,7 @@ SET NAMES cp1251; # Test problem with LEFT() (Bug #514) # -create table t1 (a varchar(10) not null); +create table t1 (a varchar(10) not null) character set cp1251; insert into t1 values ("a"),("ab"),("abc"); select * from t1; select a, left(a,1) as b from t1; @@ -21,7 +21,7 @@ drop table t1; # # Test of binary and upper/lower # -create table t1 (a char(15) binary, b binary(15)); +create table t1 (a char(15) binary, b binary(15)) character set cp1251; insert into t1 values ('aaa','bbb'),('AAA','BBB'); select upper(a),upper(b) from t1; select lower(a),lower(b) from t1; diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index afd479c520e..327be1b724b 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -489,3 +489,28 @@ select a,sum(b) from t1 where a=1 group by c having a=1; select a as d,sum(b) from t1 where a=1 group by c having d=1; select sum(a)*sum(b) as d from t1 where a=1 group by c having d > 0; drop table t1; + +# Test for BUG#9213 GROUP BY query on utf-8 key returns wrong results +create table t1(a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(8),(9); +create table t2 ( + a int, + b varchar(200) NOT NULL, + c varchar(50) NOT NULL, + d varchar(100) NOT NULL, + primary key (a,b(132),c,d), + key a (a,b) +) charset=utf8; + +insert into t2 select + x3.a, -- 3 + concat('val-', x3.a + 3*x4.a), -- 12 + concat('val-', @a:=x3.a + 3*x4.a + 12*C.a), -- 120 + concat('val-', @a + 120*D.a) +from t1 x3, t1 x4, t1 C, t1 D where x3.a < 3 and x4.a < 4 and D.a < 4; +delete from t2 where a = 2 and b = 'val-2' limit 30; + +explain select c from t2 where a = 2 and b = 'val-2' group by c; +select c from t2 where a = 2 and b = 'val-2' group by c; +drop table t1,t2; + diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 09579432856..86544f72316 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3731,6 +3731,7 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv, db ? db : "", want_access, thd->master_access)); #ifndef NO_EMBEDDED_ACCESS_CHECKS ulong db_access; + bool db_is_pattern= test(want_access & GRANT_ACL); #endif ulong dummy; if (save_priv) @@ -3757,9 +3758,8 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv, */ db_access= thd->db_access; if (!(thd->master_access & SELECT_ACL) && - (db && (!thd->db || strcmp(db,thd->db)))) - db_access=acl_get(thd->host, thd->ip, - thd->priv_user, db, test(want_access & GRANT_ACL)); + (db && (!thd->db || db_is_pattern || strcmp(db,thd->db)))) + db_access=acl_get(thd->host, thd->ip, thd->priv_user, db, db_is_pattern); *save_priv=thd->master_access | db_access; DBUG_RETURN(FALSE); } @@ -3777,9 +3777,8 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv, if (db == any_db) DBUG_RETURN(FALSE); // Allow select on anything - if (db && (!thd->db || strcmp(db,thd->db))) - db_access=acl_get(thd->host, thd->ip, - thd->priv_user, db, test(want_access & GRANT_ACL)); + if (db && (!thd->db || db_is_pattern || strcmp(db,thd->db))) + db_access=acl_get(thd->host, thd->ip, thd->priv_user, db, db_is_pattern); else db_access=thd->db_access; DBUG_PRINT("info",("db_access: %lu", db_access)); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 95a7ba514b7..57b09fa40b4 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -4604,14 +4604,14 @@ const_expression_in_where(COND *cond, Item *comp_item, Item **const_item) create_tmp_field_from_field() thd Thread handler org_field field from which new field will be created + name New field name item Item to create a field for table Temporary table - modify_item 1 if item->result_field should point to new item. - This is relevent for how fill_record() is going to - work: - If modify_item is 1 then fill_record() will update + item !=NULL if item->result_field should point to new field. + This is relevant for how fill_record() is going to work: + If item != NULL then fill_record() will update the record in the original table. - If modify_item is 0 then fill_record() will update + If item == NULL then fill_record() will update the temporary table convert_blob_length If >0 create a varstring(convert_blob_length) field instead of blob. @@ -4622,8 +4622,8 @@ const_expression_in_where(COND *cond, Item *comp_item, Item **const_item) */ static Field* create_tmp_field_from_field(THD *thd, Field* org_field, - Item *item, TABLE *table, - bool modify_item, + const char *name, TABLE *table, + Item_field *item, uint convert_blob_length) { Field *new_field; @@ -4636,10 +4636,10 @@ static Field* create_tmp_field_from_field(THD *thd, Field* org_field, new_field= org_field->new_field(thd->mem_root, table); if (new_field) { - if (modify_item) - ((Item_field *)item)->result_field= new_field; + if (item) + item->result_field= new_field; else - new_field->field_name= item->name; + new_field->field_name= name; if (org_field->maybe_null()) new_field->flags&= ~NOT_NULL_FLAG; // Because of outer join if (org_field->type() == FIELD_TYPE_VAR_STRING) @@ -4779,8 +4779,8 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, if (item_sum->args[0]->type() == Item::FIELD_ITEM) { *from_field= ((Item_field*) item_sum->args[0])->field; - return create_tmp_field_from_field(thd, *from_field, item, table, - modify_item, convert_blob_length); + return create_tmp_field_from_field(thd, *from_field, item->name, table, + NULL, convert_blob_length); } /* fall through */ default: @@ -4818,8 +4818,10 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, case Item::DEFAULT_VALUE_ITEM: { Item_field *field= (Item_field*) item; - return create_tmp_field_from_field(thd, (*from_field= field->field), item, - table, modify_item, convert_blob_length); + return create_tmp_field_from_field(thd, (*from_field= field->field), + item->name, table, + modify_item ? (Item_field*) item : NULL, + convert_blob_length); } case Item::FUNC_ITEM: case Item::COND_ITEM: @@ -7174,7 +7176,19 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, /* Found key that can be used to retrieve data in sorted order */ if (tab->ref.key >= 0) { - tab->ref.key= new_ref_key; + /* + We'll use ref access method on key new_ref_key. In general case + the index search tuple for new_ref_key will be different (e.g. + when one of the indexes only covers prefix of the field, see + BUG#9213 in group_by.test). + So we build tab->ref from scratch here. + */ + KEYUSE *keyuse= tab->keyuse; + while (keyuse->key != new_ref_key && keyuse->table == tab->table) + keyuse++; + if (create_ref_for_key(tab->join, tab, keyuse, + tab->join->const_table_map)) + DBUG_RETURN(0); } else { diff --git a/sql/table.h b/sql/table.h index eed9969dac8..054f24267b7 100644 --- a/sql/table.h +++ b/sql/table.h @@ -90,7 +90,9 @@ struct st_table { uint null_fields; /* number of null fields */ uint blob_fields; /* number of blob fields */ key_map keys_in_use, keys_for_keyread, read_only_keys; - key_map quick_keys, used_keys, keys_in_use_for_query; + key_map quick_keys; + key_map used_keys; /* keys that cover all used table fields */ + key_map keys_in_use_for_query; KEY *key_info; /* data of keys in database */ TYPELIB keynames; /* Pointers to keynames */ ha_rows max_rows; /* create information */ diff --git a/strings/my_strtoll10-x86.s b/strings/my_strtoll10-x86.s index e89e7ff5989..c04384667a7 100644 --- a/strings/my_strtoll10-x86.s +++ b/strings/my_strtoll10-x86.s @@ -394,7 +394,7 @@ my_strtoll10: popl %ebp ret -my_strtoll10_end: +.my_strtoll10_end: .size my_strtoll10,.my_strtoll10_end-my_strtoll10 .comm res,240,32 .comm end_ptr,120,32 diff --git a/vio/test-ssl.c b/vio/test-ssl.c index 88df6936a1f..a94eb1a21ff 100644 --- a/vio/test-ssl.c +++ b/vio/test-ssl.c @@ -115,7 +115,7 @@ main(int argc, char** argv) { /* child, therefore, client */ char xbuf[100]; - int r = client_vio->read(client_vio,xbuf, sizeof(xbuf)); + int r = vio_read(client_vio,xbuf, sizeof(xbuf)); if (r<=0) { my_free((gptr)ssl_acceptor,MYF(0)); my_free((gptr)ssl_connector,MYF(0)); @@ -130,7 +130,7 @@ main(int argc, char** argv) else { const char* s = "Huhuhuh"; - int r = server_vio->write(server_vio,(gptr)s, strlen(s)); + int r = vio_write(server_vio,(gptr)s, strlen(s)); if (r<=0) { my_free((gptr)ssl_acceptor,MYF(0)); my_free((gptr)ssl_connector,MYF(0)); diff --git a/vio/test-sslclient.c b/vio/test-sslclient.c index 231ce056d8c..3811ba0fb6a 100644 --- a/vio/test-sslclient.c +++ b/vio/test-sslclient.c @@ -77,13 +77,13 @@ main( int argc __attribute__((unused)), sa.sin_port = htons (1111); /* Server Port number */ err = connect(client_vio->sd, (struct sockaddr*) &sa, - sizeof(sa)); + sizeof(sa)); /* ----------------------------------------------- */ /* Now we have TCP conncetion. Start SSL negotiation. */ read(client_vio->sd,xbuf, sizeof(xbuf)); sslconnect(ssl_connector,client_vio,60L); - err = client_vio->read(client_vio,xbuf, sizeof(xbuf)); + err = vio_read(client_vio,xbuf, sizeof(xbuf)); if (err<=0) { my_free((gptr)ssl_connector,MYF(0)); fatal_error("client:SSL_read"); |