summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <serg@sergbook.mysql.com>2003-04-23 15:44:39 +0400
committerunknown <serg@sergbook.mysql.com>2003-04-23 15:44:39 +0400
commitb21a0be804fbff458ffbfff4e01f28f8730d3820 (patch)
tree77d6919fed33367fdbbc9be69c2422b18bc0d16b
parent29b593987d81b987a0feb1750afec23bd8cac9c7 (diff)
downloadmariadb-git-b21a0be804fbff458ffbfff4e01f28f8730d3820.tar.gz
bug 283: FULLTEXT index on a TEXT filed converted to a CHAR field doesn't work anymore
-rw-r--r--mysql-test/r/fulltext.result11
-rw-r--r--mysql-test/t/fulltext.test13
-rw-r--r--sql/sql_table.cc21
3 files changed, 36 insertions, 9 deletions
diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result
index edf109fcc93..eaaaf9c8880 100644
--- a/mysql-test/r/fulltext.result
+++ b/mysql-test/r/fulltext.result
@@ -215,3 +215,14 @@ test.t1 repair status OK
select * from t1 where match (a) against ('aaaa');
a
drop table t1;
+drop table if exists t1;
+create table t1 ( ref_mag text not null, fulltext (ref_mag));
+insert into t1 values ('test');
+select ref_mag from t1 where match ref_mag against ('+test' in boolean mode);
+ref_mag
+test
+alter table t1 change ref_mag ref_mag char (255) not null;
+select ref_mag from t1 where match ref_mag against ('+test' in boolean mode);
+ref_mag
+test
+drop table t1;
diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test
index 5a64f2614aa..128af680854 100644
--- a/mysql-test/t/fulltext.test
+++ b/mysql-test/t/fulltext.test
@@ -173,3 +173,16 @@ repair table t1;
select * from t1 where match (a) against ('aaaa');
drop table t1;
+#
+# bug 283 by jocelyn fournier <joc@presence-pc.com>
+# FULLTEXT index on a TEXT filed converted to a CHAR field doesn't work anymore
+#
+
+drop table if exists t1;
+create table t1 ( ref_mag text not null, fulltext (ref_mag));
+insert into t1 values ('test');
+select ref_mag from t1 where match ref_mag against ('+test' in boolean mode);
+alter table t1 change ref_mag ref_mag char (255) not null;
+select ref_mag from t1 where match ref_mag against ('+test' in boolean mode);
+drop table t1;
+
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 0cdb0a7ff48..0fbb5807c57 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -569,6 +569,14 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
column->field_name);
DBUG_RETURN(-1);
}
+ /* for fulltext keys keyseg length is 1 for blobs (it's ignored in
+ ft code anyway, and 0 (set to column width later) for char's.
+ it has to be correct col width for char's, as char data are not
+ prefixed with length (unlike blobs, where ft code takes data length
+ from a data prefix, ignoring column->length).
+ */
+ if (key->type == Key::FULLTEXT)
+ column->length=test(f_is_blob(sql_field->pack_flag));
if (f_is_blob(sql_field->pack_flag))
{
if (!(file->table_flags() & HA_BLOB_KEY))
@@ -579,15 +587,10 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
}
if (!column->length)
{
- if (key->type == Key::FULLTEXT)
- column->length=1; /* ft-code ignores it anyway :-) */
- else
- {
- my_printf_error(ER_BLOB_KEY_WITHOUT_LENGTH,
- ER(ER_BLOB_KEY_WITHOUT_LENGTH),MYF(0),
- column->field_name);
- DBUG_RETURN(-1);
- }
+ my_printf_error(ER_BLOB_KEY_WITHOUT_LENGTH,
+ ER(ER_BLOB_KEY_WITHOUT_LENGTH),MYF(0),
+ column->field_name);
+ DBUG_RETURN(-1);
}
}
if (!(sql_field->flags & NOT_NULL_FLAG))