Commit 2ba0846a authored by monty@donna.mysql.fi's avatar monty@donna.mysql.fi

Fixed bug when using MERGE on files > 4G

Fixed bug in SELECT db1.table.* FROM db1.table,db2.table
Fixed bug in INSERT DELAYED when doing shutdown and a table was locked
Changed that tmp_table_size =4G-1 means unlimited.
parent b708df26
This diff is collapsed.
......@@ -340,7 +340,7 @@ int main(int argc,char *argv[])
}
#endif
sprintf(buff,
"Type 'help;' or '\\h' for help. Type '\\c' to clear the buffer\n");
"Type 'help;' or '\\h' for help. Type '\\c' to clear the buffer.\n");
put_info(buff,INFO_INFO);
status.exit_status=read_lines(1); // read lines and execute them
if (opt_outfile)
......
......@@ -28,7 +28,7 @@ int mi_rkey(MI_INFO *info, byte *buf, int inx, const byte *key, uint key_len,
uchar *key_buff;
MYISAM_SHARE *share=info->s;
uint pack_key_length;
DBUG_ENTER("_mi_rkey");
DBUG_ENTER("mi_rkey");
DBUG_PRINT("enter",("base: %lx inx: %d search_flag: %d",
info,inx,search_flag));
......
......@@ -158,7 +158,7 @@ int _mi_search(register MI_INFO *info, register MI_KEYDEF *keyinfo,
info->page_changed=0;
info->buff_used= (info->buff != buff); /* If we have to reread buff */
DBUG_PRINT("exit",("found key at %ld",info->lastpos));
DBUG_PRINT("exit",("found key at %lu",(ulong) info->lastpos));
DBUG_RETURN(0);
err:
DBUG_PRINT("exit",("Error: %d",my_errno));
......@@ -1276,7 +1276,7 @@ int _mi_search_next(register MI_INFO *info, register MI_KEYDEF *keyinfo,
}
memcpy(info->lastkey,lastkey,info->lastkey_length);
info->lastpos=_mi_dpos(info,0,info->lastkey+info->lastkey_length);
DBUG_PRINT("exit",("found key at %d",info->lastpos));
DBUG_PRINT("exit",("found key at %lu",(ulong) info->lastpos));
DBUG_RETURN(0);
} /* _mi_search_next */
......@@ -1318,7 +1318,7 @@ int _mi_search_first(register MI_INFO *info, register MI_KEYDEF *keyinfo,
info->page_changed=info->buff_used=0;
info->lastpos=_mi_dpos(info,0,info->lastkey+info->lastkey_length);
DBUG_PRINT("exit",("found key at %d",info->lastpos));
DBUG_PRINT("exit",("found key at %ld",(ulong) info->lastpos));
DBUG_RETURN(0);
} /* _mi_search_first */
......@@ -1362,7 +1362,7 @@ int _mi_search_last(register MI_INFO *info, register MI_KEYDEF *keyinfo,
info->last_search_keypage=info->last_keypage;
info->page_changed=info->buff_used=0;
DBUG_PRINT("exit",("found key at %d",info->lastpos));
DBUG_PRINT("exit",("found key at %lu",(ulong) info->lastpos));
DBUG_RETURN(0);
} /* _mi_search_last */
......
......@@ -88,7 +88,7 @@ int myrg_rrnd(MYRG_INFO *info,byte *buf,ulonglong filepos)
isam_info->update&= HA_STATE_CHANGED;
DBUG_RETURN((*isam_info->s->read_rnd)
(isam_info, (byte*) buf,
(ha_rows) (filepos - info->current_table->file_offset),
(my_off_t) (filepos - info->current_table->file_offset),
0));
}
......
......@@ -56,7 +56,7 @@ my_bool set_changeable_var(my_string str,CHANGEABLE_VAR *vars)
CHANGEABLE_VAR *var,*found;
my_string var_end;
const char *name;
long num;
longlong num;
/* Skip end space from variable */
for (var_end=end ; end > str && isspace(var_end[-1]) ; var_end--) ;
......@@ -87,7 +87,7 @@ my_bool set_changeable_var(my_string str,CHANGEABLE_VAR *vars)
DBUG_RETURN(1);
}
num=(long) atol(end); endchar=strend(end)[-1];
num=atoll(end); endchar=strend(end)[-1];
if (endchar == 'k' || endchar == 'K')
num*=1024;
else if (endchar == 'm' || endchar == 'M')
......@@ -99,14 +99,12 @@ my_bool set_changeable_var(my_string str,CHANGEABLE_VAR *vars)
fprintf(stderr,"Unknown prefix used for variable value '%s'\n",str);
DBUG_RETURN(1);
}
if (num < (long) found->min_value)
num=(long) found->min_value;
else if ((unsigned long) num >
(unsigned long) found->max_value)
num=(long) found->max_value;
*found->varptr=(long) ((ulong) (num-found->sub_size) /
(ulong) found->block_size);
(*found->varptr)*= (ulong) found->block_size;
if (num < (longlong) found->min_value)
num=(longlong) found->min_value;
else if (num > (longlong) (ulong) found->max_value)
num=(longlong) (ulong) found->max_value;
num=((num- (longlong) found->sub_size) / (ulonglong) found->block_size);
(*found->varptr)= (long) (num*(ulonglong) found->block_size);
DBUG_RETURN(0);
}
}
......
......@@ -370,7 +370,7 @@ static my_bool wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data,
do
{
pthread_cond_wait(cond,&data->lock->mutex);
} while (data->cond == cond && !thread_var->abort);
} while (data->cond == cond && (!thread_var->abort || in_wait_list));
if (data->cond || data->type == TL_UNLOCK)
{
......
......@@ -2701,7 +2701,7 @@ CHANGEABLE_VAR changeable_vars[] = {
1024, 4, 8192*1024L, 0, 1 },
{ "max_tmp_tables", (long*) &max_tmp_tables,
32, 1, ~0L, 0, 1 },
{ "max_user_connections", (long*) &max_user_connections,
{ "max_user_connections", (long*) &max_user_connections,
0, 1, ~0L, 0, 1 },
{ "max_write_lock_count", (long*) &max_write_lock_count,
~0L, 1, ~0L, 0, 1 },
......@@ -2737,7 +2737,7 @@ CHANGEABLE_VAR changeable_vars[] = {
{ "thread_cache_size", (long*) &thread_cache_size,
0, 0, 16384, 0, 1 },
{ "tmp_table_size", (long*) &tmp_table_size,
1024*1024L, 1024, ~0L, MALLOC_OVERHEAD, 1 },
32*1024*1024L, 1024, ~0L, 0, 1 },
{ "thread_stack", (long*) &thread_stack,
DEFAULT_THREAD_STACK, 1024*32, ~0L, 0, 1024 },
{ "wait_timeout", (long*) &net_wait_timeout,
......
......@@ -34,8 +34,8 @@ HASH open_cache; /* Used by mysql_test */
static int open_unireg_entry(THD *thd,TABLE *entry,const char *db,
const char *name, const char *alias, bool locked);
static bool insert_fields(THD *thd,TABLE_LIST *tables, const char *table_name,
List_iterator<Item> *it);
static bool insert_fields(THD *thd,TABLE_LIST *tables, const char *db_name,
const char *table_name, List_iterator<Item> *it);
static void free_cache_entry(TABLE *entry);
static void mysql_rm_tmp_tables(void);
static key_map get_key_map_from_key_list(TABLE *table,
......@@ -1754,7 +1754,8 @@ int setup_fields(THD *thd, TABLE_LIST *tables, List<Item> &fields,
if (item->type() == Item::FIELD_ITEM &&
((Item_field*) item)->field_name[0] == '*')
{
if (insert_fields(thd,tables,((Item_field*) item)->table_name,&it))
if (insert_fields(thd,tables,((Item_field*) item)->db_name,
((Item_field*) item)->table_name,&it))
DBUG_RETURN(-1); /* purecov: inspected */
}
else
......@@ -1838,8 +1839,8 @@ static key_map get_key_map_from_key_list(TABLE *table,
****************************************************************************/
static bool
insert_fields(THD *thd,TABLE_LIST *tables, const char *table_name,
List_iterator<Item> *it)
insert_fields(THD *thd,TABLE_LIST *tables, const char *db_name,
const char *table_name, List_iterator<Item> *it)
{
uint found;
DBUG_ENTER("insert_fields");
......@@ -1851,7 +1852,9 @@ insert_fields(THD *thd,TABLE_LIST *tables, const char *table_name,
if (grant_option && !thd->master_access &&
check_grant_all_columns(thd,SELECT_ACL,table) )
DBUG_RETURN(-1);
if (!table_name || !strcmp(table_name,tables->name))
if (!table_name || (!strcmp(table_name,tables->name) &&
(!db_name || !tables->db ||
!strcmp(tables->db,db_name))))
{
Field **ptr=table->field,*field;
thd->used_tables|=table->map;
......
......@@ -1088,6 +1088,7 @@ bool delayed_insert::handle_inserts(void)
int error;
uint max_rows;
bool using_ignore=0;
delayed_row *row;
DBUG_ENTER("handle_inserts");
/* Allow client to insert new rows */
......@@ -1113,7 +1114,6 @@ bool delayed_insert::handle_inserts(void)
table->file->extra(HA_EXTRA_WRITE_CACHE);
pthread_mutex_lock(&mutex);
delayed_row *row;
while ((row=rows.get()))
{
stacked_inserts--;
......@@ -1138,9 +1138,7 @@ bool delayed_insert::handle_inserts(void)
if (write_record(table,&info))
{
info.error++; // Ignore errors
pthread_mutex_lock(&LOCK_delayed_status);
delayed_insert_errors++;
pthread_mutex_unlock(&LOCK_delayed_status);
thread_safe_increment(delayed_insert_errors,&LOCK_delayed_status);
row->log_query = 0;
}
if (using_ignore)
......@@ -1209,6 +1207,13 @@ bool delayed_insert::handle_inserts(void)
DBUG_RETURN(0);
err:
/* Remove all not used rows */
while ((row=rows.get()))
{
delete row;
thread_safe_increment(delayed_insert_errors,&LOCK_delayed_status);
stacked_inserts--;
}
thread_safe_increment(delayed_insert_errors, &LOCK_delayed_status);
pthread_mutex_lock(&mutex);
DBUG_RETURN(1);
......
......@@ -3554,9 +3554,12 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
param->recinfo=recinfo;
store_record(table,2); // Make empty default record
table->max_rows=(((table->db_type == DB_TYPE_HEAP) ?
min(tmp_table_size, max_heap_table_size) : tmp_table_size)/
table->reclength);
if (tmp_table_size == ~(ulong) 0) // No limit
table->max_rows= ~(ha_rows) 0;
else
table->max_rows=(((table->db_type == DB_TYPE_HEAP) ?
min(tmp_table_size, max_heap_table_size) :
tmp_table_size)/ table->reclength);
set_if_bigger(table->max_rows,1); // For dummy start options
keyinfo=param->keyinfo;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment