summaryrefslogtreecommitdiff
path: root/sql/table.cc
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2003-12-19 16:34:48 +0200
committerunknown <monty@mysql.com>2003-12-19 16:34:48 +0200
commitde8b2bbd301a17a7a02ea62cff806950071dfbce (patch)
tree05b144ca850fc0bb99c1922907bfb2e9ba19fc77 /sql/table.cc
parent5372bc432d3ecc476c777d24dd393a9f2c51ea4d (diff)
parentc9f5145abb9815220b51a9707c6ede0c77b3e1f0 (diff)
downloadmariadb-git-de8b2bbd301a17a7a02ea62cff806950071dfbce.tar.gz
merge
client/mysqldump.c: Auto merged client/mysqltest.c: Auto merged include/my_global.h: Auto merged libmysqld/lib_sql.cc: Auto merged mysql-test/r/warnings.result: Auto merged mysql-test/t/type_enum.test: Auto merged sql/field.cc: Auto merged sql/lex.h: Auto merged sql/mysql_priv.h: Auto merged sql/mysqld.cc: Auto merged sql/set_var.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_show.cc: Auto merged sql/sql_table.cc: Auto merged sql/sql_yacc.yy: Auto merged sql/table.cc: Auto merged
Diffstat (limited to 'sql/table.cc')
-rw-r--r--sql/table.cc30
1 files changed, 21 insertions, 9 deletions
diff --git a/sql/table.cc b/sql/table.cc
index 7c12762d9c4..912c133e571 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -507,14 +507,17 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
if (primary_key >= MAX_KEY && (keyinfo->flags & HA_NOSAME))
{
/*
- If the UNIQUE key don't have NULL columns, declare this as
- a primary key.
+ If the UNIQUE key doesn't have NULL columns and is not a part key
+ declare this as a primary key.
*/
primary_key=key;
for (i=0 ; i < keyinfo->key_parts ;i++)
{
- if (!key_part[i].fieldnr ||
- outparam->field[key_part[i].fieldnr-1]->null_ptr)
+ uint fieldnr= key_part[i].fieldnr;
+ if (!fieldnr ||
+ outparam->field[fieldnr-1]->null_ptr ||
+ outparam->field[fieldnr-1]->key_length() !=
+ key_part[i].length)
{
primary_key=MAX_KEY; // Can't be used
break;
@@ -554,6 +557,12 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
keyinfo->extra_length+=HA_KEY_BLOB_LENGTH;
key_part->store_length+=HA_KEY_BLOB_LENGTH;
keyinfo->key_length+= HA_KEY_BLOB_LENGTH;
+ /*
+ Mark that there may be many matching values for one key
+ combination ('a', 'a ', 'a '...)
+ */
+ if (!(field->flags & BINARY_FLAG))
+ keyinfo->flags|= HA_END_SPACE_KEY;
}
if (i == 0 && key != primary_key)
field->flags |=
@@ -591,7 +600,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
}
if (field->key_length() != key_part->length)
{
- key_part->key_part_flag|= HA_PART_KEY;
+ key_part->key_part_flag|= HA_PART_KEY_SEG;
if (!(field->flags & BLOB_FLAG))
{ // Create a new field
field=key_part->field=field->new_field(&outparam->mem_root,
@@ -605,7 +614,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
as we need to test for NULL = NULL.
*/
if (field->real_maybe_null())
- key_part->key_part_flag|= HA_PART_KEY;
+ key_part->key_part_flag|= HA_PART_KEY_SEG;
}
else
{ // Error: shorten key
@@ -1237,14 +1246,17 @@ bool get_field(MEM_ROOT *mem, Field *field, String *res)
char *get_field(MEM_ROOT *mem, Field *field)
{
- char buff[MAX_FIELD_WIDTH];
+ char buff[MAX_FIELD_WIDTH], *to;
String str(buff,sizeof(buff),&my_charset_bin);
uint length;
field->val_str(&str,&str);
- if (!(length= str.length()))
+ length= str.length();
+ if (!length || !(to= (char*) alloc_root(mem,length+1)))
return NullS;
- return strmake_root(mem, str.ptr(), length);
+ memcpy(to,str.ptr(),(uint) length);
+ to[length]=0;
+ return to;
}