Commit abb7df2d authored by monty@tramp.mysql.fi's avatar monty@tramp.mysql.fi

Fixed error message when opening a not-MyISAM file.

Extended MODIFY and CHANGE in ALTER TABLE to accept the AFTER keyword.
Extended MyISAM to handle records > 16M.
parent 00046f8e
...@@ -33,3 +33,4 @@ tonu@x153.internalnet ...@@ -33,3 +33,4 @@ tonu@x153.internalnet
tonu@x3.internalnet tonu@x3.internalnet
Administrator@co3064164-a. Administrator@co3064164-a.
Administrator@co3064164-a.rochd1.qld.optushome.com.au Administrator@co3064164-a.rochd1.qld.optushome.com.au
monty@tramp.mysql.fi
This diff is collapsed.
...@@ -190,6 +190,8 @@ static int _mi_find_writepos(MI_INFO *info, ...@@ -190,6 +190,8 @@ static int _mi_find_writepos(MI_INFO *info,
my_errno=HA_ERR_RECORD_FILE_FULL; my_errno=HA_ERR_RECORD_FILE_FULL;
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
if (*length > MI_MAX_BLOCK_LENGTH)
*length=MI_MAX_BLOCK_LENGTH;
info->state->data_file_length+= *length; info->state->data_file_length+= *length;
info->s->state.split++; info->s->state.split++;
info->update|=HA_STATE_WRITE_AT_END; info->update|=HA_STATE_WRITE_AT_END;
...@@ -370,19 +372,30 @@ int _mi_write_part_record(MI_INFO *info, ...@@ -370,19 +372,30 @@ int _mi_write_part_record(MI_INFO *info,
info->s->state.dellink : info->state->data_file_length; info->s->state.dellink : info->state->data_file_length;
if (*flag == 0) /* First block */ if (*flag == 0) /* First block */
{ {
head_length=5+8+long_block*2; if (*reclength > MI_MAX_BLOCK_LENGTH)
temp[0]=5+(uchar) long_block;
if (long_block)
{ {
mi_int3store(temp+1,*reclength); head_length= 16;
temp[0]=13;
mi_int4store(temp+1,*reclength);
mi_int3store(temp+4,length-head_length); mi_int3store(temp+4,length-head_length);
mi_sizestore((byte*) temp+7,next_filepos); mi_sizestore((byte*) temp+8,next_filepos);
} }
else else
{ {
mi_int2store(temp+1,*reclength); head_length=5+8+long_block*2;
mi_int2store(temp+3,length-head_length); temp[0]=5+(uchar) long_block;
mi_sizestore((byte*) temp+5,next_filepos); if (long_block)
{
mi_int3store(temp+1,*reclength);
mi_int3store(temp+4,length-head_length);
mi_sizestore((byte*) temp+7,next_filepos);
}
else
{
mi_int2store(temp+1,*reclength);
mi_int2store(temp+3,length-head_length);
mi_sizestore((byte*) temp+5,next_filepos);
}
} }
} }
else else
...@@ -1433,10 +1446,10 @@ uint _mi_get_block_info(MI_BLOCK_INFO *info, File file, my_off_t filepos) ...@@ -1433,10 +1446,10 @@ uint _mi_get_block_info(MI_BLOCK_INFO *info, File file, my_off_t filepos)
} }
else else
{ {
if (info->header[0] > 6) if (info->header[0] > 6 && info->header[0] != 13)
return_val=BLOCK_SYNC_ERROR; return_val=BLOCK_SYNC_ERROR;
} }
info->next_filepos= HA_OFFSET_ERROR; /* Dummy ifall no next block */ info->next_filepos= HA_OFFSET_ERROR; /* Dummy if no next block */
switch (info->header[0]) { switch (info->header[0]) {
case 0: case 0:
...@@ -1470,6 +1483,14 @@ uint _mi_get_block_info(MI_BLOCK_INFO *info, File file, my_off_t filepos) ...@@ -1470,6 +1483,14 @@ uint _mi_get_block_info(MI_BLOCK_INFO *info, File file, my_off_t filepos)
info->filepos=filepos+4; info->filepos=filepos+4;
return return_val | BLOCK_FIRST | BLOCK_LAST; return return_val | BLOCK_FIRST | BLOCK_LAST;
case 13:
info->rec_len=mi_uint4korr(header+1);
info->block_len=info->data_len=mi_uint3korr(header+5);
info->next_filepos=mi_sizekorr(header+8);
info->second_read=1;
info->filepos=filepos+16;
return return_val | BLOCK_FIRST;
case 3: case 3:
info->rec_len=info->data_len=mi_uint2korr(header+1); info->rec_len=info->data_len=mi_uint2korr(header+1);
info->block_len=info->rec_len+ (uint) header[3]; info->block_len=info->rec_len+ (uint) header[3];
......
...@@ -115,7 +115,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) ...@@ -115,7 +115,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
DBUG_PRINT("error",("Wrong header in %s",name_buff)); DBUG_PRINT("error",("Wrong header in %s",name_buff));
DBUG_DUMP("error_dump",(char*) share->state.header.file_version, DBUG_DUMP("error_dump",(char*) share->state.header.file_version,
head_length); head_length);
my_errno=HA_ERR_CRASHED; my_errno=HA_ERR_WRONG_TABLE_DEF;
goto err; goto err;
} }
share->options= mi_uint2korr(share->state.header.options); share->options= mi_uint2korr(share->state.header.options);
......
...@@ -356,7 +356,8 @@ struct st_myisam_info { ...@@ -356,7 +356,8 @@ struct st_myisam_info {
#define MI_DYN_MAX_BLOCK_LENGTH ((1L << 24)-4L) #define MI_DYN_MAX_BLOCK_LENGTH ((1L << 24)-4L)
#define MI_DYN_MAX_ROW_LENGTH (MI_DYN_MAX_BLOCK_LENGTH - MI_SPLIT_LENGTH) #define MI_DYN_MAX_ROW_LENGTH (MI_DYN_MAX_BLOCK_LENGTH - MI_SPLIT_LENGTH)
#define MI_DYN_ALIGN_SIZE 4 /* Align blocks on this */ #define MI_DYN_ALIGN_SIZE 4 /* Align blocks on this */
#define MI_MAX_DYN_HEADER_BYTE 12 /* max header byte for dynamic rows */ #define MI_MAX_DYN_HEADER_BYTE 13 /* max header byte for dynamic rows */
#define MI_MAX_BLOCK_LENGTH (((ulong) 1 << 24)-1)
#define MEMMAP_EXTRA_MARGIN 7 /* Write this as a suffix for file */ #define MEMMAP_EXTRA_MARGIN 7 /* Write this as a suffix for file */
......
...@@ -6,10 +6,16 @@ col3 varchar (20) not null, ...@@ -6,10 +6,16 @@ col3 varchar (20) not null,
col4 varchar(4) not null, col4 varchar(4) not null,
col5 enum('PENDING', 'ACTIVE', 'DISABLED') not null, col5 enum('PENDING', 'ACTIVE', 'DISABLED') not null,
col6 int not null, to_be_deleted int); col6 int not null, to_be_deleted int);
insert into t1 values (2,4,3,5,"PENDING",1,7);
alter table t1 alter table t1
add column col4_5 varchar(20) not null after col4, add column col4_5 varchar(20) not null after col4,
add column col7 varchar(30) not null after col6, add column col7 varchar(30) not null after col5,
add column col8 datetime not null, drop column to_be_deleted; add column col8 datetime not null, drop column to_be_deleted,
change column col2 fourth varchar(30) not null after col3,
modify column col6 int not null first;
select * from t1;
col6 col1 col3 fourth col4 col4_5 col5 col7 col8
1 2 3 4 5 PENDING 0000-00-00 00:00:00
drop table t1; drop table t1;
create table t1 (bandID MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY, payoutID SMALLINT UNSIGNED NOT NULL); create table t1 (bandID MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY, payoutID SMALLINT UNSIGNED NOT NULL);
insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12); insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12);
......
...@@ -10,10 +10,14 @@ col3 varchar (20) not null, ...@@ -10,10 +10,14 @@ col3 varchar (20) not null,
col4 varchar(4) not null, col4 varchar(4) not null,
col5 enum('PENDING', 'ACTIVE', 'DISABLED') not null, col5 enum('PENDING', 'ACTIVE', 'DISABLED') not null,
col6 int not null, to_be_deleted int); col6 int not null, to_be_deleted int);
insert into t1 values (2,4,3,5,"PENDING",1,7);
alter table t1 alter table t1
add column col4_5 varchar(20) not null after col4, add column col4_5 varchar(20) not null after col4,
add column col7 varchar(30) not null after col6, add column col7 varchar(30) not null after col5,
add column col8 datetime not null, drop column to_be_deleted; add column col8 datetime not null, drop column to_be_deleted,
change column col2 fourth varchar(30) not null after col3,
modify column col6 int not null first;
select * from t1;
drop table t1; drop table t1;
create table t1 (bandID MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY, payoutID SMALLINT UNSIGNED NOT NULL); create table t1 (bandID MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY, payoutID SMALLINT UNSIGNED NOT NULL);
......
...@@ -1273,8 +1273,11 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, ...@@ -1273,8 +1273,11 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
def->field=field; def->field=field;
if (def->sql_type == FIELD_TYPE_TIMESTAMP) if (def->sql_type == FIELD_TYPE_TIMESTAMP)
use_timestamp=1; use_timestamp=1;
create_list.push_back(def); if (!def->after)
def_it.remove(); {
create_list.push_back(def);
def_it.remove();
}
} }
else else
{ // Use old field value { // Use old field value
...@@ -1305,7 +1308,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, ...@@ -1305,7 +1308,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
List_iterator<create_field> find_it(create_list); List_iterator<create_field> find_it(create_list);
while ((def=def_it++)) // Add new columns while ((def=def_it++)) // Add new columns
{ {
if (def->change) if (def->change && ! def->field)
{ {
my_error(ER_BAD_FIELD_ERROR,MYF(0),def->change,table_name); my_error(ER_BAD_FIELD_ERROR,MYF(0),def->change,table_name);
DBUG_RETURN(-1); DBUG_RETURN(-1);
......
...@@ -1138,7 +1138,7 @@ alter_list_item: ...@@ -1138,7 +1138,7 @@ alter_list_item:
LEX *lex=Lex; LEX *lex=Lex;
lex->change= $3.str; lex->simple_alter=0; lex->change= $3.str; lex->simple_alter=0;
} }
field_spec field_spec opt_place
| MODIFY_SYM opt_column field_ident | MODIFY_SYM opt_column field_ident
{ {
LEX *lex=Lex; LEX *lex=Lex;
...@@ -1157,6 +1157,7 @@ alter_list_item: ...@@ -1157,6 +1157,7 @@ alter_list_item:
YYABORT; YYABORT;
lex->simple_alter=0; lex->simple_alter=0;
} }
opt_place
| DROP opt_column field_ident opt_restrict | DROP opt_column field_ident opt_restrict
{ {
LEX *lex=Lex; LEX *lex=Lex;
...@@ -2831,6 +2832,7 @@ keyword: ...@@ -2831,6 +2832,7 @@ keyword:
| BACKUP_SYM {} | BACKUP_SYM {}
| BEGIN_SYM {} | BEGIN_SYM {}
| BERKELEY_DB_SYM {} | BERKELEY_DB_SYM {}
| BINLOG_SYM {}
| BIT_SYM {} | BIT_SYM {}
| BOOL_SYM {} | BOOL_SYM {}
| BOOLEAN_SYM {} | BOOLEAN_SYM {}
...@@ -2857,6 +2859,7 @@ keyword: ...@@ -2857,6 +2859,7 @@ keyword:
| END {} | END {}
| ENUM {} | ENUM {}
| ESCAPE_SYM {} | ESCAPE_SYM {}
| EVENTS_SYM {}
| EXTENDED_SYM {} | EXTENDED_SYM {}
| FAST_SYM {} | FAST_SYM {}
| FULL {} | FULL {}
......
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