diff options
author | unknown <konstantin@mysql.com> | 2006-02-02 18:17:18 +0300 |
---|---|---|
committer | unknown <konstantin@mysql.com> | 2006-02-02 18:17:18 +0300 |
commit | 95a3509a6637699fdcc26d7042013778c5e55d08 (patch) | |
tree | 336ed0f3ebd53f06d2b14904f4fd937b5fe487c6 /sql/ha_heap.cc | |
parent | 9b3e6c27b0615270042cff92c88cb338ded9b69f (diff) | |
parent | 1e686ae7702d297cc9fd261c42864653f4fdd7b3 (diff) | |
download | mariadb-git-95a3509a6637699fdcc26d7042013778c5e55d08.tar.gz |
Merge mysql.com:/opt/local/work/mysql-4.1-root
into mysql.com:/opt/local/work/mysql-5.0-root
BitKeeper/deleted/.del-rpl_ignore_table.result:
Delete: mysql-test/r/rpl_ignore_table.result
BitKeeper/deleted/.del-rpl_multi_update4.result:
Delete: mysql-test/r/rpl_multi_update4.result
BitKeeper/deleted/.del-rpl_ignore_table-slave.opt:
Delete: mysql-test/t/rpl_ignore_table-slave.opt
BitKeeper/deleted/.del-rpl_ignore_table.test:
Delete: mysql-test/t/rpl_ignore_table.test
BitKeeper/deleted/.del-rpl_multi_update4-slave.opt:
Delete: mysql-test/t/rpl_multi_update4-slave.opt
BitKeeper/deleted/.del-disabled.def:
Auto merged
BitKeeper/deleted/.del-rpl_multi_update4.test:
Delete: mysql-test/t/rpl_multi_update4.test
heap/hp_create.c:
Auto merged
mysql-test/r/date_formats.result:
Auto merged
mysql-test/r/myisam.result:
Auto merged
mysql-test/r/update.result:
Auto merged
mysql-test/t/date_formats.test:
Auto merged
mysql-test/t/heap.test:
Auto merged
mysql-test/t/kill.test:
Auto merged
mysql-test/t/update.test:
Auto merged
ndb/include/mgmapi/mgmapi_config_parameters.h:
Auto merged
ndb/test/ndbapi/testBlobs.cpp:
Auto merged
sql/sql_base.cc:
Auto merged
sql/sql_select.cc:
Auto merged
sql/sql_select.h:
Auto merged
configure.in:
Manual merge.
libmysql/libmysql.c:
Manual merge.
mysql-test/r/heap.result:
Manual merge.
mysql-test/r/heap_hash.result:
Manual merge.
mysql-test/r/kill.result:
Manual merge.
sql/ha_heap.cc:
Manual merge.
sql/ha_heap.h:
Manual merge.
sql/item_timefunc.cc:
Manual merge.
sql/sql_class.cc:
Manual merge.
sql/sql_parse.cc:
Manual merge.
sql/sql_update.cc:
Manual merge.
tests/mysql_client_test.c:
Manual merge.
Diffstat (limited to 'sql/ha_heap.cc')
-rw-r--r-- | sql/ha_heap.cc | 56 |
1 files changed, 45 insertions, 11 deletions
diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc index 98cc96db707..2a989a71edc 100644 --- a/sql/ha_heap.cc +++ b/sql/ha_heap.cc @@ -53,7 +53,7 @@ handlerton heap_hton= { ha_heap::ha_heap(TABLE *table_arg) :handler(&heap_hton, table_arg), file(0), records_changed(0), - key_stats_ok(0) + key_stats_version(0) {} @@ -104,7 +104,7 @@ int ha_heap::open(const char *name, int mode, uint test_if_locked) ha_heap::info(), which is always called before key statistics are used. */ - key_stats_ok= FALSE; + key_stat_version= file->s->key_stat_version-1; } return (file ? 0 : 1); } @@ -151,14 +151,21 @@ void ha_heap::update_key_stats() continue; if (key->algorithm != HA_KEY_ALG_BTREE) { - ha_rows hash_buckets= file->s->keydef[i].hash_buckets; - key->rec_per_key[key->key_parts-1]= - hash_buckets ? file->s->records/hash_buckets : 0; + if (key->flags & HA_NOSAME) + key->rec_per_key[key->key_parts-1]= 1; + else + { + ha_rows hash_buckets= file->s->keydef[i].hash_buckets; + uint no_records= hash_buckets ? file->s->records/hash_buckets : 2; + if (no_records < 2) + no_records= 2; + key->rec_per_key[key->key_parts-1]= no_records; + } } } records_changed= 0; /* At the end of update_key_stats() we can proudly claim they are OK. */ - key_stats_ok= TRUE; + key_stat_version= file->s->key_stat_version; } @@ -173,7 +180,13 @@ int ha_heap::write_row(byte * buf) res= heap_write(file,buf); if (!res && (++records_changed*HEAP_STATS_UPDATE_THRESHOLD > file->s->records)) - key_stats_ok= FALSE; + { + /* + We can perform this safely since only one writer at the time is + allowed on the table. + */ + file->s->key_stat_version++; + } return res; } @@ -186,7 +199,13 @@ int ha_heap::update_row(const byte * old_data, byte * new_data) res= heap_update(file,old_data,new_data); if (!res && ++records_changed*HEAP_STATS_UPDATE_THRESHOLD > file->s->records) - key_stats_ok= FALSE; + { + /* + We can perform this safely since only one writer at the time is + allowed on the table. + */ + file->s->key_stat_version++; + } return res; } @@ -197,7 +216,13 @@ int ha_heap::delete_row(const byte * buf) res= heap_delete(file,buf); if (!res && table->s->tmp_table == NO_TMP_TABLE && ++records_changed*HEAP_STATS_UPDATE_THRESHOLD > file->s->records) - key_stats_ok= FALSE; + { + /* + We can perform this safely since only one writer at the time is + allowed on the table. + */ + file->s->key_stat_version++; + } return res; } @@ -324,7 +349,7 @@ void ha_heap::info(uint flag) have to update the key statistics. Hoping that a table lock is now in place. */ - if (! key_stats_ok) + if (key_stat_version != file->s->key_stat_version) update_key_stats(); } @@ -337,7 +362,13 @@ int ha_heap::delete_all_rows() { heap_clear(file); if (table->s->tmp_table == NO_TMP_TABLE) - key_stats_ok= FALSE; + { + /* + We can perform this safely since only one writer at the time is + allowed on the table. + */ + file->s->key_stat_version++; + } return 0; } @@ -497,6 +528,9 @@ ha_rows ha_heap::records_in_range(uint inx, key_range *min_key, max_key->flag != HA_READ_AFTER_KEY) return HA_POS_ERROR; // Can only use exact keys + if (records <= 1) + return records; + /* Assert that info() did run. We need current statistics here. */ DBUG_ASSERT(key_stats_ok); return key->rec_per_key[key->key_parts-1]; |