summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2005-06-29 12:44:40 +0300
committerunknown <monty@mysql.com>2005-06-29 12:44:40 +0300
commit1aa6343fe8d9a1d61aa7fcd4246fb5858b3dfa16 (patch)
tree1c72d027318d11b4953c9f65caa108e33b6abf86 /sql
parentfeffe571eb0044817cee8d53019081a9f1025662 (diff)
downloadmariadb-git-1aa6343fe8d9a1d61aa7fcd4246fb5858b3dfa16.tar.gz
Simple optimization
nsure that delete works not only on table->record[0] for federated tables sql/field.cc: Test OOM condition sql/ha_federated.cc: Simple optimizations Ensure that delete works not only on table->record[0] sql/opt_range.cc: Simplify code
Diffstat (limited to 'sql')
-rw-r--r--sql/field.cc7
-rw-r--r--sql/ha_federated.cc24
-rw-r--r--sql/opt_range.cc12
3 files changed, 21 insertions, 22 deletions
diff --git a/sql/field.cc b/sql/field.cc
index fb244de4275..2cfd162899c 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -6822,7 +6822,12 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs)
&not_used)))
{
uint conv_errors;
- tmpstr.copy(from, length, cs, field_charset, &conv_errors);
+ if (tmpstr.copy(from, length, cs, field_charset, &conv_errors))
+ {
+ /* Fatal OOM error */
+ bzero(ptr,Field_blob::pack_length());
+ return -1;
+ }
from= tmpstr.ptr();
length= tmpstr.length();
if (conv_errors)
diff --git a/sql/ha_federated.cc b/sql/ha_federated.cc
index 77db17608bc..6754a1a8707 100644
--- a/sql/ha_federated.cc
+++ b/sql/ha_federated.cc
@@ -1399,27 +1399,25 @@ int ha_federated::update_row(const byte *old_data, byte *new_data)
int ha_federated::delete_row(const byte *buf)
{
- uint x= 0;
char delete_buffer[IO_SIZE];
char data_buffer[IO_SIZE];
-
String delete_string(delete_buffer, sizeof(delete_buffer), &my_charset_bin);
- delete_string.length(0);
String data_string(data_buffer, sizeof(data_buffer), &my_charset_bin);
- data_string.length(0);
-
DBUG_ENTER("ha_federated::delete_row");
+ delete_string.length(0);
delete_string.append("DELETE FROM `");
delete_string.append(share->table_base_name);
delete_string.append("`");
delete_string.append(" WHERE ");
- for (Field **field= table->field; *field; field++, x++)
+ for (Field **field= table->field; *field; field++)
{
- delete_string.append((*field)->field_name);
+ Field *cur_field= *field;
+ data_string.length(0);
+ delete_string.append(cur_field->field_name);
- if ((*field)->is_null())
+ if (cur_field->is_null_in_record((const uchar*) buf))
{
delete_string.append(" IS ");
data_string.append("NULL");
@@ -1427,17 +1425,15 @@ int ha_federated::delete_row(const byte *buf)
else
{
delete_string.append("=");
- (*field)->val_str(&data_string);
- (*field)->quote_data(&data_string);
+ cur_field->val_str(&data_string, (char*) buf+ cur_field->offset());
+ cur_field->quote_data(&data_string);
}
delete_string.append(data_string);
- data_string.length(0);
-
- if (x + 1 < table->s->fields)
- delete_string.append(" AND ");
+ delete_string.append(" AND ");
}
+ delete_string.length(delete_string.length()-5); // Remove AND
delete_string.append(" LIMIT 1");
DBUG_PRINT("info",
("Delete sql: %s", delete_string.c_ptr_quick()));
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 4c0c895f22a..05028c4e2a5 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -8556,23 +8556,21 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_max_in_range()
if ((result == HA_ERR_KEY_NOT_FOUND) && (cur_range->flag & EQ_RANGE))
continue; /* Check the next range. */
- else if (result)
+ if (result)
+ {
/*
In no key was found with this upper bound, there certainly are no keys
in the ranges to the left.
*/
return result;
-
+ }
/* A key was found. */
if (cur_range->flag & EQ_RANGE)
- return result; /* No need to perform the checks below for equal keys. */
+ return 0; /* No need to perform the checks below for equal keys. */
/* Check if record belongs to the current group. */
if (key_cmp(index_info->key_part, group_prefix, real_prefix_len))
- {
- result = HA_ERR_KEY_NOT_FOUND;
- continue;
- }
+ continue; // Row not found
/* If there is a lower limit, check if the found key is in the range. */
if ( !(cur_range->flag & NO_MIN_RANGE) )