summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authormonty@hundin.mysql.fi <>2001-11-26 03:30:16 +0200
committermonty@hundin.mysql.fi <>2001-11-26 03:30:16 +0200
commitcefe361b827ac831e5323424424919c26999dff4 (patch)
tree5af6c2ffd0a12a6830b9504e665f80be858ad71d /sql
parentbbc5277cc9efc1d1aa6538582cc2f1c0bd79e033 (diff)
parent50b43f85ef6ae6d01e48a0c4b57df20299393618 (diff)
downloadmariadb-git-cefe361b827ac831e5323424424919c26999dff4.tar.gz
merge
Diffstat (limited to 'sql')
-rw-r--r--sql/records.cc44
-rw-r--r--sql/sql_table.cc9
2 files changed, 40 insertions, 13 deletions
diff --git a/sql/records.cc b/sql/records.cc
index 5edbd6896b5..37f79e54cf6 100644
--- a/sql/records.cc
+++ b/sql/records.cc
@@ -132,8 +132,13 @@ static int rr_quick(READ_RECORD *info)
{
if (tmp == HA_ERR_END_OF_FILE)
tmp= -1;
- else if (info->print_error)
- info->file->print_error(tmp,MYF(0));
+ else
+ {
+ if (info->print_error)
+ info->file->print_error(tmp,MYF(0));
+ if (tmp < 0) // Fix negative BDB errno
+ tmp=1;
+ }
}
return tmp;
}
@@ -153,8 +158,13 @@ static int rr_sequential(READ_RECORD *info)
{
if (tmp == HA_ERR_END_OF_FILE)
tmp= -1;
- else if (info->print_error)
- info->table->file->print_error(tmp,MYF(0));
+ else
+ {
+ if (info->print_error)
+ info->table->file->print_error(tmp,MYF(0));
+ if (tmp < 0) // Fix negative BDB errno
+ tmp=1;
+ }
break;
}
}
@@ -168,21 +178,27 @@ static int rr_from_tempfile(READ_RECORD *info)
tryNext:
if (my_b_read(info->io_cache,info->ref_pos,info->ref_length))
return -1; /* End of file */
- tmp=info->file->rnd_pos(info->record,info->ref_pos);
- if (tmp)
+ if ((tmp=info->file->rnd_pos(info->record,info->ref_pos)))
{
if (tmp == HA_ERR_END_OF_FILE)
tmp= -1;
else if (tmp == HA_ERR_RECORD_DELETED)
goto tryNext;
- else if (info->print_error)
- info->file->print_error(tmp,MYF(0));
+ else
+ {
+ if (info->print_error)
+ info->file->print_error(tmp,MYF(0));
+ if (tmp < 0) // Fix negative BDB errno
+ tmp=1;
+ }
}
return tmp;
} /* rr_from_tempfile */
+
static int rr_from_pointers(READ_RECORD *info)
{
+ int tmp;
byte *cache_pos;
tryNext:
if (info->cache_pos == info->cache_end)
@@ -190,15 +206,19 @@ tryNext:
cache_pos=info->cache_pos;
info->cache_pos+=info->ref_length;
- int tmp=info->file->rnd_pos(info->record,cache_pos);
- if (tmp)
+ if ((tmp=info->file->rnd_pos(info->record,cache_pos)))
{
if (tmp == HA_ERR_END_OF_FILE)
tmp= -1;
else if (tmp == HA_ERR_RECORD_DELETED)
goto tryNext;
- else if (info->print_error)
- info->file->print_error(tmp,MYF(0));
+ else
+ {
+ if (info->print_error)
+ info->file->print_error(tmp,MYF(0));
+ if (tmp < 0) // Fix negative BDB errno
+ tmp=1;
+ }
}
return tmp;
}
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index b0e319288d9..049fb1c182c 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -954,9 +954,11 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
}
/* Close all instances of the table to allow repair to rename files */
- if (open_for_modify && table->table->version)
+ if (lock_type == TL_WRITE && table->table->version)
{
pthread_mutex_lock(&LOCK_open);
+ const char *old_message=thd->enter_cond(&COND_refresh, &LOCK_open,
+ "Waiting to get writelock");
mysql_lock_abort(thd,table->table);
while (remove_table_from_cache(thd, table->table->table_cache_key,
table->table->real_name) &&
@@ -966,9 +968,11 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
(void) pthread_cond_wait(&COND_refresh,&LOCK_open);
dropping_tables--;
}
+ thd->exit_cond(old_message);
pthread_mutex_unlock(&LOCK_open);
if (thd->killed)
goto err;
+ open_for_modify=0;
}
int result_code = (table->table->file->*operator_func)(thd, check_opt);
@@ -1016,6 +1020,9 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
}
if (fatal_error)
table->table->version=0; // Force close of table
+ else if (open_for_modify)
+ remove_table_from_cache(thd, table->table->table_cache_key,
+ table->table->real_name);
close_thread_tables(thd);
if (my_net_write(&thd->net, (char*) packet->ptr(),
packet->length()))