diff options
author | unknown <petr/cps@mysql.com/owlet.> | 2006-07-11 15:54:52 +0400 |
---|---|---|
committer | unknown <petr/cps@mysql.com/owlet.> | 2006-07-11 15:54:52 +0400 |
commit | 83aade738787f991122b3dcf519789eba7becb93 (patch) | |
tree | 14b80f2cbea92c4466d455c702b0ccc75109e0b9 /sql/examples | |
parent | 0eaae4157d4bd467fa7fecf88bc37c81c8d069b1 (diff) | |
download | mariadb-git-83aade738787f991122b3dcf519789eba7becb93.tar.gz |
Fix Bug#15205 "Select from CSV table without the datafile causes crash"
mysql-test/r/csv.result:
update result file
mysql-test/t/csv.test:
add a test for the bug
sql/examples/ha_tina.cc:
move open() call before my_hash_insert, so that we don't insert invalid
share to the hash. To avoid other possible problems also add
hash_delete(), so that the share is removed from hash before it is freed.
Diffstat (limited to 'sql/examples')
-rw-r--r-- | sql/examples/ha_tina.cc | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/sql/examples/ha_tina.cc b/sql/examples/ha_tina.cc index 8ae82f97d0b..ebddfc244b8 100644 --- a/sql/examples/ha_tina.cc +++ b/sql/examples/ha_tina.cc @@ -184,16 +184,18 @@ static TINA_SHARE *get_share(const char *table_name, TABLE *table) share->table_name_length=length; share->table_name=tmp_name; strmov(share->table_name,table_name); - fn_format(data_file_name, table_name, "", ".CSV",MY_REPLACE_EXT|MY_UNPACK_FILENAME); + fn_format(data_file_name, table_name, "", ".CSV", + MY_REPLACE_EXT | MY_UNPACK_FILENAME); + + if ((share->data_file= my_open(data_file_name, O_RDWR|O_APPEND, + MYF(0))) == -1) + goto error; + if (my_hash_insert(&tina_open_tables, (byte*) share)) goto error; thr_lock_init(&share->lock); pthread_mutex_init(&share->mutex,MY_MUTEX_INIT_FAST); - if ((share->data_file= my_open(data_file_name, O_RDWR|O_APPEND, - MYF(0))) == -1) - goto error2; - /* We only use share->data_file for writing, so we scan to the end to append */ if (my_seek(share->data_file, 0, SEEK_END, MYF(0)) == MY_FILEPOS_ERROR) goto error2; @@ -212,6 +214,7 @@ error3: error2: thr_lock_delete(&share->lock); pthread_mutex_destroy(&share->mutex); + hash_delete(&tina_open_tables, (byte*) share); error: pthread_mutex_unlock(&tina_mutex); my_free((gptr) share, MYF(0)); |