summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authoringo@mysql.com <>2005-01-24 10:47:52 +0100
committeringo@mysql.com <>2005-01-24 10:47:52 +0100
commit47c400914900a4771732362fb0b6dd05aac626f0 (patch)
tree3bfa0bc61665651aef2c0a0b16b2129556f99eb2 /sql
parent8555668067b152509ee8365767f10984b3ab03dc (diff)
parenta551510cfd20c6be84d29575917fc39a27250e47 (diff)
downloadmariadb-git-47c400914900a4771732362fb0b6dd05aac626f0.tar.gz
Merge mysql.com:/home/mydev/mysql-4.1
into mysql.com:/home/mydev/mysql-4.1-4100
Diffstat (limited to 'sql')
-rw-r--r--sql/mysql_priv.h1
-rw-r--r--sql/mysqld.cc13
-rw-r--r--sql/set_var.cc4
-rw-r--r--sql/sql_parse.cc14
-rw-r--r--sql/sql_select.cc13
-rw-r--r--sql/sql_show.cc5
6 files changed, 23 insertions, 27 deletions
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 4b785aafc5f..4f4aea66dd7 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -938,7 +938,6 @@ extern SHOW_COMP_OPTION have_ndbcluster;
extern struct system_variables global_system_variables;
extern struct system_variables max_system_variables;
extern struct rand_struct sql_rand;
-extern KEY_CACHE *sql_key_cache;
extern const char *opt_date_time_formats[];
extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[];
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index d1fef3519bf..21b1cb7ffd0 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -383,7 +383,6 @@ struct system_variables max_system_variables;
MY_TMPDIR mysql_tmpdir_list;
MY_BITMAP temp_pool;
-KEY_CACHE *sql_key_cache;
CHARSET_INFO *system_charset_info, *files_charset_info ;
CHARSET_INFO *national_charset_info, *table_alias_charset;
@@ -1846,14 +1845,14 @@ We will try our best to scrape up some info that will hopefully help diagnose\n\
the problem, but since we have already crashed, something is definitely wrong\n\
and this may fail.\n\n");
fprintf(stderr, "key_buffer_size=%lu\n",
- (ulong) sql_key_cache->key_cache_mem_size);
+ (ulong) dflt_key_cache->key_cache_mem_size);
fprintf(stderr, "read_buffer_size=%ld\n", global_system_variables.read_buff_size);
fprintf(stderr, "max_used_connections=%ld\n", max_used_connections);
fprintf(stderr, "max_connections=%ld\n", max_connections);
fprintf(stderr, "threads_connected=%d\n", thread_count);
fprintf(stderr, "It is possible that mysqld could use up to \n\
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = %ld K\n\
-bytes of memory\n", ((ulong) sql_key_cache->key_cache_mem_size +
+bytes of memory\n", ((ulong) dflt_key_cache->key_cache_mem_size +
(global_system_variables.read_buff_size +
global_system_variables.sortbuff_size) *
max_connections)/ 1024);
@@ -2120,12 +2119,12 @@ extern "C" void *signal_hand(void *arg __attribute__((unused)))
case SIGHUP:
if (!abort_loop)
{
+ mysql_print_status((THD*) 0); // Print some debug info
reload_acl_and_cache((THD*) 0,
(REFRESH_LOG | REFRESH_TABLES | REFRESH_FAST |
REFRESH_STATUS | REFRESH_GRANT |
REFRESH_THREADS | REFRESH_HOSTS),
(TABLE_LIST*) 0, NULL); // Flush logs
- mysql_print_status((THD*) 0); // Send debug some info
}
break;
#ifdef USE_ONE_SIGNAL_HAND
@@ -2699,8 +2698,6 @@ server.");
/* call ha_init_key_cache() on all key caches to init them */
process_key_caches(&ha_init_key_cache);
- /* We must set dflt_key_cache in case we are using ISAM tables */
- dflt_key_cache= sql_key_cache;
#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT) && !defined(EMBEDDED_LIBRARY)
if (locked_in_memory && !getuid())
@@ -5598,10 +5595,10 @@ static void mysql_init_variables(void)
threads.empty();
thread_cache.empty();
key_caches.empty();
- multi_keycache_init();
- if (!(sql_key_cache= get_or_create_key_cache(default_key_cache_base.str,
+ if (!(dflt_key_cache= get_or_create_key_cache(default_key_cache_base.str,
default_key_cache_base.length)))
exit(1);
+ multi_keycache_init(); /* set key_cache_hash.default_value = dflt_key_cache */
/* Initialize structures that is used when processing options */
replicate_rewrite_db.empty();
diff --git a/sql/set_var.cc b/sql/set_var.cc
index e44ac742abe..1237c31075c 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -2174,7 +2174,7 @@ bool sys_var_key_buffer_size::update(THD *thd, set_var *var)
if (!tmp) // Zero size means delete
{
- if (key_cache == sql_key_cache)
+ if (key_cache == dflt_key_cache)
goto end; // Ignore default key cache
if (key_cache->key_cache_inited) // If initied
@@ -2188,7 +2188,7 @@ bool sys_var_key_buffer_size::update(THD *thd, set_var *var)
base_name->length, &list);
key_cache->in_init= 1;
pthread_mutex_unlock(&LOCK_global_system_variables);
- error= reassign_keycache_tables(thd, key_cache, sql_key_cache);
+ error= reassign_keycache_tables(thd, key_cache, dflt_key_cache);
pthread_mutex_lock(&LOCK_global_system_variables);
key_cache->in_init= 0;
}
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index c81aefc9cea..9eb4019b5d7 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -4946,6 +4946,7 @@ void kill_one_thread(THD *thd, ulong id)
net_printf(thd,error,id);
}
+
/* Clear most status variables */
static void refresh_status(void)
@@ -4955,18 +4956,9 @@ static void refresh_status(void)
{
if (ptr->type == SHOW_LONG)
*(ulong*) ptr->value= 0;
- else if (ptr->type == SHOW_KEY_CACHE_LONG)
- {
- /*
- Reset value in 'default' key cache.
- This needs to be recoded when we have thread specific key values
- */
- char *value= (((char*) sql_key_cache) +
- (uint) ((char*) (ptr->value) -
- (char*) &dflt_key_cache_var));
- *(ulong*) value= 0;
- }
}
+ /* Reset the counters of all key caches (default and named). */
+ process_key_caches(reset_key_cache_counters);
pthread_mutex_unlock(&LOCK_status);
}
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 7e48374a8e6..5cb6a0a65df 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -2844,9 +2844,15 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count,
x = used key parts (1 <= x <= c)
*/
double rec_per_key;
+#if 0
if (!(rec_per_key=(double)
keyinfo->rec_per_key[keyinfo->key_parts-1]))
rec_per_key=(double) s->records/rec+1;
+#else
+ rec_per_key= keyinfo->rec_per_key[keyinfo->key_parts-1] ?
+ (double) keyinfo->rec_per_key[keyinfo->key_parts-1] :
+ (double) s->records/rec+1;
+#endif
if (!s->records)
tmp=0;
@@ -7496,13 +7502,14 @@ remove_duplicates(JOIN *join, TABLE *entry,List<Item> &fields, Item *having)
field_count++;
}
- if (!field_count)
- { // only const items
+ if (!field_count && !(join->select_options & OPTION_FOUND_ROWS))
+ { // only const items with no OPTION_FOUND_ROWS
join->unit->select_limit_cnt= 1; // Only send first row
DBUG_RETURN(0);
}
Field **first_field=entry->field+entry->fields - field_count;
- offset=entry->field[entry->fields - field_count]->offset();
+ offset= field_count ?
+ entry->field[entry->fields - field_count]->offset() : 0;
reclength=entry->reclength-offset;
free_io_cache(entry); // Safety
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 8929872c466..8d741b4dc67 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -1025,7 +1025,8 @@ mysqld_show_keys(THD *thd, TABLE_LIST *table_list)
/* Check if we have a key part that only uses part of the field */
if (!(key_info->flags & HA_FULLTEXT) && (!key_part->field ||
key_part->length != table->field[key_part->fieldnr-1]->key_length()))
- protocol->store_tiny((longlong) key_part->length);
+ protocol->store_tiny((longlong) key_part->length /
+ key_part->field->charset()->mbmaxlen);
else
protocol->store_null();
protocol->store_null(); // No pack_information yet
@@ -2066,7 +2067,7 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables,
#endif /* HAVE_OPENSSL */
case SHOW_KEY_CACHE_LONG:
case SHOW_KEY_CACHE_CONST_LONG:
- value= (value-(char*) &dflt_key_cache_var)+ (char*) sql_key_cache;
+ value= (value-(char*) &dflt_key_cache_var)+ (char*) dflt_key_cache;
end= int10_to_str(*(long*) value, buff, 10);
break;
case SHOW_UNDEF: // Show never happen