diff options
author | Michael Widenius <monty@askmonty.org> | 2012-04-04 00:14:07 +0300 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2012-04-04 00:14:07 +0300 |
commit | a3bee835eea847b6d5b68897aee63ab9a1a5d6ba (patch) | |
tree | 95d04198c00f1d59b9c5e3e518a02228b0850813 /storage/csv | |
parent | 9b8542a4f6abde851ff428d0b6cffb789c5ccede (diff) | |
download | mariadb-git-a3bee835eea847b6d5b68897aee63ab9a1a5d6ba.tar.gz |
Fixed lp:970528 "Server crashes in my_strnncollsp_simple on LEFT JOIN with CSV table, TEXT field"
The main problem was a bug in CSV where it provided wrong statistics (it claimed the table was empty when it wasn't)
I also fixed wrong freeing of blob's in the CSV handler. (Any call to handler::read_first_row() on a CSV table with blobs would fail)
mysql-test/r/csv.result:
Added new test case
mysql-test/r/partition_innodb.result:
Updated test results after fixing bug with impossible partitions and const tables
mysql-test/t/csv.test:
Added new test case
sql/sql_select.cc:
Cleaned up code for handling of partitions.
Fixed also a bug where we didn't threat a table with impossible partitions as a const table.
storage/csv/ha_tina.cc:
Allocate blobroot onces.
Diffstat (limited to 'storage/csv')
-rw-r--r-- | storage/csv/ha_tina.cc | 28 | ||||
-rw-r--r-- | storage/csv/ha_tina.h | 3 |
2 files changed, 20 insertions, 11 deletions
diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc index 3a6b2b1578c..d2af7d9e713 100644 --- a/storage/csv/ha_tina.cc +++ b/storage/csv/ha_tina.cc @@ -854,6 +854,7 @@ int ha_tina::open(const char *name, int mode, uint open_options) */ thr_lock_data_init(&share->lock, &lock, (void*) this); ref_length= sizeof(my_off_t); + init_alloc_root(&blobroot, BLOB_MEMROOT_ALLOC_SIZE, 0); share->lock.get_status= tina_get_status; share->lock.update_status= tina_update_status; @@ -871,6 +872,7 @@ int ha_tina::close(void) { int rc= 0; DBUG_ENTER("ha_tina::close"); + free_root(&blobroot, MYF(0)); rc= my_close(data_file, MYF(0)); DBUG_RETURN(free_share(share) || rc); } @@ -1086,11 +1088,9 @@ int ha_tina::rnd_init(bool scan) current_position= next_position= 0; stats.records= 0; - records_is_known= 0; + records_is_known= found_end_of_file= 0; chain_ptr= chain; - init_alloc_root(&blobroot, BLOB_MEMROOT_ALLOC_SIZE, 0); - DBUG_RETURN(0); } @@ -1122,10 +1122,16 @@ int ha_tina::rnd_next(uchar *buf) /* don't scan an empty file */ if (!local_saved_data_file_length) + { + found_end_of_file= 1; DBUG_RETURN(HA_ERR_END_OF_FILE); - + } if ((rc= find_current_row(buf))) + { + DBUG_PRINT("warning", ("got error %d while reading file", rc)); + found_end_of_file= (rc == HA_ERR_END_OF_FILE); DBUG_RETURN(rc); + } stats.records++; DBUG_RETURN(0); @@ -1220,8 +1226,7 @@ int ha_tina::rnd_end() my_off_t file_buffer_start= 0; DBUG_ENTER("ha_tina::rnd_end"); - free_root(&blobroot, MYF(0)); - records_is_known= 1; + records_is_known= found_end_of_file; if ((chain_ptr - chain) > 0) { @@ -1394,8 +1399,6 @@ int ha_tina::repair(THD* thd, HA_CHECK_OPT* check_opt) /* set current position to the beginning of the file */ current_position= next_position= 0; - init_alloc_root(&blobroot, BLOB_MEMROOT_ALLOC_SIZE, 0); - /* Read the file row-by-row. If everything is ok, repair is not needed. */ while (!(rc= find_current_row(buf))) { @@ -1603,8 +1606,6 @@ int ha_tina::check(THD* thd, HA_CHECK_OPT* check_opt) /* set current position to the beginning of the file */ current_position= next_position= 0; - init_alloc_root(&blobroot, BLOB_MEMROOT_ALLOC_SIZE, 0); - /* Read the file row-by-row. If everything is ok, repair is not needed. */ while (!(rc= find_current_row(buf))) { @@ -1628,6 +1629,13 @@ int ha_tina::check(THD* thd, HA_CHECK_OPT* check_opt) } +int ha_tina::reset(void) +{ + free_root(&blobroot, MYF(0)); + return 0; +} + + bool ha_tina::check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes) { diff --git a/storage/csv/ha_tina.h b/storage/csv/ha_tina.h index 54860ecb3fb..a124ea77f3c 100644 --- a/storage/csv/ha_tina.h +++ b/storage/csv/ha_tina.h @@ -84,7 +84,7 @@ class ha_tina: public handler uchar chain_alloced; uint32 chain_size; uint local_data_file_version; /* Saved version of the data file used */ - bool records_is_known; + bool records_is_known, found_end_of_file; MEM_ROOT blobroot; private: @@ -156,6 +156,7 @@ public: bool auto_repair() const { return 1; } void position(const uchar *record); int info(uint); + int reset(); int extra(enum ha_extra_function operation); int delete_all_rows(void); int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info); |