diff options
author | unknown <joerg@trift2.> | 2007-11-16 11:12:13 +0100 |
---|---|---|
committer | unknown <joerg@trift2.> | 2007-11-16 11:12:13 +0100 |
commit | 33c9d06b5e36d5083f2bfcd92885f627bed8726d (patch) | |
tree | 7b85b7460872d013096082e9b786184d76db8e50 /storage | |
parent | 6a86af045888aebcc5f52ac3c37ccf41ca132e3d (diff) | |
parent | f4f7e1f42c831152d750a0f159db7bae1b756601 (diff) | |
download | mariadb-git-33c9d06b5e36d5083f2bfcd92885f627bed8726d.tar.gz |
Merge trift2.:/MySQL/M51/mysql-5.1
into trift2.:/MySQL/M51/push-5.1
Diffstat (limited to 'storage')
-rw-r--r-- | storage/archive/azio.c | 10 | ||||
-rw-r--r-- | storage/archive/ha_archive.cc | 4 | ||||
-rw-r--r-- | storage/example/ha_example.cc | 30 | ||||
-rw-r--r-- | storage/myisam/mi_dynrec.c | 68 |
4 files changed, 104 insertions, 8 deletions
diff --git a/storage/archive/azio.c b/storage/archive/azio.c index c04749444cb..2cf0fe114d3 100644 --- a/storage/archive/azio.c +++ b/storage/archive/azio.c @@ -681,8 +681,8 @@ my_off_t azseek (s, offset, whence) /* There was a zmemzero here if inbuf was null -Brian */ while (offset > 0) { - uInt size = AZ_BUFSIZE_WRITE; - if (offset < AZ_BUFSIZE_WRITE) size = (uInt)offset; + uInt size = AZ_BUFSIZE_READ; + if (offset < AZ_BUFSIZE_READ) size = (uInt)offset; size = azwrite(s, s->inbuf, size); if (size == 0) return -1L; @@ -725,11 +725,11 @@ my_off_t azseek (s, offset, whence) } while (offset > 0) { int error; - unsigned int size = AZ_BUFSIZE_READ; - if (offset < AZ_BUFSIZE_READ) size = (int)offset; + unsigned int size = AZ_BUFSIZE_WRITE; + if (offset < AZ_BUFSIZE_WRITE) size = (int)offset; size = azread(s, s->outbuf, size, &error); - if (error <= 0) return -1L; + if (error < 0) return -1L; offset -= size; } return s->out; diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index 6696eac2fbb..84298e785d1 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -1241,8 +1241,8 @@ int ha_archive::rnd_pos(uchar * buf, uchar *pos) DBUG_ENTER("ha_archive::rnd_pos"); ha_statistic_increment(&SSV::ha_read_rnd_next_count); current_position= (my_off_t)my_get_ptr(pos, ref_length); - (void)azseek(&archive, current_position, SEEK_SET); - + if (azseek(&archive, current_position, SEEK_SET) == (my_off_t)(-1L)) + DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); DBUG_RETURN(get_row(&archive, buf)); } diff --git a/storage/example/ha_example.cc b/storage/example/ha_example.cc index b7186dda676..6d9f4841e06 100644 --- a/storage/example/ha_example.cc +++ b/storage/example/ha_example.cc @@ -848,6 +848,34 @@ int ha_example::create(const char *name, TABLE *table_arg, struct st_mysql_storage_engine example_storage_engine= { MYSQL_HANDLERTON_INTERFACE_VERSION }; +static ulong srv_enum_var= 0; + +const char *enum_var_names[]= +{ + "e1", "e2", NullS +}; + +TYPELIB enum_var_typelib= +{ + array_elements(enum_var_names) - 1, "enum_var_typelib", + enum_var_names, NULL +}; + +static MYSQL_SYSVAR_ENUM( + enum_var, // name + srv_enum_var, // varname + PLUGIN_VAR_RQCMDARG, // opt + "Sample ENUM system variable.", // comment + NULL, // check + NULL, // update + 0, // def + &enum_var_typelib); // typelib + +static struct st_mysql_sys_var* example_system_variables[]= { + MYSQL_SYSVAR(enum_var), + NULL +}; + mysql_declare_plugin(example) { MYSQL_STORAGE_ENGINE_PLUGIN, @@ -860,7 +888,7 @@ mysql_declare_plugin(example) example_done_func, /* Plugin Deinit */ 0x0001 /* 0.1 */, NULL, /* status variables */ - NULL, /* system variables */ + example_system_variables, /* system variables */ NULL /* config options */ } mysql_declare_plugin_end; diff --git a/storage/myisam/mi_dynrec.c b/storage/myisam/mi_dynrec.c index cdd70abe9ad..9940cf62204 100644 --- a/storage/myisam/mi_dynrec.c +++ b/storage/myisam/mi_dynrec.c @@ -326,6 +326,29 @@ static int write_dynamic_record(MI_INFO *info, const uchar *record, DBUG_ENTER("write_dynamic_record"); flag=0; + + /* + Check if we have enough room for the new record. + First we do simplified check to make usual case faster. + Then we do more precise check for the space left. + Though it still is not absolutely precise, as + we always use MI_MAX_DYN_BLOCK_HEADER while it can be + less in the most of the cases. + */ + + if (unlikely(info->s->base.max_data_file_length - + info->state->data_file_length < + reclength + MI_MAX_DYN_BLOCK_HEADER)) + { + if (info->s->base.max_data_file_length - info->state->data_file_length + + info->state->empty - info->state->del * MI_MAX_DYN_BLOCK_HEADER < + reclength + MI_MAX_DYN_BLOCK_HEADER) + { + my_errno=HA_ERR_RECORD_FILE_FULL; + DBUG_RETURN(1); + } + } + do { if (_mi_find_writepos(info,reclength,&filepos,&length)) @@ -762,6 +785,51 @@ static int update_dynamic_record(MI_INFO *info, my_off_t filepos, uchar *record, DBUG_ENTER("update_dynamic_record"); flag=block_info.second_read=0; + /* + Check if we have enough room for the record. + First we do simplified check to make usual case faster. + Then we do more precise check for the space left. + Though it still is not absolutely precise, as + we always use MI_MAX_DYN_BLOCK_HEADER while it can be + less in the most of the cases. + */ + + /* + compare with just the reclength as we're going + to get some space from the old replaced record + */ + if (unlikely(info->s->base.max_data_file_length - + info->state->data_file_length < reclength)) + { + /* + let's read the old record's block to find out the length of the + old record + */ + if ((error=_mi_get_block_info(&block_info,info->dfile,filepos)) + & (BLOCK_DELETED | BLOCK_ERROR | BLOCK_SYNC_ERROR | BLOCK_FATAL_ERROR)) + { + DBUG_PRINT("error",("Got wrong block info")); + if (!(error & BLOCK_FATAL_ERROR)) + my_errno=HA_ERR_WRONG_IN_RECORD; + goto err; + } + + /* + if new record isn't longer, we can go on safely + */ + if (block_info.rec_len < reclength) + { + if (info->s->base.max_data_file_length - info->state->data_file_length + + info->state->empty - info->state->del * MI_MAX_DYN_BLOCK_HEADER < + reclength - block_info.rec_len + MI_MAX_DYN_BLOCK_HEADER) + { + my_errno=HA_ERR_RECORD_FILE_FULL; + goto err; + } + } + block_info.second_read=0; + } + while (reclength > 0) { if (filepos != info->s->state.dellink) |