summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <serg@serg.mylan>2004-04-07 16:20:46 +0200
committerunknown <serg@serg.mylan>2004-04-07 16:20:46 +0200
commit3c2d37357f73e22545e2b048f81927e70d21212c (patch)
tree8e3d0724200afbcae1e7e7b321b2e166b4f4cd39
parent01bcc6ed3c4c1c6515592364b4aec0cae5d2083c (diff)
parenta9a5517a1c861754529c003e9ebdbc001f84f647 (diff)
downloadmariadb-git-3c2d37357f73e22545e2b048f81927e70d21212c.tar.gz
merged
sql/field.cc: Auto merged sql/item.cc: Auto merged sql/protocol.cc: Auto merged sql/sql_acl.cc: Auto merged sql/sql_base.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_show.cc: Auto merged sql/sql_table.cc: Auto merged sql/table.cc: Auto merged
-rw-r--r--include/my_base.h4
-rw-r--r--mysql-test/r/myisam.result25
-rw-r--r--mysql-test/r/repair.result (renamed from mysql-test/r/repair_part1.result)8
-rw-r--r--mysql-test/r/repair_part2.result8
-rw-r--r--mysql-test/t/help.test4
-rw-r--r--mysql-test/t/lowercase_table2.test2
-rw-r--r--mysql-test/t/lowercase_table3.test2
-rw-r--r--mysql-test/t/lowercase_table_qcache.test2
-rw-r--r--mysql-test/t/myisam.test23
-rw-r--r--mysql-test/t/repair.test (renamed from mysql-test/t/repair_part1.test)8
-rw-r--r--mysql-test/t/repair_part2-master.sh1
-rw-r--r--mysql-test/t/repair_part2.test7
-rw-r--r--sql/field.cc15
-rw-r--r--sql/field.h13
-rw-r--r--sql/field_conv.cc10
-rw-r--r--sql/ha_berkeley.cc1
-rw-r--r--sql/ha_berkeley.h3
-rw-r--r--sql/ha_heap.cc5
-rw-r--r--sql/ha_heap.h4
-rw-r--r--sql/ha_innodb.cc10
-rw-r--r--sql/ha_innodb.h4
-rw-r--r--sql/ha_isam.cc5
-rw-r--r--sql/ha_isam.h1
-rw-r--r--sql/ha_isammrg.cc5
-rw-r--r--sql/ha_isammrg.h1
-rw-r--r--sql/ha_myisam.cc138
-rw-r--r--sql/ha_myisam.h11
-rw-r--r--sql/ha_myisammrg.cc6
-rw-r--r--sql/ha_myisammrg.h1
-rw-r--r--sql/handler.h11
-rw-r--r--sql/item.cc2
-rw-r--r--sql/item_sum.cc5
-rw-r--r--sql/key.cc2
-rw-r--r--sql/opt_range.cc2
-rw-r--r--sql/protocol.cc2
-rw-r--r--sql/records.cc2
-rw-r--r--sql/sql_acl.cc6
-rw-r--r--sql/sql_base.cc2
-rw-r--r--sql/sql_insert.cc55
-rw-r--r--sql/sql_load.cc10
-rw-r--r--sql/sql_show.cc8
-rw-r--r--sql/sql_table.cc44
-rw-r--r--sql/table.cc4
43 files changed, 238 insertions, 244 deletions
diff --git a/include/my_base.h b/include/my_base.h
index d23a70b8a55..b38e177fd89 100644
--- a/include/my_base.h
+++ b/include/my_base.h
@@ -105,8 +105,8 @@ enum ha_extra_function {
HA_EXTRA_NORMAL=0, /* Optimize for space (def) */
HA_EXTRA_QUICK=1, /* Optimize for speed */
HA_EXTRA_RESET=2, /* Reset database to after open */
- HA_EXTRA_CACHE=3, /* Cash record in HA_rrnd() */
- HA_EXTRA_NO_CACHE=4, /* End cacheing of records (def) */
+ HA_EXTRA_CACHE=3, /* Cache record in HA_rrnd() */
+ HA_EXTRA_NO_CACHE=4, /* End caching of records (def) */
HA_EXTRA_NO_READCHECK=5, /* No readcheck on update */
HA_EXTRA_READCHECK=6, /* Use readcheck (def) */
HA_EXTRA_KEYREAD=7, /* Read only key to database */
diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result
index d210048a5c7..9a123729c4b 100644
--- a/mysql-test/r/myisam.result
+++ b/mysql-test/r/myisam.result
@@ -504,3 +504,28 @@ test.t1 968604391
test.t2 968604391
test.t3 NULL
drop table t1,t2;
+create table t1 (a int, key (a));
+show keys from t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
+t1 1 a 1 a A NULL NULL NULL YES BTREE
+alter table t1 disable keys;
+show keys from t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
+t1 1 a 1 a A NULL NULL NULL YES BTREE disabled
+create table t2 (a int);
+insert t1 select * from t2;
+show keys from t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
+t1 1 a 1 a A NULL NULL NULL YES BTREE disabled
+alter table t1 enable keys;
+show keys from t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
+t1 1 a 1 a A 1000 NULL NULL YES BTREE
+alter table t1 engine=heap;
+alter table t1 disable keys;
+Warnings:
+Note 1031 Table storage engine for 't1' doesn't have this option
+show keys from t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
+t1 1 a 1 a NULL NULL NULL NULL YES HASH
+drop table t1,t2;
diff --git a/mysql-test/r/repair_part1.result b/mysql-test/r/repair.result
index 6dcec409ea6..2398e13b8e3 100644
--- a/mysql-test/r/repair_part1.result
+++ b/mysql-test/r/repair.result
@@ -28,3 +28,11 @@ repair table t1 use_frm;
Table Op Msg_type Msg_text
test.t1 repair error Table 'test.t1' doesn't exist
create table t1 engine=myisam SELECT 1,"table 1";
+repair table t1;
+Table Op Msg_type Msg_text
+test.t1 repair error Can't open file: 't1.MYI' (errno: 130)
+repair table t1 use_frm;
+Table Op Msg_type Msg_text
+test.t1 repair warning Number of rows changed from 0 to 1
+test.t1 repair status OK
+drop table t1;
diff --git a/mysql-test/r/repair_part2.result b/mysql-test/r/repair_part2.result
deleted file mode 100644
index c9cf6c019f7..00000000000
--- a/mysql-test/r/repair_part2.result
+++ /dev/null
@@ -1,8 +0,0 @@
-repair table t1;
-Table Op Msg_type Msg_text
-test.t1 repair error Can't open file: 't1.MYI' (errno: 130)
-repair table t1 use_frm;
-Table Op Msg_type Msg_text
-test.t1 repair warning Number of rows changed from 0 to 1
-test.t1 repair status OK
-drop table t1;
diff --git a/mysql-test/t/help.test b/mysql-test/t/help.test
index 54c551ccd7a..3f3e99e1556 100644
--- a/mysql-test/t/help.test
+++ b/mysql-test/t/help.test
@@ -1,5 +1,3 @@
--- source include/have_innodb.inc
-
# category: topic: keyword:
#
# impossible_category_1
@@ -65,10 +63,12 @@ help 'impossible_function_1';
help 'impossible_category_1';
##############
+--disable_warnings
alter table mysql.help_relation engine=innodb;
alter table mysql.help_keyword engine=innodb;
alter table mysql.help_topic engine=innodb;
alter table mysql.help_category engine=innodb;
+--enable_warnings
##############
help 'function_of_my_dream';
diff --git a/mysql-test/t/lowercase_table2.test b/mysql-test/t/lowercase_table2.test
index 8f542a7af78..5c479391916 100644
--- a/mysql-test/t/lowercase_table2.test
+++ b/mysql-test/t/lowercase_table2.test
@@ -1,6 +1,6 @@
#
# Test of --lower-case-table-names=2
-# (User has case insensitive file system and want's to preserve case of
+# (User has case insensitive file system and wants to preserve case of
# table names)
#
--source include/have_innodb.inc
diff --git a/mysql-test/t/lowercase_table3.test b/mysql-test/t/lowercase_table3.test
index 735a0b390f9..1753772ecc3 100644
--- a/mysql-test/t/lowercase_table3.test
+++ b/mysql-test/t/lowercase_table3.test
@@ -1,6 +1,6 @@
#
# Test of force of lower-case-table-names=0
-# (User has case insensitive file system and want's to preserve case of
+# (User has case insensitive file system and wants to preserve case of
# table names)
#
diff --git a/mysql-test/t/lowercase_table_qcache.test b/mysql-test/t/lowercase_table_qcache.test
index 7416de25e1d..5077a41402a 100644
--- a/mysql-test/t/lowercase_table_qcache.test
+++ b/mysql-test/t/lowercase_table_qcache.test
@@ -26,4 +26,4 @@ select * from MySQL.db;
enable_result_log;
show status like "Qcache_queries_in_cache";
-set GLOBAL query_cache_size=0; \ No newline at end of file
+set GLOBAL query_cache_size=0;
diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test
index 95847ba1af7..298a8b1b61b 100644
--- a/mysql-test/t/myisam.test
+++ b/mysql-test/t/myisam.test
@@ -479,3 +479,26 @@ checksum table t1, t2, t3;
checksum table t1, t2, t3 extended;
#show table status;
drop table t1,t2;
+
+create table t1 (a int, key (a));
+show keys from t1;
+alter table t1 disable keys;
+show keys from t1;
+create table t2 (a int);
+let $i=1000;
+--disable_query_log
+while ($i)
+{
+ dec $i;
+ eval insert t2 values (rand()*100000);
+}
+--enable_query_log
+insert t1 select * from t2;
+show keys from t1;
+alter table t1 enable keys;
+show keys from t1;
+alter table t1 engine=heap;
+alter table t1 disable keys;
+show keys from t1;
+drop table t1,t2;
+
diff --git a/mysql-test/t/repair_part1.test b/mysql-test/t/repair.test
index a2e186fd385..83a302e6f29 100644
--- a/mysql-test/t/repair_part1.test
+++ b/mysql-test/t/repair.test
@@ -27,8 +27,8 @@ drop table t1;
# non-existent table
repair table t1 use_frm;
-#
-# Create test table for repair2
-# The following must be last in this file
-
create table t1 engine=myisam SELECT 1,"table 1";
+system echo 1 > $MYSQL_TEST_DIR/var/master-data/test/t1.MYI ;
+repair table t1;
+repair table t1 use_frm;
+drop table t1;
diff --git a/mysql-test/t/repair_part2-master.sh b/mysql-test/t/repair_part2-master.sh
deleted file mode 100644
index 964bde06c18..00000000000
--- a/mysql-test/t/repair_part2-master.sh
+++ /dev/null
@@ -1 +0,0 @@
-echo "1" > $MYSQL_TEST_DIR/var/master-data/test/t1.MYI
diff --git a/mysql-test/t/repair_part2.test b/mysql-test/t/repair_part2.test
deleted file mode 100644
index 8c27e382dff..00000000000
--- a/mysql-test/t/repair_part2.test
+++ /dev/null
@@ -1,7 +0,0 @@
-#
-# This test starts with a crashed t1.MYI file left over from repair.test
-#
-
-repair table t1;
-repair table t1 use_frm;
-drop table t1;
diff --git a/sql/field.cc b/sql/field.cc
index d099da2d959..2da84ba1316 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -327,7 +327,7 @@ bool Field::send_binary(Protocol *protocol)
{
char buff[MAX_FIELD_WIDTH];
String tmp(buff,sizeof(buff),charset());
- val_str(&tmp,&tmp);
+ val_str(&tmp);
return protocol->store(tmp.ptr(), tmp.length(), tmp.charset());
}
@@ -396,8 +396,8 @@ uint Field::fill_cache_field(CACHE_FIELD *copy)
bool Field::get_date(TIME *ltime,uint fuzzydate)
{
char buff[40];
- String tmp(buff,sizeof(buff),&my_charset_bin),tmp2,*res;
- if (!(res=val_str(&tmp,&tmp2)) ||
+ String tmp(buff,sizeof(buff),&my_charset_bin),*res;
+ if (!(res=val_str(&tmp)) ||
str_to_TIME(res->ptr(),res->length(),ltime,fuzzydate) <=
TIMESTAMP_DATETIME_ERROR)
return 1;
@@ -407,8 +407,8 @@ bool Field::get_date(TIME *ltime,uint fuzzydate)
bool Field::get_time(TIME *ltime)
{
char buff[40];
- String tmp(buff,sizeof(buff),&my_charset_bin),tmp2,*res;
- if (!(res=val_str(&tmp,&tmp2)) ||
+ String tmp(buff,sizeof(buff),&my_charset_bin),*res;
+ if (!(res=val_str(&tmp)) ||
str_to_time(res->ptr(),res->length(),ltime))
return 1;
return 0;
@@ -3087,8 +3087,7 @@ longlong Field_timestamp::val_int(void)
}
-String *Field_timestamp::val_str(String *val_buffer,
- String *val_ptr __attribute__((unused)))
+String *Field_timestamp::val_str(String *val_buffer, String *val_ptr)
{
uint32 temp, temp2;
time_t time_arg;
@@ -5789,7 +5788,7 @@ create_field::create_field(Field *old_field,Field *orig_field)
my_ptrdiff_t diff= (my_ptrdiff_t) (orig_field->table->rec_buff_length*2);
orig_field->move_field(diff); // Points now at default_values
bool is_null=orig_field->is_real_null();
- orig_field->val_str(&tmp,&tmp);
+ orig_field->val_str(&tmp);
orig_field->move_field(-diff); // Back to record[0]
if (!is_null)
{
diff --git a/sql/field.h b/sql/field.h
index 75bb96f2f6d..8ebc7412c35 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -98,6 +98,19 @@ public:
virtual void store_time(TIME *ltime,timestamp_type t_type);
virtual double val_real(void)=0;
virtual longlong val_int(void)=0;
+ inline String *val_str(String *str) { return val_str(str, str); }
+ /*
+ val_str(buf1, buf2) gets two buffers and should use them as follows:
+ if it needs a temp buffer to convert result to string - use buf1
+ example Field_tiny::val_str()
+ if the value exists as a string already - use buf2
+ example Field_string::val_str()
+ consequently, buf2 may be created as 'String buf;' - no memory
+ will be allocated for it. buf1 will be allocated to hold a
+ value if it's too small. Using allocated buffer for buf2 may result in
+ an unnecessary free (and later, may be an alloc).
+ This trickery is used to decrease a number of malloc calls.
+ */
virtual String *val_str(String*,String *)=0;
virtual Item_result result_type () const=0;
virtual Item_result cmp_type () const { return result_type(); }
diff --git a/sql/field_conv.cc b/sql/field_conv.cc
index 5632c63c521..0974c552364 100644
--- a/sql/field_conv.cc
+++ b/sql/field_conv.cc
@@ -274,7 +274,7 @@ static void do_copy_blob(Copy_field *copy)
static void do_conv_blob(Copy_field *copy)
{
- copy->from_field->val_str(&copy->tmp,&copy->tmp);
+ copy->from_field->val_str(&copy->tmp);
((Field_blob *) copy->to_field)->store(copy->tmp.ptr(),
copy->tmp.length(),
copy->tmp.charset());
@@ -286,7 +286,7 @@ static void do_save_blob(Copy_field *copy)
{
char buff[MAX_FIELD_WIDTH];
String res(buff,sizeof(buff),copy->tmp.charset());
- copy->from_field->val_str(&res,&res);
+ copy->from_field->val_str(&res);
copy->tmp.copy(res);
((Field_blob *) copy->to_field)->store(copy->tmp.ptr(),
copy->tmp.length(),
@@ -298,7 +298,7 @@ static void do_field_string(Copy_field *copy)
{
char buff[MAX_FIELD_WIDTH];
copy->tmp.set_quick(buff,sizeof(buff),copy->tmp.charset());
- copy->from_field->val_str(&copy->tmp,&copy->tmp);
+ copy->from_field->val_str(&copy->tmp);
copy->to_field->store(copy->tmp.c_ptr_quick(),copy->tmp.length(),copy->tmp.charset());
}
@@ -559,7 +559,7 @@ void field_conv(Field *to,Field *from)
if (to->type() == FIELD_TYPE_BLOB)
{ // Be sure the value is stored
Field_blob *blob=(Field_blob*) to;
- from->val_str(&blob->value,&blob->value);
+ from->val_str(&blob->value);
if (!blob->value.is_alloced() &&
from->real_type() != FIELD_TYPE_STRING)
blob->value.copy();
@@ -574,7 +574,7 @@ void field_conv(Field *to,Field *from)
{
char buff[MAX_FIELD_WIDTH];
String result(buff,sizeof(buff),from->charset());
- from->val_str(&result,&result);
+ from->val_str(&result);
to->store(result.c_ptr_quick(),result.length(),from->charset());
}
else if (from->result_type() == REAL_RESULT)
diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc
index f13261ef52d..593b9575fb6 100644
--- a/sql/ha_berkeley.cc
+++ b/sql/ha_berkeley.cc
@@ -1709,6 +1709,7 @@ int ha_berkeley::extra(enum ha_extra_function operation)
int ha_berkeley::reset(void)
{
+ ha_berkeley::extra(HA_EXTRA_RESET);
key_read=0; // Reset to state after open
return 0;
}
diff --git a/sql/ha_berkeley.h b/sql/ha_berkeley.h
index 581b50501e8..88af2326eac 100644
--- a/sql/ha_berkeley.h
+++ b/sql/ha_berkeley.h
@@ -88,7 +88,7 @@ class ha_berkeley: public handler
public:
ha_berkeley(TABLE *table): handler(table), alloc_ptr(0),rec_buff(0), file(0),
int_table_flags(HA_REC_NOT_IN_SEQ |
- HA_KEYPOS_TO_RNDPOS | HA_LASTKEY_ORDER |
+ HA_KEYPOS_TO_RNDPOS | HA_LASTKEY_ORDER | HA_FAST_KEY_READ |
HA_NULL_KEY | HA_BLOB_KEY | HA_NOT_EXACT_COUNT |
HA_PRIMARY_KEY_IN_READ_INDEX | HA_DROP_BEFORE_CREATE |
HA_AUTO_PART_KEY | HA_TABLE_SCAN_ON_INDEX |
@@ -107,7 +107,6 @@ class ha_berkeley: public handler
uint max_key_length() const { return MAX_KEY_LENGTH; }
uint extra_rec_buf_length() { return BDB_HIDDEN_PRIMARY_KEY_LENGTH; }
ha_rows estimate_number_of_rows();
- bool fast_key_read() { return 1;}
const key_map *keys_to_use_for_scanning() { return &key_map_full; }
bool has_transactions() { return 1;}
diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc
index 94105fb9409..47978d647ec 100644
--- a/sql/ha_heap.cc
+++ b/sql/ha_heap.cc
@@ -196,11 +196,6 @@ int ha_heap::extra(enum ha_extra_function operation)
return heap_extra(file,operation);
}
-int ha_heap::reset(void)
-{
- return heap_extra(file,HA_EXTRA_RESET);
-}
-
int ha_heap::delete_all_rows()
{
heap_clear(file);
diff --git a/sql/ha_heap.h b/sql/ha_heap.h
index feadc0c3c0f..68406202c76 100644
--- a/sql/ha_heap.h
+++ b/sql/ha_heap.h
@@ -40,7 +40,7 @@ class ha_heap: public handler
const char **bas_ext() const;
ulong table_flags() const
{
- return (HA_READ_RND_SAME | HA_NO_INDEX | HA_KEYPOS_TO_RNDPOS |
+ return (HA_READ_RND_SAME | HA_FAST_KEY_READ | HA_KEYPOS_TO_RNDPOS |
HA_NO_BLOBS | HA_NULL_KEY | HA_REC_NOT_IN_SEQ);
}
ulong index_flags(uint inx) const
@@ -58,7 +58,6 @@ class ha_heap: public handler
double scan_time() { return (double) (records+deleted) / 20.0+10; }
double read_time(uint index, uint ranges, ha_rows rows)
{ return (double) rows / 20.0+1; }
- virtual bool fast_key_read() { return 1;}
int open(const char *name, int mode, uint test_if_locked);
int close(void);
@@ -81,7 +80,6 @@ class ha_heap: public handler
void position(const byte *record);
void info(uint);
int extra(enum ha_extra_function operation);
- int reset(void);
int external_lock(THD *thd, int lock_type);
int delete_all_rows(void);
ha_rows records_in_range(int inx, const byte *start_key,uint start_key_len,
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index 80721ae373c..a5dc6719182 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -4541,16 +4541,6 @@ ha_innobase::extra(
}
/**********************************************************************
-????????????? */
-
-int
-ha_innobase::reset(void)
-/*====================*/
-{
- return(0);
-}
-
-/**********************************************************************
MySQL calls this function at the start of each SQL statement inside LOCK
TABLES. Inside LOCK TABLES the ::external_lock method does not work to
mark SQL statement borders. Note also a special case: if a temporary table
diff --git a/sql/ha_innodb.h b/sql/ha_innodb.h
index a9e8c146d69..e5f1c66e23a 100644
--- a/sql/ha_innodb.h
+++ b/sql/ha_innodb.h
@@ -89,7 +89,7 @@ class ha_innobase: public handler
int_table_flags(HA_REC_NOT_IN_SEQ |
HA_KEYPOS_TO_RNDPOS |
HA_LASTKEY_ORDER |
- HA_NULL_KEY |
+ HA_NULL_KEY | HA_FAST_KEY_READ |
HA_BLOB_KEY |
HA_CAN_SQL_HANDLER |
HA_NOT_EXACT_COUNT |
@@ -123,7 +123,6 @@ class ha_innobase: public handler
whose size is > MAX_KEY_LENGTH */
uint max_key_length() const { return((MAX_KEY_LENGTH <= 3500) ?
MAX_KEY_LENGTH : 3500);}
- bool fast_key_read() { return 1;}
const key_map *keys_to_use_for_scanning() { return &key_map_full; }
bool has_transactions() { return 1;}
@@ -161,7 +160,6 @@ class ha_innobase: public handler
int optimize(THD* thd,HA_CHECK_OPT* check_opt);
int discard_or_import_tablespace(my_bool discard);
int extra(enum ha_extra_function operation);
- int reset(void);
int external_lock(THD *thd, int lock_type);
int start_stmt(THD *thd);
diff --git a/sql/ha_isam.cc b/sql/ha_isam.cc
index 52fea2f7a15..09c2aeceafc 100644
--- a/sql/ha_isam.cc
+++ b/sql/ha_isam.cc
@@ -237,11 +237,6 @@ int ha_isam::extra(enum ha_extra_function operation)
return nisam_extra(file,operation);
}
-int ha_isam::reset(void)
-{
- return nisam_extra(file,HA_EXTRA_RESET);
-}
-
int ha_isam::external_lock(THD *thd, int lock_type)
{
if (!table->tmp_table)
diff --git a/sql/ha_isam.h b/sql/ha_isam.h
index 129777e68e5..2c8ec274145 100644
--- a/sql/ha_isam.h
+++ b/sql/ha_isam.h
@@ -69,7 +69,6 @@ class ha_isam: public handler
my_off_t row_position() { return nisam_position(file); }
void info(uint);
int extra(enum ha_extra_function operation);
- int reset(void);
int external_lock(THD *thd, int lock_type);
ha_rows records_in_range(int inx,
const byte *start_key,uint start_key_len,
diff --git a/sql/ha_isammrg.cc b/sql/ha_isammrg.cc
index 8f7056a15fa..20e2b4db423 100644
--- a/sql/ha_isammrg.cc
+++ b/sql/ha_isammrg.cc
@@ -171,11 +171,6 @@ int ha_isammrg::extra(enum ha_extra_function operation)
return !mrg_extra(file,operation) ? 0 : my_errno ? my_errno : -1;
}
-int ha_isammrg::reset(void)
-{
- return !mrg_extra(file,HA_EXTRA_RESET) ? 0 : my_errno ? my_errno : -1;
-}
-
int ha_isammrg::external_lock(THD *thd, int lock_type)
{
return !mrg_lock_database(file,lock_type) ? 0 : my_errno ? my_errno : -1;
diff --git a/sql/ha_isammrg.h b/sql/ha_isammrg.h
index e5846d20212..05c1d862eb3 100644
--- a/sql/ha_isammrg.h
+++ b/sql/ha_isammrg.h
@@ -63,7 +63,6 @@ class ha_isammrg: public handler
my_off_t row_position() { return mrg_position(file); }
void info(uint);
int extra(enum ha_extra_function operation);
- int reset(void);
int external_lock(THD *thd, int lock_type);
uint lock_count(void) const;
int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info);
diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc
index 427edde2f4b..c56009dc0aa 100644
--- a/sql/ha_myisam.cc
+++ b/sql/ha_myisam.cc
@@ -811,78 +811,92 @@ int ha_myisam::preload_keys(THD* thd, HA_CHECK_OPT *check_opt)
}
/*
- Deactive all not unique index that can be recreated fast
+ disable indexes, making it persistent if requested
+ SYNOPSIS
+ disable_indexes(all, save)
+ all disable all indexes
+ if not set only non-unique indexes will be disabled
+ [all=1 is NOT IMPLEMENTED YET]
+ save save the disabled state, so that it will persist
+ between queries/threads/reboots
+ [save=0 is NOT IMPLEMENTED YET]
+*/
+int ha_myisam::disable_indexes(bool all, bool save)
+{
+ mi_extra(file, HA_EXTRA_NO_KEYS, 0);
+ info(HA_STATUS_CONST); // Read new key info
+ return 0;
+}
+
+int ha_myisam::enable_indexes()
+{
+ if (file->s->state.key_map == set_bits(ulonglong, file->s->base.keys))
+ return 0;
+
+ int error=0;
+ THD *thd=current_thd;
+ MI_CHECK param;
+ const char *save_proc_info=thd->proc_info;
+ thd->proc_info="Creating index";
+ myisamchk_init(&param);
+ param.op_name = (char*) "recreating_index";
+ param.testflag = (T_SILENT | T_REP_BY_SORT | T_QUICK |
+ T_CREATE_MISSING_KEYS);
+ param.myf_rw&= ~MY_WAIT_IF_FULL;
+ param.sort_buffer_length= thd->variables.myisam_sort_buff_size;
+ param.tmpdir=&mysql_tmpdir_list;
+ error=repair(thd,param,0) != HA_ADMIN_OK;
+ info(HA_STATUS_CONST);
+ thd->proc_info=save_proc_info;
+ return error;
+}
+
+/*
+ prepare for a many-rows insert operation
+ e.g. - disable indexes (if they can be recreated fast) or
+ activate special bulk-insert optimizations
SYNOPSIS
- deactivate_non_unique_index()
- rows Rows to be inserted
- 0 if we don't know
- HA_POS_ERROR if we want to force disabling
- and make it permanent (save on disk)
+ start_bulk_insert(rows)
+ rows Rows to be inserted
+ 0 if we don't know
*/
-void ha_myisam::deactivate_non_unique_index(ha_rows rows)
+void ha_myisam::start_bulk_insert(ha_rows rows)
{
- MYISAM_SHARE* share = file->s;
- if (share->state.key_map == ((ulonglong) 1L << share->base.keys)-1)
+ THD *thd=current_thd;
+ ulong size= min(thd->variables.read_buff_size, table->avg_row_length*rows);
+
+ mi_extra(file, HA_EXTRA_WRITE_CACHE, (void*)&size);
+
+ can_enable_indexes= (file->s->state.key_map ==
+ set_bits(ulonglong, file->s->base.keys));
+
+ if (!(specialflag & SPECIAL_SAFE_MODE))
{
- if (!(specialflag & SPECIAL_SAFE_MODE))
+ /*
+ Only disable old index if the table was empty and we are inserting
+ a lot of rows.
+ We should not do this for only a few rows as this is slower and
+ we don't want to update the key statistics based of only a few rows.
+ */
+ if (file->state->records == 0 && can_enable_indexes &&
+ (!rows || rows >= MI_MIN_ROWS_TO_DISABLE_INDEXES))
+ mi_disable_non_unique_index(file,rows);
+ else
+ if (!file->bulk_insert &&
+ (!rows || rows >= MI_MIN_ROWS_TO_USE_BULK_INSERT))
{
- if (rows == HA_POS_ERROR) // force disable and save it on disk!
- mi_extra(file, HA_EXTRA_NO_KEYS, 0);
- else
- {
- /*
- Only disable old index if the table was empty and we are inserting
- a lot of rows.
- We should not do this for only a few rows as this is slower and
- we don't want to update the key statistics based of only a few rows.
- */
- if (file->state->records == 0 &&
- (!rows || rows >= MI_MIN_ROWS_TO_DISABLE_INDEXES))
- mi_disable_non_unique_index(file,rows);
- else if (!file->bulk_insert &&
- (!rows || rows >= MI_MIN_ROWS_TO_USE_BULK_INSERT))
- mi_init_bulk_insert(file,
- current_thd->variables.bulk_insert_buff_size,
- rows);
- }
+ mi_init_bulk_insert(file, thd->variables.bulk_insert_buff_size, rows);
}
- enable_activate_all_index=1;
- info(HA_STATUS_CONST); // Read new key info
}
- else
- enable_activate_all_index=0;
}
-
-bool ha_myisam::activate_all_index(THD *thd)
+int ha_myisam::end_bulk_insert()
{
- int error=0;
- MI_CHECK param;
- MYISAM_SHARE* share = file->s;
- DBUG_ENTER("activate_all_index");
-
mi_end_bulk_insert(file);
- if (enable_activate_all_index &&
- share->state.key_map != set_bits(ulonglong, share->base.keys))
- {
- const char *save_proc_info=thd->proc_info;
- thd->proc_info="Creating index";
- myisamchk_init(&param);
- param.op_name = (char*) "recreating_index";
- param.testflag = (T_SILENT | T_REP_BY_SORT | T_QUICK |
- T_CREATE_MISSING_KEYS);
- param.myf_rw&= ~MY_WAIT_IF_FULL;
- param.sort_buffer_length= thd->variables.myisam_sort_buff_size;
- param.tmpdir=&mysql_tmpdir_list;
- error=repair(thd,param,0) != HA_ADMIN_OK;
- info(HA_STATUS_CONST);
- thd->proc_info=save_proc_info;
- }
- else
- enable_activate_all_index=1;
- DBUG_RETURN(error);
+ int err=mi_extra(file, HA_EXTRA_NO_CACHE, 0);
+ return err ? err : can_enable_indexes ? enable_indexes() : 0;
}
@@ -1115,12 +1129,6 @@ int ha_myisam::extra_opt(enum ha_extra_function operation, ulong cache_size)
return mi_extra(file, operation, (void*) &cache_size);
}
-
-int ha_myisam::reset(void)
-{
- return mi_extra(file, HA_EXTRA_RESET, 0);
-}
-
int ha_myisam::delete_all_rows()
{
return mi_delete_all_rows(file);
diff --git a/sql/ha_myisam.h b/sql/ha_myisam.h
index 4d66639690d..ca318b02778 100644
--- a/sql/ha_myisam.h
+++ b/sql/ha_myisam.h
@@ -39,7 +39,7 @@ class ha_myisam: public handler
MI_INFO *file;
ulong int_table_flags;
char *data_file_name, *index_file_name;
- bool enable_activate_all_index;
+ bool can_enable_indexes;
int repair(THD *thd, MI_CHECK &param, bool optimize);
public:
@@ -48,7 +48,7 @@ class ha_myisam: public handler
HA_NULL_KEY | HA_CAN_FULLTEXT | HA_CAN_SQL_HANDLER |
HA_DUPP_POS | HA_BLOB_KEY | HA_AUTO_PART_KEY |
HA_FILE_BASED | HA_HAS_GEOMETRY),
- enable_activate_all_index(1)
+ can_enable_indexes(1)
{}
~ha_myisam() {}
const char *table_type() const { return "MyISAM"; }
@@ -103,11 +103,12 @@ class ha_myisam: public handler
void info(uint);
int extra(enum ha_extra_function operation);
int extra_opt(enum ha_extra_function operation, ulong cache_size);
- int reset(void);
int external_lock(THD *thd, int lock_type);
int delete_all_rows(void);
- void deactivate_non_unique_index(ha_rows rows);
- bool activate_all_index(THD *thd);
+ int disable_indexes(bool all, bool save);
+ int enable_indexes();
+ void start_bulk_insert(ha_rows rows);
+ int end_bulk_insert();
ha_rows records_in_range(int inx,
const byte *start_key,uint start_key_len,
enum ha_rkey_function start_search_flag,
diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc
index 7c36f6c6e0e..041d9eaead3 100644
--- a/sql/ha_myisammrg.cc
+++ b/sql/ha_myisammrg.cc
@@ -271,12 +271,6 @@ int ha_myisammrg::extra_opt(enum ha_extra_function operation, ulong cache_size)
return myrg_extra(file, operation, (void*) &cache_size);
}
-
-int ha_myisammrg::reset(void)
-{
- return myrg_extra(file,HA_EXTRA_RESET,0);
-}
-
int ha_myisammrg::external_lock(THD *thd, int lock_type)
{
return myrg_lock_database(file,lock_type);
diff --git a/sql/ha_myisammrg.h b/sql/ha_myisammrg.h
index ea53b40739d..c0f81a77a1e 100644
--- a/sql/ha_myisammrg.h
+++ b/sql/ha_myisammrg.h
@@ -79,7 +79,6 @@ class ha_myisammrg: public handler
void info(uint);
int extra(enum ha_extra_function operation);
int extra_opt(enum ha_extra_function operation, ulong cache_size);
- int reset(void);
int external_lock(THD *thd, int lock_type);
uint lock_count(void) const;
int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info);
diff --git a/sql/handler.h b/sql/handler.h
index 26fb762a9b5..dff814c94e6 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -51,7 +51,7 @@
#define HA_REC_NOT_IN_SEQ 8 /* ha_info don't return recnumber;
It returns a position to ha_r_rnd */
#define HA_HAS_GEOMETRY (1 << 4)
-#define HA_NO_INDEX (1 << 5) /* No index needed for next/prev */
+#define HA_FAST_KEY_READ (1 << 5) /* no need for a record cache in filesort */
#define HA_KEY_READ_WRONG_STR (1 << 6) /* keyread returns converted strings */
#define HA_NULL_KEY (1 << 7) /* One can have keys with NULL */
#define HA_DUPP_POS (1 << 8) /* ha_position() gives dupp row */
@@ -256,7 +256,6 @@ public:
{ return ulonglong2double(data_file_length) / IO_SIZE + 2; }
virtual double read_time(uint index, uint ranges, ha_rows rows)
{ return rows2double(ranges+rows); }
- virtual bool fast_key_read() { return 0;}
virtual const key_map *keys_to_use_for_scanning() { return &key_map_empty; }
virtual bool has_transactions(){ return 0;}
virtual uint extra_rec_buf_length() { return 0; }
@@ -310,7 +309,7 @@ public:
{
return extra(operation);
}
- virtual int reset()=0;
+ virtual int reset() { return extra(HA_EXTRA_RESET); }
virtual int external_lock(THD *thd, int lock_type)=0;
virtual void unlock_row() {}
virtual int start_stmt(THD *thd) {return 0;}
@@ -331,8 +330,10 @@ public:
*/
virtual int restore(THD* thd, HA_CHECK_OPT* check_opt);
virtual int dump(THD* thd, int fd = -1) { return ER_DUMP_NOT_IMPLEMENTED; }
- virtual void deactivate_non_unique_index(ha_rows rows) {}
- virtual bool activate_all_index(THD *thd) {return 0;}
+ virtual int disable_indexes(bool all, bool save) { return HA_ERR_WRONG_COMMAND; }
+ virtual int enable_indexes() { return HA_ERR_WRONG_COMMAND; }
+ virtual void start_bulk_insert(ha_rows rows) {}
+ virtual int end_bulk_insert() {return 0; }
virtual int discard_or_import_tablespace(my_bool discard) {return -1;}
// not implemented by default
virtual int net_read_dump(NET* net)
diff --git a/sql/item.cc b/sql/item.cc
index a0ca28ebd99..65e1e67c7c6 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1971,7 +1971,7 @@ bool field_is_equal_to_item(Field *field,Item *item)
item_result=item->val_str(&item_tmp);
if (item->null_value)
return 1; // This must be true
- field->val_str(&field_tmp,&field_tmp);
+ field->val_str(&field_tmp);
return !stringcmp(&field_tmp,item_result);
}
if (res_type == INT_RESULT)
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 3213ff94ab5..eac8d31b256 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -941,7 +941,7 @@ Item_sum_hybrid::min_max_update_str_field()
if (!args[0]->null_value)
{
res_str->strip_sp();
- result_field->val_str(&tmp_value,&tmp_value);
+ result_field->val_str(&tmp_value);
if (result_field->is_null() ||
(cmp_sign * sortcmp(res_str,&tmp_value,cmp_charset)) < 0)
@@ -1655,8 +1655,7 @@ int dump_leaf_key(byte* key, uint32 count __attribute__((unused)),
Item_func_group_concat *item)
{
char buff[MAX_FIELD_WIDTH];
- String tmp((char*) &buff, sizeof(buff), default_charset_info);
- String tmp2((char *) &buff, sizeof(buff), default_charset_info);
+ String tmp((char *)&buff,sizeof(buff),default_charset_info), tmp2;
char *record= (char*) item->table->record[0];
tmp.length(0);
diff --git a/sql/key.cc b/sql/key.cc
index d4499573e8e..a2c3b2c8989 100644
--- a/sql/key.cc
+++ b/sql/key.cc
@@ -233,7 +233,7 @@ void key_unpack(String *to,TABLE *table,uint idx)
}
if ((field=key_part->field))
{
- field->val_str(&tmp,&tmp);
+ field->val_str(&tmp);
if (key_part->length < field->pack_length())
tmp.length(min(tmp.length(),key_part->length));
to->append(tmp);
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index b6ac0eab53b..38ff7f14c40 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -2968,7 +2968,7 @@ print_key(KEY_PART *key_part,const char *key,uint used_length)
((field->type() == FIELD_TYPE_BLOB) ?
HA_KEY_BLOB_LENGTH : 0),
field->charset());
- field->val_str(&tmp,&tmp);
+ field->val_str(&tmp);
fwrite(tmp.ptr(),sizeof(char),tmp.length(),DBUG_FILE);
}
}
diff --git a/sql/protocol.cc b/sql/protocol.cc
index fb4d2a57ab6..a5944af829d 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -825,7 +825,7 @@ bool Protocol_simple::store(Field *field)
String str(buff,sizeof(buff), &my_charset_bin);
CHARSET_INFO *tocs= this->thd->variables.character_set_results;
- field->val_str(&str,&str);
+ field->val_str(&str);
if (tocs && !my_charset_same(field->charset(), tocs) &&
(field->charset() != &my_charset_bin) &&
(tocs != &my_charset_bin))
diff --git a/sql/records.cc b/sql/records.cc
index 0feb873a6af..ca00658cdae 100644
--- a/sql/records.cc
+++ b/sql/records.cc
@@ -80,7 +80,7 @@ void init_read_record(READ_RECORD *info,THD *thd, TABLE *table,
if (!table->sort.addon_field &&
! (specialflag & SPECIAL_SAFE_MODE) &&
thd->variables.read_rnd_buff_size &&
- !table->file->fast_key_read() &&
+ !(table->file->table_flags() & HA_FAST_KEY_READ) &&
(table->db_stat & HA_READ_ONLY ||
table->reginfo.lock_type <= TL_READ_NO_INSERT) &&
(ulonglong) table->reclength*(table->file->records+
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 63646dcc920..4b287ea9a8d 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -505,7 +505,7 @@ static ulong get_access(TABLE *form, uint fieldnr)
((Field_enum*) (*pos))->typelib->count == 2 ;
pos++ , bit<<=1)
{
- (*pos)->val_str(&res,&res);
+ (*pos)->val_str(&res);
if (my_toupper(&my_charset_latin1, res[0]) == 'Y')
access_bits|= bit;
}
@@ -1789,7 +1789,7 @@ public:
String *res,column_name;
GRANT_COLUMN *mem_check;
/* As column name is a string, we don't have to supply a buffer */
- res=col_privs->field[4]->val_str(&column_name,&column_name);
+ res=col_privs->field[4]->val_str(&column_name);
ulong priv= (ulong) col_privs->field[6]->val_int();
if (!(mem_check = new GRANT_COLUMN(*res,
fix_rights_for_column(priv))))
@@ -1992,7 +1992,7 @@ static int replace_column_table(GRANT_TABLE *g_t,
privileges&= ~rights;
table->field[6]->store((longlong)
get_rights_for_column(privileges));
- table->field[4]->val_str(&column_name,&column_name);
+ table->field[4]->val_str(&column_name);
grant_column = column_hash_search(g_t,
column_name.ptr(),
column_name.length());
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 93050419afa..e89224f078b 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -444,7 +444,7 @@ bool close_thread_table(THD *thd, TABLE **table_ptr)
else
{
// Free memory and reset for next loop
- table->file->extra(HA_EXTRA_RESET);
+ table->file->reset();
}
table->in_use=0;
if (unused_tables)
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 241b293262f..c6aff403f5b 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -260,17 +260,8 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
thd->proc_info="update";
if (duplic != DUP_ERROR)
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
- if ((lock_type != TL_WRITE_DELAYED && !(specialflag & SPECIAL_SAFE_MODE)) &&
- values_list.elements >= MIN_ROWS_TO_USE_BULK_INSERT)
- {
- table->file->extra_opt(HA_EXTRA_WRITE_CACHE,
- min(thd->variables.read_buff_size,
- table->avg_row_length*values_list.elements));
- table->file->deactivate_non_unique_index(values_list.elements);
- bulk_insert=1;
- }
- else
- bulk_insert=0;
+ if (lock_type != TL_WRITE_DELAYED)
+ table->file->start_bulk_insert(values_list.elements);
while ((values= its++))
{
@@ -348,24 +339,10 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
else
#endif
{
- if (bulk_insert)
+ if (table->file->end_bulk_insert() && !error)
{
- if (table->file->extra(HA_EXTRA_NO_CACHE))
- {
- if (!error)
- {
- table->file->print_error(my_errno,MYF(0));
- error=1;
- }
- }
- if (table->file->activate_all_index(thd))
- {
- if (!error)
- {
- table->file->print_error(my_errno,MYF(0));
- error=1;
- }
- }
+ table->file->print_error(my_errno,MYF(0));
+ error=1;
}
if (id && values_list.elements != 1)
thd->insert_id(id); // For update log
@@ -383,7 +360,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
transactional_table= table->file->has_transactions();
log_delayed= (transactional_table || table->tmp_table);
- if ((info.copied || info.deleted || info.updated) &&
+ if ((info.copied || info.deleted || info.updated) &&
(error <= 0 || !transactional_table))
{
mysql_update_log.write(thd, thd->query, thd->query_length);
@@ -1435,12 +1412,10 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
table->next_number_field=table->found_next_number_field;
thd->count_cuted_fields= CHECK_FIELD_WARN; // calc cuted fields
thd->cuted_fields=0;
- if (info.handle_duplicates != DUP_REPLACE)
- table->file->extra(HA_EXTRA_WRITE_CACHE);
if (info.handle_duplicates == DUP_IGNORE ||
info.handle_duplicates == DUP_REPLACE)
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
- table->file->deactivate_non_unique_index((ha_rows) 0);
+ table->file->start_bulk_insert((ha_rows) 0);
DBUG_RETURN(0);
}
@@ -1449,7 +1424,7 @@ select_insert::~select_insert()
if (table)
{
table->next_number_field=0;
- table->file->extra(HA_EXTRA_RESET);
+ table->file->reset();
}
thd->count_cuted_fields= CHECK_FIELD_IGNORE;
}
@@ -1493,15 +1468,14 @@ void select_insert::send_error(uint errcode,const char *err)
*/
DBUG_VOID_RETURN;
}
- table->file->extra(HA_EXTRA_NO_CACHE);
- table->file->activate_all_index(thd);
+ table->file->end_bulk_insert();
/*
If at least one row has been inserted/modified and will stay in the table
(the table doesn't have transactions) (example: we got a duplicate key
error while inserting into a MyISAM table) we must write to the binlog (and
the error code will make the slave stop).
*/
- if ((info.copied || info.deleted || info.updated) &&
+ if ((info.copied || info.deleted || info.updated) &&
!table->file->has_transactions())
{
if (last_insert_id)
@@ -1514,7 +1488,7 @@ void select_insert::send_error(uint errcode,const char *err)
mysql_bin_log.write(&qinfo);
}
if (!table->tmp_table)
- thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
+ thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
}
if (info.copied || info.deleted || info.updated)
query_cache_invalidate3(thd, table, 1);
@@ -1528,8 +1502,7 @@ bool select_insert::send_eof()
int error,error2;
DBUG_ENTER("select_insert::send_eof");
- if (!(error=table->file->extra(HA_EXTRA_NO_CACHE)))
- error=table->file->activate_all_index(thd);
+ error=table->file->end_bulk_insert();
table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
/*
@@ -1605,7 +1578,7 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
/* Don't set timestamp if used */
table->timestamp_default_now= table->timestamp_on_update_now= 0;
-
+
table->next_number_field=table->found_next_number_field;
restore_record(table,default_values); // Get empty record
@@ -1614,7 +1587,7 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
if (info.handle_duplicates == DUP_IGNORE ||
info.handle_duplicates == DUP_REPLACE)
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
- table->file->deactivate_non_unique_index((ha_rows) 0);
+ table->file->start_bulk_insert((ha_rows) 0);
DBUG_RETURN(0);
}
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index 7b7ed2e96d0..3d9299ca05c 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -276,14 +276,12 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
{
if (use_timestamp)
table->timestamp_default_now= table->timestamp_on_update_now= 0;
-
+
table->next_number_field=table->found_next_number_field;
- VOID(table->file->extra_opt(HA_EXTRA_WRITE_CACHE,
- thd->variables.read_buff_size));
if (handle_duplicates == DUP_IGNORE ||
handle_duplicates == DUP_REPLACE)
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
- table->file->deactivate_non_unique_index((ha_rows) 0);
+ table->file->start_bulk_insert((ha_rows) 0);
table->copy_blobs=1;
if (!field_term->length() && !enclosed->length())
error=read_fixed_length(thd,info,table,fields,read_info,
@@ -291,9 +289,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
else
error=read_sep_field(thd,info,table,fields,read_info,*enclosed,
skip_lines);
- if (table->file->extra(HA_EXTRA_NO_CACHE))
- error=1; /* purecov: inspected */
- if (table->file->activate_all_index(thd))
+ if (table->file->end_bulk_insert())
error=1; /* purecov: inspected */
table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
table->next_number_field=0;
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 021064c6bfc..c3c4124db1c 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -735,11 +735,11 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
*/
protocol->store("CURRENT_TIMESTAMP", system_charset_info);
}
- else if (field->unireg_check != Field::NEXT_NUMBER &&
+ else if (field->unireg_check != Field::NEXT_NUMBER &&
!field->is_null())
{ // Not null by default
type.set(tmp, sizeof(tmp), field->charset());
- field->val_str(&type,&type);
+ field->val_str(&type);
protocol->store(type.ptr(),type.length(),type.charset());
}
else if (field->unireg_check == Field::NEXT_NUMBER ||
@@ -1298,10 +1298,10 @@ store_create_info(THD *thd, TABLE *table, String *packet)
else if (!field->is_null())
{ // Not null by default
type.set(tmp, sizeof(tmp), field->charset());
- field->val_str(&type,&type);
+ field->val_str(&type);
if (type.length())
{
- String def_val;
+ String def_val;
/* convert to system_charset_info == utf8 */
def_val.copy(type.ptr(), type.length(), field->charset(),
system_charset_info);
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 3352c3a5f17..fa61f530b02 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -2259,25 +2259,25 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
VOID(pthread_mutex_lock(&LOCK_open));
wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN);
VOID(pthread_mutex_unlock(&LOCK_open));
- error= table->file->activate_all_index(thd);
+ error= table->file->enable_indexes();
/* COND_refresh will be signaled in close_thread_tables() */
break;
case DISABLE:
- if (table->db_type == DB_TYPE_MYISAM)
- {
- VOID(pthread_mutex_lock(&LOCK_open));
- wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN);
- VOID(pthread_mutex_unlock(&LOCK_open));
- table->file->deactivate_non_unique_index(HA_POS_ERROR);
+ VOID(pthread_mutex_lock(&LOCK_open));
+ wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN);
+ VOID(pthread_mutex_unlock(&LOCK_open));
+ error=table->file->disable_indexes(0, 1);
/* COND_refresh will be signaled in close_thread_tables() */
- }
- else
- push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_ILLEGAL_HA,
- ER(ER_ILLEGAL_HA), table->table_name);
break;
}
}
+ if (error==HA_ERR_WRONG_COMMAND)
+ {
+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
+ ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA),
+ table->table_name);
+ error=0;
+ }
if (!error)
{
mysql_update_log.write(thd, thd->query, thd->query_length);
@@ -2289,6 +2289,11 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
}
send_ok(thd);
}
+ else
+ {
+ table->file->print_error(error, MYF(0));
+ error=-1;
+ }
table_list->table=0; // For query cache
query_cache_invalidate3(thd, table_list, 0);
DBUG_RETURN(error);
@@ -2868,9 +2873,8 @@ copy_data_between_tables(TABLE *from,TABLE *to,
DBUG_RETURN(-1); /* purecov: inspected */
to->file->external_lock(thd,F_WRLCK);
- to->file->extra(HA_EXTRA_WRITE_CACHE);
from->file->info(HA_STATUS_VARIABLE);
- to->file->deactivate_non_unique_index(from->file->records);
+ to->file->start_bulk_insert(from->file->records);
List_iterator<create_field> it(create);
create_field *def;
@@ -2953,17 +2957,15 @@ copy_data_between_tables(TABLE *from,TABLE *to,
end_read_record(&info);
free_io_cache(from);
delete [] copy; // This is never 0
- uint tmp_error;
- if ((tmp_error=to->file->extra(HA_EXTRA_NO_CACHE)))
+
+ if (to->file->end_bulk_insert() && !error)
{
- to->file->print_error(tmp_error,MYF(0));
+ to->file->print_error(my_errno,MYF(0));
error=1;
}
to->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
- if (to->file->activate_all_index(thd))
- error=1;
- tmp_error = ha_recovery_logging(thd,TRUE);
+ ha_recovery_logging(thd,TRUE);
/*
Ensure that the new table is saved properly to disk so that we
can do a rename
@@ -3053,7 +3055,7 @@ int mysql_checksum_table(THD *thd, TABLE_LIST *tables, HA_CHECK_OPT *check_opt)
if (f->type() == FIELD_TYPE_BLOB)
{
String tmp;
- f->val_str(&tmp,&tmp);
+ f->val_str(&tmp);
row_crc= my_checksum(row_crc, (byte*) tmp.ptr(), tmp.length());
}
else
diff --git a/sql/table.cc b/sql/table.cc
index 23d99466a83..f137abf2ef7 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -1228,7 +1228,7 @@ bool get_field(MEM_ROOT *mem, Field *field, String *res)
String str(buff,sizeof(buff),&my_charset_bin);
uint length;
- field->val_str(&str,&str);
+ field->val_str(&str);
if (!(length= str.length()))
return 1;
to= strmake_root(mem, str.ptr(), length);
@@ -1256,7 +1256,7 @@ char *get_field(MEM_ROOT *mem, Field *field)
String str(buff,sizeof(buff),&my_charset_bin);
uint length;
- field->val_str(&str,&str);
+ field->val_str(&str);
length= str.length();
if (!length || !(to= (char*) alloc_root(mem,length+1)))
return NullS;