From b176870cf6e1413001652631c0658a9cf9089e48 Mon Sep 17 00:00:00 2001 From: "petr/cps@mysql.com/owlet." <> Date: Tue, 11 Jul 2006 15:54:52 +0400 Subject: Fix Bug#15205 "Select from CSV table without the datafile causes crash" --- sql/examples/ha_tina.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'sql/examples') 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)); -- cgit v1.2.1