Commit f8cd1e79 authored by monty@narttu.mysql.fi's avatar monty@narttu.mysql.fi

After merge fixes

Fixed bug in Item::set_name()
Fix for memory leak with geometry type
parent 9f200ede
...@@ -262,7 +262,7 @@ show create table t1; ...@@ -262,7 +262,7 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL default '0' `a` int(11) NOT NULL default '0'
) TYPE=HEAP ) TYPE=HEAP CHARSET=latin1
drop table t1; drop table t1;
SET SESSION table_type="gemini"; SET SESSION table_type="gemini";
SELECT @@table_type; SELECT @@table_type;
...@@ -273,6 +273,6 @@ show create table t1; ...@@ -273,6 +273,6 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL default '0' `a` int(11) NOT NULL default '0'
) TYPE=MyISAM ) TYPE=MyISAM CHARSET=latin1
SET SESSION table_type=default; SET SESSION table_type=default;
drop table t1; drop table t1;
...@@ -140,13 +140,13 @@ id parent_id level ...@@ -140,13 +140,13 @@ id parent_id level
1015 102 2 1015 102 2
explain select level from t1 where level=1; explain select level from t1 where level=1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref level level 1 const 12 Using where; Using index 1 SIMPLE t1 ref level level 1 const # Using where; Using index
explain select level,id from t1 where level=1; explain select level,id from t1 where level=1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref level level 1 const 12 Using where; Using index 1 SIMPLE t1 ref level level 1 const # Using where; Using index
explain select level,id,parent_id from t1 where level=1; explain select level,id,parent_id from t1 where level=1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref level level 1 const 12 Using where 1 SIMPLE t1 ref level level 1 const # Using where
select level,id from t1 where level=1; select level,id from t1 where level=1;
level id level id
1 1002 1 1002
...@@ -168,9 +168,9 @@ Table Op Msg_type Msg_text ...@@ -168,9 +168,9 @@ Table Op Msg_type Msg_text
test.t1 optimize error The handler for the table doesn't support optimize test.t1 optimize error The handler for the table doesn't support optimize
show keys from t1; show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 0 PRIMARY 1 id A 87 NULL NULL BTREE t1 0 PRIMARY 1 id A # NULL NULL BTREE
t1 1 parent_id 1 parent_id A 43 NULL NULL BTREE t1 1 parent_id 1 parent_id A # NULL NULL BTREE
t1 1 level 1 level A 6 NULL NULL BTREE t1 1 level 1 level A # NULL NULL BTREE
drop table t1; drop table t1;
CREATE TABLE t1 ( CREATE TABLE t1 (
gesuchnr int(11) DEFAULT '0' NOT NULL, gesuchnr int(11) DEFAULT '0' NOT NULL,
......
slave stop; stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master; reset master;
reset slave; reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
slave start; start slave;
stop slave; stop slave;
create table t1 (a int); create table t1 (a int);
reset slave; reset slave;
......
...@@ -22,6 +22,8 @@ drop table t1; ...@@ -22,6 +22,8 @@ drop table t1;
# #
# A bit bigger test # A bit bigger test
# The 'replace_result' statements are needed because the cardinality calculated
# by innodb is not always the same between runs
# #
CREATE TABLE t1 ( CREATE TABLE t1 (
...@@ -43,12 +45,16 @@ update ignore t1 set id=id+1; # This will change all rows ...@@ -43,12 +45,16 @@ update ignore t1 set id=id+1; # This will change all rows
select * from t1; select * from t1;
update ignore t1 set id=1023 where id=1010; update ignore t1 set id=1023 where id=1010;
select * from t1 where parent_id=102; select * from t1 where parent_id=102;
--replace_result 12 # 6 #
explain select level from t1 where level=1; explain select level from t1 where level=1;
--replace_result 12 # 6 #
explain select level,id from t1 where level=1; explain select level,id from t1 where level=1;
--replace_result 12 # 6 #
explain select level,id,parent_id from t1 where level=1; explain select level,id,parent_id from t1 where level=1;
select level,id from t1 where level=1; select level,id from t1 where level=1;
select level,id,parent_id from t1 where level=1; select level,id,parent_id from t1 where level=1;
optimize table t1; optimize table t1;
--replace_result 87 # 48 # 43 # 24 # 6 # 3 #
show keys from t1; show keys from t1;
drop table t1; drop table t1;
......
...@@ -1049,7 +1049,8 @@ int ha_myisam::create(const char *name, register TABLE *table_arg, ...@@ -1049,7 +1049,8 @@ int ha_myisam::create(const char *name, register TABLE *table_arg,
&recinfo,(table_arg->fields*2+2)*sizeof(MI_COLUMNDEF), &recinfo,(table_arg->fields*2+2)*sizeof(MI_COLUMNDEF),
&keydef, table_arg->keys*sizeof(MI_KEYDEF), &keydef, table_arg->keys*sizeof(MI_KEYDEF),
&keyseg, &keyseg,
((table_arg->key_parts + table_arg->keys) * sizeof(HA_KEYSEG)), ((table_arg->key_parts + table_arg->keys) *
sizeof(HA_KEYSEG)),
0))) 0)))
DBUG_RETURN(1); DBUG_RETURN(1);
...@@ -1107,7 +1108,8 @@ int ha_myisam::create(const char *name, register TABLE *table_arg, ...@@ -1107,7 +1108,8 @@ int ha_myisam::create(const char *name, register TABLE *table_arg,
keydef[i].seg[j].null_bit=0; keydef[i].seg[j].null_bit=0;
keydef[i].seg[j].null_pos=0; keydef[i].seg[j].null_pos=0;
} }
if ((field->type() == FIELD_TYPE_BLOB) || (field->type() == FIELD_TYPE_GEOMETRY)) if (field->type() == FIELD_TYPE_BLOB ||
field->type() == FIELD_TYPE_GEOMETRY)
{ {
keydef[i].seg[j].flag|=HA_BLOB_PART; keydef[i].seg[j].flag|=HA_BLOB_PART;
/* save number of bytes used to pack length */ /* save number of bytes used to pack length */
......
...@@ -93,13 +93,15 @@ bool Item::check_cols(uint c) ...@@ -93,13 +93,15 @@ bool Item::check_cols(uint c)
void Item::set_name(const char *str,uint length, CHARSET_INFO *cs) void Item::set_name(const char *str,uint length, CHARSET_INFO *cs)
{ {
if (!length) if (!length)
length= str ? strlen(str) : 0; name= (char*) str; // Empty string, used by AS
else
{
while (length && !my_isgraph(cs,*str)) while (length && !my_isgraph(cs,*str))
{ // Fix problem with yacc { // Fix problem with yacc
length--; length--;
str++; str++;
} }
if (!my_charset_same(cs, system_charset_info)) if (length && !my_charset_same(cs, system_charset_info))
{ {
String tmp; String tmp;
tmp.copy(str, length, cs, system_charset_info); tmp.copy(str, length, cs, system_charset_info);
...@@ -107,6 +109,7 @@ void Item::set_name(const char *str,uint length, CHARSET_INFO *cs) ...@@ -107,6 +109,7 @@ void Item::set_name(const char *str,uint length, CHARSET_INFO *cs)
} }
else else
name=sql_strmake(str,min(length,MAX_FIELD_WIDTH)); name=sql_strmake(str,min(length,MAX_FIELD_WIDTH));
}
} }
/* /*
......
...@@ -152,7 +152,7 @@ void create_random_string(int length,struct rand_struct *rand_st,char *target) ...@@ -152,7 +152,7 @@ void create_random_string(int length,struct rand_struct *rand_st,char *target)
char *end=target+length; char *end=target+length;
/* Use pointer arithmetics as it is faster way to do so. */ /* Use pointer arithmetics as it is faster way to do so. */
for (; target<end ; target++) for (; target<end ; target++)
*target= (char) (rnd(rand_st)*94+33); *target= (char) (my_rnd(rand_st)*94+33);
} }
...@@ -293,7 +293,7 @@ void make_scrambled_password(char *to,const char *password, ...@@ -293,7 +293,7 @@ void make_scrambled_password(char *to,const char *password,
{ {
to[0]=PVERSION41_CHAR; /* New passwords have version prefix */ to[0]=PVERSION41_CHAR; /* New passwords have version prefix */
/* Rnd returns number from 0 to 1 so this would be good salt generation.*/ /* Rnd returns number from 0 to 1 so this would be good salt generation.*/
salt=(unsigned short) (rnd(rand_st)*65535+1); salt=(unsigned short) (my_rnd(rand_st)*65535+1);
/* Use only 2 first bytes from it */ /* Use only 2 first bytes from it */
sprintf(to+1,"%04x",salt); sprintf(to+1,"%04x",salt);
/* First hasing is done without salt */ /* First hasing is done without salt */
......
...@@ -597,7 +597,7 @@ multi_update::initialize_tables(JOIN *join) ...@@ -597,7 +597,7 @@ multi_update::initialize_tables(JOIN *join)
/* ok to be on stack as this is not referenced outside of this func */ /* ok to be on stack as this is not referenced outside of this func */
Field_string offset(table->file->ref_length, 0, "offset", Field_string offset(table->file->ref_length, 0, "offset",
table, 1, &my_charset_bin); table, &my_charset_bin);
if (temp_fields.push_front(new Item_field(((Field *) &offset)))) if (temp_fields.push_front(new Item_field(((Field *) &offset))))
DBUG_RETURN(1); DBUG_RETURN(1);
......
...@@ -515,6 +515,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, ...@@ -515,6 +515,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
keyinfo->key_length+= HA_KEY_NULL_LENGTH; keyinfo->key_length+= HA_KEY_NULL_LENGTH;
} }
if (field->type() == FIELD_TYPE_BLOB || if (field->type() == FIELD_TYPE_BLOB ||
field->type() == FIELD_TYPE_GEOMETRY ||
field->real_type() == FIELD_TYPE_VAR_STRING) field->real_type() == FIELD_TYPE_VAR_STRING)
{ {
if (field->type() == FIELD_TYPE_BLOB) if (field->type() == FIELD_TYPE_BLOB)
...@@ -531,7 +532,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, ...@@ -531,7 +532,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
if (i == 0) if (i == 0)
field->key_start|= ((key_map) 1 << key); field->key_start|= ((key_map) 1 << key);
if (field->key_length() == key_part->length && if (field->key_length() == key_part->length &&
field->type() != FIELD_TYPE_BLOB) !(field->flags & BLOB_FLAG))
{ {
if ((index_flags & HA_KEY_READ_ONLY) && if ((index_flags & HA_KEY_READ_ONLY) &&
(field->key_type() != HA_KEYTYPE_TEXT || (field->key_type() != HA_KEYTYPE_TEXT ||
...@@ -560,7 +561,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, ...@@ -560,7 +561,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
if (field->key_length() != key_part->length) if (field->key_length() != key_part->length)
{ {
key_part->key_part_flag|= HA_PART_KEY; key_part->key_part_flag|= HA_PART_KEY;
if (field->type() != FIELD_TYPE_BLOB) if (!(field->flags & BLOB_FLAG))
{ // Create a new field { // Create a new field
field=key_part->field=field->new_field(&outparam->mem_root, field=key_part->field=field->new_field(&outparam->mem_root,
outparam); outparam);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment