Commit 845e9f55 authored by unknown's avatar unknown

stricter checks on FULLTEXT index creating

parent b192ab5e
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
#define ER_NO_PERMISSION_TO_CREATE_USER 1211 #define ER_NO_PERMISSION_TO_CREATE_USER 1211
#define ER_UNION_TABLES_IN_DIFFERENT_DIR 1212 #define ER_UNION_TABLES_IN_DIFFERENT_DIR 1212
#define ER_LOCK_DEADLOCK 1213 #define ER_LOCK_DEADLOCK 1213
#define ER_TABLE_CANT_HANDLE_FULLTEXT 1214 #define ER_TABLE_CANT_HANDLE_FT 1214
#define ER_CANNOT_ADD_FOREIGN 1215 #define ER_CANNOT_ADD_FOREIGN 1215
#define ER_NO_REFERENCED_ROW 1216 #define ER_NO_REFERENCED_ROW 1216
#define ER_ROW_IS_REFERENCED 1217 #define ER_ROW_IS_REFERENCED 1217
...@@ -295,4 +295,5 @@ ...@@ -295,4 +295,5 @@
#define ER_BAD_SLAVE_UNTIL_COND 1276 #define ER_BAD_SLAVE_UNTIL_COND 1276
#define ER_MISSING_SKIP_SLAVE 1277 #define ER_MISSING_SKIP_SLAVE 1277
#define ER_UNTIL_COND_IGNORED 1278 #define ER_UNTIL_COND_IGNORED 1278
#define ER_ERROR_MESSAGES 279 #define ER_BAD_FT_COLUMN 1279
#define ER_ERROR_MESSAGES 280
...@@ -191,6 +191,12 @@ ticket inhalt ...@@ -191,6 +191,12 @@ ticket inhalt
select * from t2 having MATCH inhalt AGAINST ('foobar'); select * from t2 having MATCH inhalt AGAINST ('foobar');
ticket inhalt ticket inhalt
3 foobar 3 foobar
CREATE TABLE t3 (t int(11),i text,fulltext tix (t,i));
ERROR HY000: Column 't' cannot be part of FULLTEXT index
CREATE TABLE t3 (t int(11),i text,
j varchar(200) CHARACTER SET latin2,
fulltext tix (i,j));
ERROR HY000: Column 'j' cannot be part of FULLTEXT index
CREATE TABLE t3 ( CREATE TABLE t3 (
ticket int(11), ticket int(11),
inhalt text, inhalt text,
......
...@@ -4,8 +4,6 @@ INSERT INTO t1 VALUES (1), (2); ...@@ -4,8 +4,6 @@ INSERT INTO t1 VALUES (1), (2);
<?xml version="1.0"?> <?xml version="1.0"?>
<mysqldump> <mysqldump>
<database name="test"> <database name="test">
DROP TABLE IF EXISTS t1;
LOCK TABLES t1 WRITE;
<table name="t1"> <table name="t1">
<row> <row>
<field name="a">1</field> <field name="a">1</field>
...@@ -14,7 +12,6 @@ LOCK TABLES t1 WRITE; ...@@ -14,7 +12,6 @@ LOCK TABLES t1 WRITE;
<field name="a">2</field> <field name="a">2</field>
</row> </row>
</table> </table>
UNLOCK TABLES;
</database> </database>
</mysqldump> </mysqldump>
DROP TABLE t1; DROP TABLE t1;
...@@ -130,6 +130,13 @@ select * from t2 having MATCH inhalt AGAINST ('foobar'); ...@@ -130,6 +130,13 @@ select * from t2 having MATCH inhalt AGAINST ('foobar');
# check of fulltext errors # check of fulltext errors
# #
--error 1279
CREATE TABLE t3 (t int(11),i text,fulltext tix (t,i));
--error 1279
CREATE TABLE t3 (t int(11),i text,
j varchar(200) CHARACTER SET latin2,
fulltext tix (i,j));
CREATE TABLE t3 ( CREATE TABLE t3 (
ticket int(11), ticket int(11),
inhalt text, inhalt text,
......
...@@ -291,3 +291,4 @@ character-set=latin2 ...@@ -291,3 +291,4 @@ character-set=latin2
"Wrong parameter or combination of parameters for START SLAVE UNTIL" "Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart" "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored" "SQL thread is not to be started so UNTIL options are ignored"
...@@ -285,3 +285,4 @@ character-set=latin1 ...@@ -285,3 +285,4 @@ character-set=latin1
"Wrong parameter or combination of parameters for START SLAVE UNTIL" "Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart" "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored" "SQL thread is not to be started so UNTIL options are ignored"
...@@ -293,3 +293,4 @@ character-set=latin1 ...@@ -293,3 +293,4 @@ character-set=latin1
"Wrong parameter or combination of parameters for START SLAVE UNTIL" "Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart" "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored" "SQL thread is not to be started so UNTIL options are ignored"
...@@ -277,8 +277,10 @@ character-set=latin1 ...@@ -277,8 +277,10 @@ character-set=latin1
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
"Unknown collation: '%-.64s'", "Unknown collation: '%-.64s'",
"SSL parameters in CHANGE MASTER are ignored because this MySQL slave was compiled without SSL support. They can be used later when MySQL slave with SSL will be started." "SSL parameters in CHANGE MASTER are ignored because this MySQL slave was compiled without SSL support. They can be used later when MySQL slave with SSL will be started."
"Server is running in --secure-auth mode, but '%s@%s' has a password in the old format; please change the password to the new format", "Server is running in --secure-auth mode, but '%s'@'%s' has a password in the old format; please change the password to the new format",
"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d", "Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d",
"Wrong parameter or combination of parameters for START SLAVE UNTIL" "Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart" "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored" "SQL thread is not to be started so UNTIL options are ignored"
"Column '%-.64s' cannot be part of FULLTEXT index"
...@@ -287,3 +287,4 @@ character-set=latin7 ...@@ -287,3 +287,4 @@ character-set=latin7
"Wrong parameter or combination of parameters for START SLAVE UNTIL" "Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart" "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored" "SQL thread is not to be started so UNTIL options are ignored"
...@@ -282,3 +282,4 @@ character-set=latin1 ...@@ -282,3 +282,4 @@ character-set=latin1
"Wrong parameter or combination of parameters for START SLAVE UNTIL" "Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart" "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored" "SQL thread is not to be started so UNTIL options are ignored"
...@@ -294,3 +294,4 @@ character-set=latin1 ...@@ -294,3 +294,4 @@ character-set=latin1
"Falscher Parameter oder falsche Kombination von Parametern für START SLAVE UNTIL", "Falscher Parameter oder falsche Kombination von Parametern für START SLAVE UNTIL",
"Es wird empfohlen, mit --skip-slave-start zu starten, wenn mit START SLAVE UNTIL eine Schritt-für-Schritt-Replikation ausgeführt wird. Ansonsten gibt es Probleme, wenn der Slave-Server unerwartet neu startet", "Es wird empfohlen, mit --skip-slave-start zu starten, wenn mit START SLAVE UNTIL eine Schritt-für-Schritt-Replikation ausgeführt wird. Ansonsten gibt es Probleme, wenn der Slave-Server unerwartet neu startet",
"SQL-Thread soll nicht gestartet werden. Daher werden UNTIL-Optionen ignoriert" "SQL-Thread soll nicht gestartet werden. Daher werden UNTIL-Optionen ignoriert"
...@@ -282,3 +282,4 @@ character-set=greek ...@@ -282,3 +282,4 @@ character-set=greek
"Wrong parameter or combination of parameters for START SLAVE UNTIL" "Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart" "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored" "SQL thread is not to be started so UNTIL options are ignored"
...@@ -284,3 +284,4 @@ character-set=latin2 ...@@ -284,3 +284,4 @@ character-set=latin2
"Wrong parameter or combination of parameters for START SLAVE UNTIL" "Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart" "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored" "SQL thread is not to be started so UNTIL options are ignored"
...@@ -282,3 +282,4 @@ character-set=latin1 ...@@ -282,3 +282,4 @@ character-set=latin1
"Wrong parameter or combination of parameters for START SLAVE UNTIL" "Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart" "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored" "SQL thread is not to be started so UNTIL options are ignored"
...@@ -284,3 +284,4 @@ character-set=ujis ...@@ -284,3 +284,4 @@ character-set=ujis
"Wrong parameter or combination of parameters for START SLAVE UNTIL" "Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart" "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored" "SQL thread is not to be started so UNTIL options are ignored"
...@@ -282,3 +282,4 @@ character-set=euckr ...@@ -282,3 +282,4 @@ character-set=euckr
"Wrong parameter or combination of parameters for START SLAVE UNTIL" "Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart" "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored" "SQL thread is not to be started so UNTIL options are ignored"
...@@ -284,3 +284,4 @@ character-set=latin1 ...@@ -284,3 +284,4 @@ character-set=latin1
"Wrong parameter or combination of parameters for START SLAVE UNTIL" "Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart" "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored" "SQL thread is not to be started so UNTIL options are ignored"
...@@ -284,3 +284,4 @@ character-set=latin1 ...@@ -284,3 +284,4 @@ character-set=latin1
"Wrong parameter or combination of parameters for START SLAVE UNTIL" "Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart" "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored" "SQL thread is not to be started so UNTIL options are ignored"
...@@ -286,3 +286,4 @@ character-set=latin2 ...@@ -286,3 +286,4 @@ character-set=latin2
"Wrong parameter or combination of parameters for START SLAVE UNTIL" "Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart" "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored" "SQL thread is not to be started so UNTIL options are ignored"
...@@ -283,3 +283,4 @@ character-set=latin1 ...@@ -283,3 +283,4 @@ character-set=latin1
"Wrong parameter or combination of parameters for START SLAVE UNTIL" "Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart" "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored" "SQL thread is not to be started so UNTIL options are ignored"
...@@ -286,3 +286,4 @@ character-set=latin2 ...@@ -286,3 +286,4 @@ character-set=latin2
"Wrong parameter or combination of parameters for START SLAVE UNTIL" "Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart" "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored" "SQL thread is not to be started so UNTIL options are ignored"
...@@ -284,3 +284,4 @@ character-set=koi8r ...@@ -284,3 +284,4 @@ character-set=koi8r
"Wrong parameter or combination of parameters for START SLAVE UNTIL" "Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart" "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored" "SQL thread is not to be started so UNTIL options are ignored"
...@@ -277,3 +277,4 @@ character-set=cp1250 ...@@ -277,3 +277,4 @@ character-set=cp1250
"Wrong parameter or combination of parameters for START SLAVE UNTIL" "Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart" "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored" "SQL thread is not to be started so UNTIL options are ignored"
...@@ -290,3 +290,4 @@ character-set=latin2 ...@@ -290,3 +290,4 @@ character-set=latin2
"Wrong parameter or combination of parameters for START SLAVE UNTIL" "Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart" "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored" "SQL thread is not to be started so UNTIL options are ignored"
...@@ -284,3 +284,4 @@ character-set=latin1 ...@@ -284,3 +284,4 @@ character-set=latin1
"Wrong parameter or combination of parameters for START SLAVE UNTIL" "Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart" "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored" "SQL thread is not to be started so UNTIL options are ignored"
...@@ -282,3 +282,4 @@ character-set=latin1 ...@@ -282,3 +282,4 @@ character-set=latin1
"Wrong parameter or combination of parameters for START SLAVE UNTIL" "Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart" "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored" "SQL thread is not to be started so UNTIL options are ignored"
...@@ -287,3 +287,4 @@ character-set=koi8u ...@@ -287,3 +287,4 @@ character-set=koi8u
"Wrong parameter or combination of parameters for START SLAVE UNTIL" "Wrong parameter or combination of parameters for START SLAVE UNTIL"
"It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart" "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart"
"SQL thread is not to be started so UNTIL options are ignored" "SQL thread is not to be started so UNTIL options are ignored"
...@@ -424,7 +424,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, ...@@ -424,7 +424,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
if (!sql_field->charset) if (!sql_field->charset)
sql_field->charset= create_info->table_charset; sql_field->charset= create_info->table_charset;
sql_field->create_length_to_internal_length(); sql_field->create_length_to_internal_length();
/* Don't pack keys in old tables if the user has requested this */ /* Don't pack keys in old tables if the user has requested this */
if ((sql_field->flags & BLOB_FLAG) || if ((sql_field->flags & BLOB_FLAG) ||
sql_field->sql_type == FIELD_TYPE_VAR_STRING && sql_field->sql_type == FIELD_TYPE_VAR_STRING &&
...@@ -663,12 +663,11 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, ...@@ -663,12 +663,11 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
key_info->usable_key_parts= key_number; key_info->usable_key_parts= key_number;
key_info->algorithm=key->algorithm; key_info->algorithm=key->algorithm;
/* TODO: Add proper checks if handler supports key_type and algorithm */
if (key->type == Key::FULLTEXT) if (key->type == Key::FULLTEXT)
{ {
if (!(file->table_flags() & HA_CAN_FULLTEXT)) if (!(file->table_flags() & HA_CAN_FULLTEXT))
{ {
my_error(ER_TABLE_CANT_HANDLE_FULLTEXT, MYF(0)); my_error(ER_TABLE_CANT_HANDLE_FT, MYF(0));
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
} }
...@@ -680,6 +679,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, ...@@ -680,6 +679,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
checking for proper key parts number: checking for proper key parts number:
*/ */
/* TODO: Add proper checks if handler supports key_type and algorithm */
if (key_info->flags == HA_SPATIAL) if (key_info->flags == HA_SPATIAL)
{ {
if (key_info->key_parts != 1) if (key_info->key_parts != 1)
...@@ -704,6 +704,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, ...@@ -704,6 +704,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
} }
List_iterator<key_part_spec> cols(key->columns); List_iterator<key_part_spec> cols(key->columns);
CHARSET_INFO *ft_key_charset=0; // for FULLTEXT
for (uint column_nr=0 ; (column=cols++) ; column_nr++) for (uint column_nr=0 ; (column=cols++) ; column_nr++)
{ {
it.rewind(); it.rewind();
...@@ -727,64 +728,87 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, ...@@ -727,64 +728,87 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
from a data prefix, ignoring column->length). from a data prefix, ignoring column->length).
*/ */
if (key->type == Key::FULLTEXT) if (key->type == Key::FULLTEXT)
{
if ((sql_field->sql_type != FIELD_TYPE_STRING &&
sql_field->sql_type != FIELD_TYPE_VAR_STRING &&
!f_is_blob(sql_field->pack_flag)) ||
sql_field->charset == &my_charset_bin ||
(ft_key_charset && sql_field->charset != ft_key_charset))
{
my_printf_error(ER_BAD_FT_COLUMN,ER(ER_BAD_FT_COLUMN),MYF(0),
column->field_name);
DBUG_RETURN(-1);
}
ft_key_charset=sql_field->charset;
/*
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).
*/
column->length=test(f_is_blob(sql_field->pack_flag)); column->length=test(f_is_blob(sql_field->pack_flag));
}
else else
{
column->length*= sql_field->charset->mbmaxlen; column->length*= sql_field->charset->mbmaxlen;
if (f_is_blob(sql_field->pack_flag)) if (f_is_blob(sql_field->pack_flag))
{ {
if (!(file->table_flags() & HA_BLOB_KEY)) if (!(file->table_flags() & HA_BLOB_KEY))
{ {
my_printf_error(ER_BLOB_USED_AS_KEY,ER(ER_BLOB_USED_AS_KEY),MYF(0), my_printf_error(ER_BLOB_USED_AS_KEY,ER(ER_BLOB_USED_AS_KEY),MYF(0),
column->field_name); column->field_name);
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
if (!column->length) if (!column->length)
{ {
my_printf_error(ER_BLOB_KEY_WITHOUT_LENGTH, my_printf_error(ER_BLOB_KEY_WITHOUT_LENGTH,
ER(ER_BLOB_KEY_WITHOUT_LENGTH),MYF(0), ER(ER_BLOB_KEY_WITHOUT_LENGTH),MYF(0),
column->field_name); column->field_name);
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
} }
if (key->type == Key::SPATIAL) if (key->type == Key::SPATIAL)
{ {
if (!column->length ) if (!column->length )
{ {
/* /*
BAR: 4 is: (Xmin,Xmax,Ymin,Ymax), this is for 2D case BAR: 4 is: (Xmin,Xmax,Ymin,Ymax), this is for 2D case
Lately we'll extend this code to support more dimensions Lately we'll extend this code to support more dimensions
*/ */
column->length=4*sizeof(double); column->length=4*sizeof(double);
} }
} }
if (!(sql_field->flags & NOT_NULL_FLAG)) if (!(sql_field->flags & NOT_NULL_FLAG))
{ {
if (key->type == Key::PRIMARY) if (key->type == Key::PRIMARY)
{ {
/* Implicitly set primary key fields to NOT NULL for ISO conf. */ /* Implicitly set primary key fields to NOT NULL for ISO conf. */
sql_field->flags|= NOT_NULL_FLAG; sql_field->flags|= NOT_NULL_FLAG;
sql_field->pack_flag&= ~FIELDFLAG_MAYBE_NULL; sql_field->pack_flag&= ~FIELDFLAG_MAYBE_NULL;
} }
else else
key_info->flags|= HA_NULL_PART_KEY; key_info->flags|= HA_NULL_PART_KEY;
if (!(file->table_flags() & HA_NULL_KEY)) if (!(file->table_flags() & HA_NULL_KEY))
{ {
my_printf_error(ER_NULL_COLUMN_IN_INDEX,ER(ER_NULL_COLUMN_IN_INDEX), my_printf_error(ER_NULL_COLUMN_IN_INDEX,ER(ER_NULL_COLUMN_IN_INDEX),
MYF(0),column->field_name); MYF(0),column->field_name);
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
if (key->type == Key::SPATIAL) if (key->type == Key::SPATIAL)
{ {
my_error(ER_SPATIAL_CANT_HAVE_NULL, MYF(0)); my_error(ER_SPATIAL_CANT_HAVE_NULL, MYF(0));
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
} }
if (MTYP_TYPENR(sql_field->unireg_check) == Field::NEXT_NUMBER) if (MTYP_TYPENR(sql_field->unireg_check) == Field::NEXT_NUMBER)
{ {
if (column_nr == 0 || (file->table_flags() & HA_AUTO_PART_KEY)) if (column_nr == 0 || (file->table_flags() & HA_AUTO_PART_KEY))
auto_increment--; // Field is used auto_increment--; // Field is used
}
} }
key_part_info->fieldnr= field; key_part_info->fieldnr= field;
key_part_info->offset= (uint16) sql_field->offset; key_part_info->offset= (uint16) sql_field->offset;
key_part_info->key_type=sql_field->pack_flag; key_part_info->key_type=sql_field->pack_flag;
......
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