summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authormonty@bitch.mysql.fi <>2001-11-28 02:55:52 +0200
committermonty@bitch.mysql.fi <>2001-11-28 02:55:52 +0200
commitd0ccff50907e7b04f0d14ad95f359dc23e6dc294 (patch)
tree40e5d73c964ca6aeb5e0e7d4294e70216edaa397 /sql
parentd3288575de18b38179961a8acf93ba883a90e652 (diff)
downloadmariadb-git-d0ccff50907e7b04f0d14ad95f359dc23e6dc294.tar.gz
New improved IO_CACHE
Diffstat (limited to 'sql')
-rw-r--r--sql/ha_berkeley.cc6
-rw-r--r--sql/ha_innobase.cc24
-rw-r--r--sql/log.cc4
-rw-r--r--sql/mf_iocache.cc26
-rw-r--r--sql/opt_range.cc2
-rw-r--r--sql/sql_base.cc2
-rw-r--r--sql/sql_handler.cc6
-rw-r--r--sql/sql_load.cc2
-rw-r--r--sql/sql_parse.cc2
-rw-r--r--sql/sql_repl.cc8
-rw-r--r--sql/sql_select.cc2
11 files changed, 46 insertions, 38 deletions
diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc
index c11b1bbd4f8..3cb14b5e72f 100644
--- a/sql/ha_berkeley.cc
+++ b/sql/ha_berkeley.cc
@@ -1045,7 +1045,7 @@ int ha_berkeley::restore_keys(DB_TXN *trans, key_map changed_keys,
}
err:
- dbug_assert(error != DB_KEYEXIST);
+ DBUG_ASSERT(error != DB_KEYEXIST);
DBUG_RETURN(error);
}
@@ -1187,7 +1187,7 @@ int ha_berkeley::remove_key(DB_TXN *trans, uint keynr, const byte *record,
((table->key_info[keynr].flags & (HA_NOSAME | HA_NULL_PART_KEY)) ==
HA_NOSAME))
{ // Unique key
- dbug_assert(keynr == primary_key || prim_key->data != key_buff2);
+ DBUG_ASSERT(keynr == primary_key || prim_key->data != key_buff2);
error=key_file[keynr]->del(key_file[keynr], trans,
keynr == primary_key ?
prim_key :
@@ -1201,7 +1201,7 @@ int ha_berkeley::remove_key(DB_TXN *trans, uint keynr, const byte *record,
row to find the key to be delete and delete it.
We will never come here with keynr = primary_key
*/
- dbug_assert(keynr != primary_key && prim_key->data != key_buff2);
+ DBUG_ASSERT(keynr != primary_key && prim_key->data != key_buff2);
DBC *tmp_cursor;
if (!(error=key_file[keynr]->cursor(key_file[keynr], trans,
&tmp_cursor, 0)))
diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc
index 8c92e0635a5..b96eb86dbc1 100644
--- a/sql/ha_innobase.cc
+++ b/sql/ha_innobase.cc
@@ -196,7 +196,7 @@ convert_error_code_to_mysql(
return(HA_ERR_TO_BIG_ROW);
} else {
- dbug_assert(0);
+ DBUG_ASSERT(0);
return(-1); // Unknown error
}
@@ -259,7 +259,7 @@ check_trx_exists(
trx = (trx_t*) thd->transaction.all.innobase_tid;
if (trx == NULL) {
- dbug_assert(thd != NULL);
+ DBUG_ASSERT(thd != NULL);
trx = trx_allocate_for_mysql();
trx->mysql_thd = thd;
@@ -852,7 +852,7 @@ normalize_table_name(
name_ptr = ptr + 1;
- dbug_assert(ptr > name);
+ DBUG_ASSERT(ptr > name);
ptr--;
@@ -975,7 +975,7 @@ ha_innobase::open(
ref_length = DATA_ROW_ID_LEN + 10;
- dbug_assert(key_used_on_scan == MAX_KEY);
+ DBUG_ASSERT(key_used_on_scan == MAX_KEY);
}
auto_inc_counter_for_this_stat = 0;
@@ -1119,8 +1119,8 @@ innobase_mysql_cmp(
enum_field_types mysql_tp;
int ret;
- dbug_assert(a_length != UNIV_SQL_NULL);
- dbug_assert(b_length != UNIV_SQL_NULL);
+ DBUG_ASSERT(a_length != UNIV_SQL_NULL);
+ DBUG_ASSERT(b_length != UNIV_SQL_NULL);
mysql_tp = (enum_field_types) mysql_type;
@@ -1158,11 +1158,11 @@ get_innobase_type_from_mysql_type(
8 bits: this is used in ibuf and also when DATA_NOT_NULL is
ORed to the type */
- dbug_assert((ulint)FIELD_TYPE_STRING < 256);
- dbug_assert((ulint)FIELD_TYPE_VAR_STRING < 256);
- dbug_assert((ulint)FIELD_TYPE_DOUBLE < 256);
- dbug_assert((ulint)FIELD_TYPE_FLOAT < 256);
- dbug_assert((ulint)FIELD_TYPE_DECIMAL < 256);
+ DBUG_ASSERT((ulint)FIELD_TYPE_STRING < 256);
+ DBUG_ASSERT((ulint)FIELD_TYPE_VAR_STRING < 256);
+ DBUG_ASSERT((ulint)FIELD_TYPE_DOUBLE < 256);
+ DBUG_ASSERT((ulint)FIELD_TYPE_FLOAT < 256);
+ DBUG_ASSERT((ulint)FIELD_TYPE_DECIMAL < 256);
switch (field->type()) {
case FIELD_TYPE_VAR_STRING: if (field->flags & BINARY_FLAG) {
@@ -2368,7 +2368,7 @@ ha_innobase::position(
len = store_key_val_for_row(primary_key, (char*) ref, record);
}
- dbug_assert(len <= ref_length);
+ DBUG_ASSERT(len <= ref_length);
ref_stored_len = len;
}
diff --git a/sql/log.cc b/sql/log.cc
index 916e7d20d32..fa45d938b24 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -774,13 +774,13 @@ bool MYSQL_LOG::write(IO_CACHE *cache)
length=my_b_bytes_in_cache(cache);
do
{
- if (my_b_write(&log_file, cache->rc_pos, length))
+ if (my_b_write(&log_file, cache->read_pos, length))
{
if (!write_error)
sql_print_error(ER(ER_ERROR_ON_WRITE), name, errno);
goto err;
}
- cache->rc_pos=cache->rc_end; // Mark buffer used up
+ cache->read_pos=cache->read_end; // Mark buffer used up
} while ((length=my_b_fill(cache)));
if (flush_io_cache(&log_file))
{
diff --git a/sql/mf_iocache.cc b/sql/mf_iocache.cc
index 55e953687a3..2a7b25eab2f 100644
--- a/sql/mf_iocache.cc
+++ b/sql/mf_iocache.cc
@@ -52,26 +52,32 @@ int _my_b_net_read(register IO_CACHE *info, byte *Buffer,
{
int read_length;
NET *net= &(current_thd)->net;
+ DBUG_ENTER("_my_b_net_read");
- if (info->end_of_file)
- return 1; /* because my_b_get (no _) takes 1 byte at a time */
+ if (!info->end_of_file)
+ DBUG_RETURN(1); /* because my_b_get (no _) takes 1 byte at a time */
read_length=my_net_read(net);
if (read_length == (int) packet_error)
{
info->error= -1;
- return 1;
+ DBUG_RETURN(1);
}
if (read_length == 0)
{
- /* End of file from client */
- info->end_of_file = 1; return 1;
+ info->end_of_file= 0; /* End of file from client */
+ DBUG_RETURN(1);
}
/* to set up stuff for my_b_get (no _) */
- info->rc_end = (info->rc_pos = (byte*) net->read_pos) + read_length;
- Buffer[0] = info->rc_pos[0]; /* length is always 1 */
- info->rc_pos++;
- info->buffer = info->rc_pos;
- return 0;
+ info->read_end = (info->read_pos = (byte*) net->read_pos) + read_length;
+ Buffer[0] = info->read_pos[0]; /* length is always 1 */
+ info->read_pos++;
+
+ /*
+ info->request_pos is used by log_loaded_block() to know the size
+ of the current block
+ */
+ info->request_pos=info->read_pos;
+ DBUG_RETURN(0);
}
} /* extern "C" */
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 4c22dc5b6a2..4ac653e070c 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -2614,7 +2614,7 @@ int QUICK_SELECT_DESC::get_next()
}
else
{
- dbug_assert(range->flag & NEAR_MAX || range_reads_after_key(range));
+ DBUG_ASSERT(range->flag & NEAR_MAX || range_reads_after_key(range));
/* Note: even if max_key is only a prefix, HA_READ_AFTER_KEY will
* do the right thing - go past all keys which match the prefix */
result=file->index_read(record, (byte*) range->max_key,
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 2f8c44c6f0b..2c2c3f703b9 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -882,7 +882,7 @@ TABLE *open_table(THD *thd,const char *db,const char *table_name,
table->outer_join=table->null_row=table->maybe_null=0;
table->status=STATUS_NO_RECORD;
table->keys_in_use_for_query=table->used_keys= table->keys_in_use;
- dbug_assert(table->key_read == 0);
+ DBUG_ASSERT(table->key_read == 0);
DBUG_RETURN(table);
}
diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc
index f40ebfe43ed..c7fb237ccf2 100644
--- a/sql/sql_handler.cc
+++ b/sql/sql_handler.cc
@@ -126,7 +126,7 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
mode=RNEXT;
break;
case RLAST:
- dbug_assert(keyname != 0);
+ DBUG_ASSERT(keyname != 0);
err=table->file->index_last(table->record[0]);
mode=RPREV;
break;
@@ -136,12 +136,12 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
table->file->rnd_next(table->record[0]);
break;
case RPREV:
- dbug_assert(keyname != 0);
+ DBUG_ASSERT(keyname != 0);
err=table->file->index_prev(table->record[0]);
break;
case RKEY:
{
- dbug_assert(keyname != 0);
+ DBUG_ASSERT(keyname != 0);
KEY *keyinfo=table->key_info+keyno;
KEY_PART_INFO *key_part=keyinfo->key_part;
uint key_len;
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index 3d79ee6682f..17d1765495c 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -551,7 +551,7 @@ READ_INFO::READ_INFO(File file_par, uint tot_length, String &field_term,
need_end_io_cache = 1;
if (!opt_old_rpl_compat && mysql_bin_log.is_open())
cache.pre_read = cache.pre_close =
- (IO_CACHE_CALLBACK)log_loaded_block;
+ (IO_CACHE_CALLBACK) log_loaded_block;
}
}
}
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 0eabd971027..96185a174b5 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -288,7 +288,7 @@ static void decrease_user_connections(const char *user, const char *host)
uc = (struct user_conn *) hash_search(&hash_user_connections,
(byte*) temp_user, temp_len);
- dbug_assert(uc != 0); // We should always find the user
+ DBUG_ASSERT(uc != 0); // We should always find the user
if (!uc)
goto end; // Safety; Something went wrong
if (! --uc->connections)
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 431f2ef5d5e..6c738ba36b4 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -137,7 +137,7 @@ File open_binlog(IO_CACHE *log, const char *log_file_name,
if ((file = my_open(log_file_name, O_RDONLY | O_BINARY, MYF(MY_WME))) < 0 ||
init_io_cache(log, file, IO_SIZE*2, READ_CACHE, 0, 0,
- MYF(MY_WME)))
+ MYF(MY_WME | MY_DONT_CHECK_FILESIZE)))
{
*errmsg = "Could not open log file"; // This will not be sent
goto err;
@@ -1024,8 +1024,10 @@ int log_loaded_block(IO_CACHE* file)
{
LOAD_FILE_INFO* lf_info;
uint block_len ;
- char* buffer = (char*)file->buffer;
- if (!(block_len = file->rc_end - buffer))
+
+ /* file->request_pos contains position where we started last read */
+ char* buffer = (char*) file->request_pos;
+ if (!(block_len = file->read_end - buffer))
return 0;
lf_info = (LOAD_FILE_INFO*)file->arg;
if (lf_info->last_pos_in_file != HA_POS_ERROR &&
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 131362167cb..b40c98cbb52 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -2680,7 +2680,7 @@ eq_ref_table(JOIN *join, ORDER *start_order, JOIN_TAB *tab)
if (order)
{
found++;
- dbug_assert(!(order->used & map));
+ DBUG_ASSERT(!(order->used & map));
order->used|=map;
continue; // Used in ORDER BY
}