summaryrefslogtreecommitdiff
path: root/sql/unireg.cc
diff options
context:
space:
mode:
authorunknown <tnurnberg@mysql.com/sin.azundris.com>2007-02-12 14:32:06 +0100
committerunknown <tnurnberg@mysql.com/sin.azundris.com>2007-02-12 14:32:06 +0100
commit91f684a5ad2ff725cef0596a06993e4e2754c059 (patch)
tree085178750621544539cca2294c607fafdb4bad92 /sql/unireg.cc
parenta63a66cb46d16088fd9c634c2b0ebca0471e78ad (diff)
parent4dc7c1aa46c4980833dd0f20bdc0650d9bd669c0 (diff)
downloadmariadb-git-91f684a5ad2ff725cef0596a06993e4e2754c059.tar.gz
Merge mysql.com:/home/tnurnberg/24660/41-24660
into mysql.com:/home/tnurnberg/24660/50-24660 mysql-test/r/type_enum.result: Auto merged sql/table.cc: Auto merged sql/unireg.cc: Auto merged
Diffstat (limited to 'sql/unireg.cc')
-rw-r--r--sql/unireg.cc61
1 files changed, 40 insertions, 21 deletions
diff --git a/sql/unireg.cc b/sql/unireg.cc
index 8568b09e498..8d24fa1df3b 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -714,29 +714,48 @@ static bool pack_fields(File file, List<create_field> &create_fields,
{
if (field->interval_id > int_count)
{
- int_count=field->interval_id;
- tmp.append(NAMES_SEP_CHAR);
- for (const char **pos=field->interval->type_names ; *pos ; pos++)
- {
- char *val= (char*) *pos;
- uint str_len= strlen(val);
- /*
- Note, hack: in old frm NAMES_SEP_CHAR is used to separate
- names in the interval (ENUM/SET). To allow names to contain
- NAMES_SEP_CHAR, we replace it with a comma before writing frm.
- Backward conversion is done during frm file opening,
- See table.cc, openfrm() function
- */
- for (uint cnt= 0 ; cnt < str_len ; cnt++)
+ unsigned char sep= 0;
+ unsigned char occ[256];
+ uint i;
+ unsigned char *val= NULL;
+
+ bzero(occ, sizeof(occ));
+
+ for (i=0; (val= (unsigned char*) field->interval->type_names[i]); i++)
+ for (uint j = 0; j < field->interval->type_lengths[i]; j++)
+ occ[(unsigned int) (val[j])]= 1;
+
+ if (!occ[(unsigned char)NAMES_SEP_CHAR])
+ sep= (unsigned char) NAMES_SEP_CHAR;
+ else if (!occ[(unsigned int)','])
+ sep= ',';
+ else
+ {
+ for (uint i=1; i<256; i++)
+ {
+ if(!occ[i])
+ {
+ sep= i;
+ break;
+ }
+ }
+
+ if(!sep) /* disaster, enum uses all characters, none left as separator */
{
- char c= val[cnt];
- if (c == NAMES_SEP_CHAR)
- val[cnt]= ',';
+ my_message(ER_WRONG_FIELD_TERMINATORS,ER(ER_WRONG_FIELD_TERMINATORS),
+ MYF(0));
+ DBUG_RETURN(1);
}
- tmp.append(*pos);
- tmp.append(NAMES_SEP_CHAR);
- }
- tmp.append('\0'); // End of intervall
+ }
+
+ int_count= field->interval_id;
+ tmp.append(sep);
+ for (const char **pos=field->interval->type_names ; *pos ; pos++)
+ {
+ tmp.append(*pos);
+ tmp.append(sep);
+ }
+ tmp.append('\0'); // End of intervall
}
}
if (my_write(file,(byte*) tmp.ptr(),tmp.length(),MYF_RW))