summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <monty@mishka.local>2005-06-21 18:18:58 +0300
committerunknown <monty@mishka.local>2005-06-21 18:18:58 +0300
commit280b1c33e3e1ddd7b4e3b295c9e30c766da6c494 (patch)
tree0a0a8e74a0ac586a06d40e05101d869295cbd90a /sql
parente17de6ecb472e84c7f826f6ac77c236ce952b9a8 (diff)
downloadmariadb-git-280b1c33e3e1ddd7b4e3b295c9e30c766da6c494.tar.gz
Cleanup during review of new code
Fixed wrong allocation that could cause buffer overrun when using join cache myisam/mi_open.c: Fixed indentation mysql-test/r/lowercase_table2.result: Drop tables and databases used in the test mysql-test/t/lowercase_table2.test: Drop tables and databases used in the test mysys/my_fopen.c: Cleanup of comments and parameter names Simple optimization Removed compiler warnings sql/field.cc: Fixed wrong allocation that could cause buffer overrun sql/mysqld.cc: Removed not needed code sql/set_var.cc: Simply code sql/sql_select.cc: Use int2store/int2korr to store length of cached VARCHAR fields (Not dependent on type and faster code as we avoid one possible call)
Diffstat (limited to 'sql')
-rw-r--r--sql/field.cc9
-rw-r--r--sql/mysqld.cc3
-rw-r--r--sql/set_var.cc2
-rw-r--r--sql/sql_select.cc18
4 files changed, 17 insertions, 15 deletions
diff --git a/sql/field.cc b/sql/field.cc
index 692f123097a..88816151c10 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -1053,6 +1053,7 @@ void Field_str::make_field(Send_field *field)
uint Field::fill_cache_field(CACHE_FIELD *copy)
{
+ uint store_length;
copy->str=ptr;
copy->length=pack_length();
copy->blob_field=0;
@@ -1065,10 +1066,16 @@ uint Field::fill_cache_field(CACHE_FIELD *copy)
}
else if (!zero_pack() && (type() == FIELD_TYPE_STRING && copy->length > 4 ||
type() == FIELD_TYPE_VAR_STRING))
+ {
copy->strip=1; /* Remove end space */
+ store_length= 2;
+ }
else
+ {
copy->strip=0;
- return copy->length+(int) copy->strip;
+ store_length= 0;
+ }
+ return copy->length+ store_length;
}
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index ec05ea2b8ce..99c96a69ceb 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -6098,9 +6098,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case (int) OPT_SLOW_QUERY_LOG:
opt_slow_log=1;
break;
- case (int) OPT_LOG_SLOW_ADMIN_STATEMENTS:
- opt_log_slow_admin_statements= 1;
- break;
case (int) OPT_SKIP_NEW:
opt_specialflag|= SPECIAL_NO_NEW_FUNC;
delay_key_write_options= (uint) DELAY_KEY_WRITE_NONE;
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 0f13a8a7f2d..b0fa61a12bc 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -1516,7 +1516,7 @@ bool sys_var::check_set(THD *thd, set_var *var, TYPELIB *enum_names)
{
if (!(res= var->value->val_str(&str)))
{
- strmake(buff, "NULL", 4);
+ strmov(buff, "NULL");
goto err;
}
var->save_result.ulong_value= ((ulong)
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 5bafe1a7df4..1031773eeed 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -28,8 +28,6 @@
#include <hash.h>
#include <ft_global.h>
-typedef uint32 cache_rec_length_type;
-
const char *join_type_str[]={ "UNKNOWN","system","const","eq_ref","ref",
"MAYBE_REF","ALL","range","index","fulltext",
"ref_or_null","unique_subquery","index_subquery"
@@ -8074,7 +8072,7 @@ used_blob_length(CACHE_FIELD **ptr)
static bool
store_record_in_cache(JOIN_CACHE *cache)
{
- cache_rec_length_type length;
+ uint length;
uchar *pos;
CACHE_FIELD *copy,*end_field;
bool last_record;
@@ -8119,9 +8117,9 @@ store_record_in_cache(JOIN_CACHE *cache)
end > str && end[-1] == ' ' ;
end--) ;
length=(uint) (end-str);
- memcpy(pos+sizeof(length), str, length);
- memcpy_fixed(pos, &length, sizeof(length));
- pos+= length+sizeof(length);
+ memcpy(pos+2, str, length);
+ int2store(pos, length);
+ pos+= length+2;
}
else
{
@@ -8155,7 +8153,7 @@ static void
read_cached_record(JOIN_TAB *tab)
{
uchar *pos;
- cache_rec_length_type length;
+ uint length;
bool last_record;
CACHE_FIELD *copy,*end_field;
@@ -8184,10 +8182,10 @@ read_cached_record(JOIN_TAB *tab)
{
if (copy->strip)
{
- memcpy_fixed(&length, pos, sizeof(length));
- memcpy(copy->str, pos+sizeof(length), length);
+ length= uint2korr(pos);
+ memcpy(copy->str, pos+2, length);
memset(copy->str+length, ' ', copy->length-length);
- pos+= sizeof(length)+length;
+ pos+= 2 + length;
}
else
{