From b16b2683e5a7e9b1eae9a59b477b8eb0517b6c68 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 3 Jul 2007 17:17:58 +0500 Subject: Complementary fix for bug #29353: inserting a negative value to a csv table leads to the table corruption New Field::store() method implemented to explicitly set thd->count_cuted_fields before value storing, instead of (incorrectly) setting it in the CSV storage engine. Thread row counter now properly incremented during check and repair in the CSV engine. include/mysql/plugin.h: Complementary fix for bug #29353: inserting a negative value to a csv table leads to the table corruption - thd_inc_row_count() function prototype added, which allows a storage engine to increment thread row counter. mysql-test/r/csv.result: Complementary fix for bug #29353: inserting a negative value to a csv table leads to the table corruption - result adjusted. sql/field.cc: Complementary fix for bug #29353: inserting a negative value to a csv table leads to the table corruption - Field::store(const char *to, uint length, CHARSET_INFO *cs, enum_check_fields check_level) method introduced in order to explicitly set count_cuted_fields before a ::store call, then reset it back after. sql/field.h: Complementary fix for bug #29353: inserting a negative value to a csv table leads to the table corruption - Field::store(const char *to, uint length, CHARSET_INFO *cs, enum_check_fields check_level) method introduced in order to explicitly set count_cuted_fields before a ::store call, then reset it back after. sql/mysql_priv.h: Complementary fix for bug #29353: inserting a negative value to a csv table leads to the table corruption - enum enum_check_fields moved from sql/sql_class.h to sql/mysql_priv.h as it's used now in the field.h sql/sql_class.cc: Complementary fix for bug #29353: inserting a negative value to a csv table leads to the table corruption - implementation of the new thd_inc_row_count() function which increments thread row counter. sql/sql_class.h: Complementary fix for bug #29353: inserting a negative value to a csv table leads to the table corruption - enum enum_check_fields moved from sql/sql_class.h to sql/mysql_priv.h as it's used now in the field.h storage/csv/ha_tina.cc: Complementary fix for bug #29353: inserting a negative value to a csv table leads to the table corruption - removed #define MYSQL_SERVER 1 - "a storage engine should not need internals of the server" - removed thd->count_cuted_fields= CHECK_FIELD_WARN as we are not allowed to access internals of THD. - used new Field::store() method to explicitly set thd->count_cuted_fields to CHECK_FIELD_WARN - thd_inc_row_count() calls added to ha_tina::repair() and ha_tina::check() to get proper row count values. --- storage/csv/ha_tina.cc | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'storage/csv') diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc index 239d47890ed..2ee96fd5d05 100644 --- a/storage/csv/ha_tina.cc +++ b/storage/csv/ha_tina.cc @@ -45,8 +45,6 @@ TODO: #pragma implementation // gcc: Class implementation #endif -#define MYSQL_SERVER 1 - #include "mysql_priv.h" #include #include "ha_tina.h" @@ -675,7 +673,8 @@ int ha_tina::find_current_row(uchar *buf) if (bitmap_is_set(table->read_set, (*field)->field_index)) { - if ((*field)->store(buffer.ptr(), buffer.length(), buffer.charset())) + if ((*field)->store(buffer.ptr(), buffer.length(), buffer.charset(), + CHECK_FIELD_WARN)) goto err; } } @@ -1002,7 +1001,6 @@ int ha_tina::delete_row(const uchar * buf) int ha_tina::rnd_init(bool scan) { - THD *thd= table ? table->in_use : current_thd; DBUG_ENTER("ha_tina::rnd_init"); /* set buffer to the beginning of the file */ @@ -1014,7 +1012,6 @@ int ha_tina::rnd_init(bool scan) stats.records= 0; records_is_known= 0; chain_ptr= chain; - thd->count_cuted_fields= CHECK_FIELD_WARN; // To find wrong values DBUG_RETURN(0); } @@ -1298,9 +1295,9 @@ int ha_tina::repair(THD* thd, HA_CHECK_OPT* check_opt) current_position= next_position= 0; /* Read the file row-by-row. If everything is ok, repair is not needed. */ - thd->count_cuted_fields= CHECK_FIELD_WARN; // To find wrong values while (!(rc= find_current_row(buf))) { + thd_inc_row_count(thd); rows_repaired++; current_position= next_position; } @@ -1464,9 +1461,9 @@ 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; /* Read the file row-by-row. If everything is ok, repair is not needed. */ - thd->count_cuted_fields= CHECK_FIELD_WARN; // To find wrong values while (!(rc= find_current_row(buf))) { + thd_inc_row_count(thd); count--; current_position= next_position; } -- cgit v1.2.1