summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <serg@serg.mysql.com>2000-12-07 15:13:01 +0100
committerunknown <serg@serg.mysql.com>2000-12-07 15:13:01 +0100
commitd81d52953559068fcc8e748f754404aeefdeaf8e (patch)
tree6d4aa8fb2dd502b14dc3787377ded8f6d0599c5d
parent54649a94c554969f2de158338f738db30696abac (diff)
parent5496809dac455ffc7c4bb0515e8360d1e73659d1 (diff)
downloadmariadb-git-d81d52953559068fcc8e748f754404aeefdeaf8e.tar.gz
Merge
sql/sql_base.cc: merged BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted
-rw-r--r--BitKeeper/etc/logging_ok1
-rw-r--r--myisammrg/mymrgdef.h8
-rw-r--r--myisammrg/myrg_extra.c20
-rw-r--r--myisammrg/myrg_info.c8
-rw-r--r--myisammrg/myrg_rrnd.c45
-rw-r--r--sql/sql_base.cc25
6 files changed, 62 insertions, 45 deletions
diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok
index 5ca7ce98828..bc7425784fb 100644
--- a/BitKeeper/etc/logging_ok
+++ b/BitKeeper/etc/logging_ok
@@ -1 +1,2 @@
jani@prima.mysql.com
+serg@serg.mysql.com
diff --git a/myisammrg/mymrgdef.h b/myisammrg/mymrgdef.h
index bfa24c778f4..564900614e2 100644
--- a/myisammrg/mymrgdef.h
+++ b/myisammrg/mymrgdef.h
@@ -1,15 +1,15 @@
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
@@ -30,5 +30,3 @@ extern pthread_mutex_t THR_LOCK_open;
int _myrg_init_queue(MYRG_INFO *info,int inx,enum ha_rkey_function search_flag);
int _myrg_finish_scan(MYRG_INFO *info, int inx, enum ha_rkey_function type);
-MYRG_TABLE *_myrg_find_table(MYRG_INFO *info, ulonglong pos);
-
diff --git a/myisammrg/myrg_extra.c b/myisammrg/myrg_extra.c
index 4b5353a146d..f6458588b59 100644
--- a/myisammrg/myrg_extra.c
+++ b/myisammrg/myrg_extra.c
@@ -1,15 +1,15 @@
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
@@ -26,6 +26,8 @@ int myrg_extra(MYRG_INFO *info,enum ha_extra_function function)
{
int error,save_error=0;
MYRG_TABLE *file;
+ DBUG_ENTER("myrg_extra");
+ DBUG_PRINT("info",("function: %d",(ulong) function));
if (function == HA_EXTRA_CACHE)
info->cache_in_use=1;
@@ -38,9 +40,19 @@ int myrg_extra(MYRG_INFO *info,enum ha_extra_function function)
info->current_table=0;
info->last_used_table=info->open_tables;
}
+
+ info->records=info->del=info->data_file_length=0;
for (file=info->open_tables ; file != info->end_table ; file++)
+ {
if ((error=mi_extra(file->table,function)))
save_error=error;
+ file->file_offset=info->data_file_length;
+ info->data_file_length+=file->table->s->state.state.data_file_length;
+ info->records+=file->table->s->state.state.records;
+ info->del+=file->table->s->state.state.del;
+ DBUG_PRINT("info2",("table: %s, offset: 0x%08lx",
+ file->table->filename,(ulong)file->file_offset));
+ }
}
- return save_error;
+ DBUG_RETURN(save_error);
}
diff --git a/myisammrg/myrg_info.c b/myisammrg/myrg_info.c
index e556c807dfa..959a34935fd 100644
--- a/myisammrg/myrg_info.c
+++ b/myisammrg/myrg_info.c
@@ -1,15 +1,15 @@
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
@@ -35,8 +35,6 @@ int myrg_status(MYRG_INFO *info,register MYMERGE_INFO *x,int flag)
MYRG_TABLE *current_table;
DBUG_ENTER("myrg_status");
- _myrg_find_table(info, HA_OFFSET_ERROR);
-
if (!(current_table = info->current_table) &&
info->open_tables != info->end_table)
current_table = info->open_tables;
diff --git a/myisammrg/myrg_rrnd.c b/myisammrg/myrg_rrnd.c
index 298ef112469..77fe00a1bb1 100644
--- a/myisammrg/myrg_rrnd.c
+++ b/myisammrg/myrg_rrnd.c
@@ -21,6 +21,8 @@
#include "mymrgdef.h"
+static MYRG_TABLE *find_table(MYRG_TABLE *start,MYRG_TABLE *end,ulonglong pos);
+
/*
If filepos == HA_OFFSET_ERROR, read next
Returns same as mi_rrnd:
@@ -33,6 +35,8 @@ int myrg_rrnd(MYRG_INFO *info,byte *buf,ulonglong filepos)
{
int error;
MI_INFO *isam_info;
+ DBUG_ENTER("myrg_rrnd");
+ DBUG_PRINT("info",("offset: 0x%016qx", (ulonglong)filepos));
if (filepos == HA_OFFSET_ERROR)
{
@@ -40,7 +44,7 @@ int myrg_rrnd(MYRG_INFO *info,byte *buf,ulonglong filepos)
{
if (info->open_tables == info->end_table)
{ /* No tables */
- return (my_errno=HA_ERR_END_OF_FILE);
+ DBUG_RETURN(my_errno=HA_ERR_END_OF_FILE);
}
isam_info=(info->current_table=info->open_tables)->table;
if (info->cache_in_use)
@@ -60,11 +64,11 @@ int myrg_rrnd(MYRG_INFO *info,byte *buf,ulonglong filepos)
if ((error=(*isam_info->s->read_rnd)(isam_info,(byte*) buf,
(my_off_t) filepos,1)) !=
HA_ERR_END_OF_FILE)
- return (error);
+ DBUG_RETURN(error);
if (info->cache_in_use)
mi_extra(info->current_table->table,HA_EXTRA_NO_CACHE);
if (info->current_table+1 == info->end_table)
- return(HA_ERR_END_OF_FILE);
+ DBUG_RETURN(HA_ERR_END_OF_FILE);
info->current_table++;
info->last_used_table=info->current_table;
if (info->cache_in_use)
@@ -78,31 +82,34 @@ int myrg_rrnd(MYRG_INFO *info,byte *buf,ulonglong filepos)
isam_info->lastinx= (uint) -1;
}
}
- info->current_table=_myrg_find_table(info,filepos);
+ info->current_table=find_table(info->open_tables,
+ info->end_table-1,filepos);
isam_info=info->current_table->table;
isam_info->update&= HA_STATE_CHANGED;
- return ((*isam_info->s->read_rnd)
- (isam_info, (byte*) buf,
- (ha_rows) (filepos - info->current_table->file_offset),
- 0));
+ DBUG_RETURN((*isam_info->s->read_rnd)
+ (isam_info, (byte*) buf,
+ (ha_rows) (filepos - info->current_table->file_offset),
+ 0));
}
/* Find which table to use according to file-pos */
-MYRG_TABLE *_myrg_find_table(MYRG_INFO *info, ulonglong pos)
+static MYRG_TABLE *find_table(MYRG_TABLE *start, MYRG_TABLE *end,
+ ulonglong pos)
{
- MYRG_TABLE *t;
-
- info->records=info->del=info->data_file_length=0;
+ MYRG_TABLE *mid;
+ DBUG_ENTER("find_table");
- for (t=info->open_tables ; t < info->end_table ; t++)
+ while (start != end)
{
- t->file_offset=info->data_file_length;
- if (pos < t->file_offset) return t-1;
- info->data_file_length+=t->table->state->data_file_length;
- info->records+=t->table->state->records;
- info->del+=t->table->state->del;
+ mid=start+((uint) (end-start)+1)/2;
+ if (mid->file_offset > pos)
+ end=mid-1;
+ else
+ start=mid;
}
- return t-1;
+ DBUG_PRINT("info",("offset: 0x%016qx, table: %s",
+ (ulonglong)pos, start->table->filename));
+ DBUG_RETURN(start);
}
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 63c17dae740..45a8ebfa54f 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -426,22 +426,22 @@ void close_temporary_tables(THD *thd)
char* query, *p;
LINT_INIT(p);
query_buf_size = init_query_buf_size;
-
+
for (table=thd->temporary_tables ; table ; table=table->next)
{
query_buf_size += table->key_length;
-
+
}
if(query_buf_size == init_query_buf_size)
return; // no tables to close
-
+
if((query = alloc_root(&thd->mem_root, query_buf_size)))
{
memcpy(query, "drop table ", init_query_buf_size);
p = query + init_query_buf_size;
}
-
+
for (table=thd->temporary_tables ; table ; table=next)
{
if(query) // we might be out of memory, but this is not fatal
@@ -475,7 +475,7 @@ TABLE **find_temporary_table(THD *thd, const char *db, const char *table_name)
int4store(key+key_length,thd->slave_proxy_id);
key_length += 4;
-
+
prev= &thd->temporary_tables;
for (table=thd->temporary_tables ; table ; table=table->next)
{
@@ -623,7 +623,7 @@ TABLE *reopen_name_locked_table(THD* thd, TABLE_LIST* table_list)
pthread_mutex_unlock(&LOCK_open);
DBUG_RETURN(0);
}
-
+
table->key_length=key_length;
table->version=0;
table->flush_version=0;
@@ -640,7 +640,7 @@ TABLE *reopen_name_locked_table(THD* thd, TABLE_LIST* table_list)
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_RETURN(table);
+ DBUG_RETURN(table);
}
@@ -669,7 +669,7 @@ TABLE *open_table(THD *thd,const char *db,const char *table_name,
DBUG_RETURN(0);
key_length= (uint) (strmov(strmov(key,db)+1,table_name)-key)+1;
int4store(key + key_length, thd->slave_proxy_id);
-
+
for (table=thd->temporary_tables; table ; table=table->next)
{
if (table->key_length == key_length+4 &&
@@ -740,6 +740,7 @@ TABLE *open_table(THD *thd,const char *db,const char *table_name,
}
table->prev->next=table->next; /* Remove from unused list */
table->next->prev=table->prev;
+ table->file->reset();
}
else
{
@@ -1086,7 +1087,7 @@ bool wait_for_tables(THD *thd)
close_old_data_files(thd,thd->open_tables,0,dropping_tables != 0);
if (!table_is_used(thd->open_tables,1))
break;
- (void) pthread_cond_wait(&COND_refresh,&LOCK_open);
+ (void) pthread_cond_wait(&COND_refresh,&LOCK_open);
}
if (thd->killed)
result= 1; // aborted
@@ -1206,7 +1207,7 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db,
HA_TRY_READ_ONLY),
READ_KEYINFO | COMPUTE_TYPES | EXTRA_RECORD,
ha_open_options | HA_OPEN_FOR_REPAIR,
- entry) || ! entry->file ||
+ entry) || ! entry->file ||
(entry->file->is_crashed() && entry->file->check_and_repair(thd)))
{
/* Give right error message */
@@ -1383,7 +1384,7 @@ TABLE *open_temporary_table(THD *thd, const char *path, const char *db,
{
TABLE *tmp_table;
DBUG_ENTER("open_temporary_table");
-
+
// the extra size in my_malloc() is for table_cache_key
// 4 bytes for master thread id if we are in the slave
// 1 byte to terminate db
@@ -1414,7 +1415,7 @@ TABLE *open_temporary_table(THD *thd, const char *path, const char *db,
int4store(tmp_table->table_cache_key + tmp_table->key_length,
thd->slave_proxy_id);
tmp_table->key_length += 4;
-
+
if (link_in_list)
{
tmp_table->next=thd->temporary_tables;