summaryrefslogtreecommitdiff
path: root/sql/sql_select.h
diff options
context:
space:
mode:
authorunknown <gkodinov/kgeorge@magare.gmz>2007-03-22 18:44:16 +0200
committerunknown <gkodinov/kgeorge@magare.gmz>2007-03-22 18:44:16 +0200
commit0a48cd93b4d26056e669b1a9bd5be791b3b79b94 (patch)
tree2157977430d766b13bee9e02927b505008b413b0 /sql/sql_select.h
parent3a520a785eeee973e79d1f6e482e270e24a20c56 (diff)
downloadmariadb-git-0a48cd93b4d26056e669b1a9bd5be791b3b79b94.tar.gz
Bug #26207: When making the key image to use
in index search MySQL was not explicitly suppressing warnings. And if the context happens to enable warnings (e.g. INSERT .. SELECT) the warnings resulting from converting the data the key is compared to are reported to the client. Fixed by suppressing warnings when converting the data to the same type as the key parts. mysql-test/r/insert_select.result: Bug #26207: test case mysql-test/t/insert_select.test: Bug #26207: test case sql/sql_select.h: Bug #26207: supress warnings when converting data of the same type to key buffer format.
Diffstat (limited to 'sql/sql_select.h')
-rw-r--r--sql/sql_select.h53
1 files changed, 41 insertions, 12 deletions
diff --git a/sql/sql_select.h b/sql/sql_select.h
index a17d7fcb362..e70e42da4ae 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -488,15 +488,11 @@ extern "C" int refpos_order_cmp(void* arg, const void *a,const void *b);
class store_key :public Sql_alloc
{
- protected:
- Field *to_field; // Store data here
- char *null_ptr;
- char err;
public:
bool null_key; /* TRUE <=> the value of the key has a null part */
enum store_key_result { STORE_KEY_OK, STORE_KEY_FATAL, STORE_KEY_CONV };
store_key(THD *thd, Field *field_arg, char *ptr, char *null, uint length)
- :null_ptr(null), err(0), null_key(0)
+ :null_key(0), null_ptr(null), err(0)
{
if (field_arg->type() == FIELD_TYPE_BLOB)
{
@@ -510,8 +506,35 @@ public:
ptr, (uchar*) null, 1);
}
virtual ~store_key() {} /* Not actually needed */
- virtual enum store_key_result copy()=0;
virtual const char *name() const=0;
+
+ /**
+ @brief sets ignore truncation warnings mode and calls the real copy method
+
+ @details this function makes sure truncation warnings when preparing the
+ key buffers don't end up as errors (because of an enclosing INSERT/UPDATE).
+ */
+ enum store_key_result copy()
+ {
+ enum store_key_result result;
+ enum_check_fields saved_count_cuted_fields=
+ to_field->table->in_use->count_cuted_fields;
+
+ to_field->table->in_use->count_cuted_fields= CHECK_FIELD_IGNORE;
+
+ result= copy_inner();
+
+ to_field->table->in_use->count_cuted_fields= saved_count_cuted_fields;
+
+ return result;
+ }
+
+ protected:
+ Field *to_field; // Store data here
+ char *null_ptr;
+ char err;
+
+ virtual enum store_key_result copy_inner()=0;
};
@@ -531,13 +554,15 @@ class store_key_field: public store_key
copy_field.set(to_field,from_field,0);
}
}
- enum store_key_result copy()
+ const char *name() const { return field_name; }
+
+ protected:
+ enum store_key_result copy_inner()
{
copy_field.do_copy(&copy_field);
null_key= to_field->is_null();
return err != 0 ? STORE_KEY_FATAL : STORE_KEY_OK;
}
- const char *name() const { return field_name; }
};
@@ -552,13 +577,15 @@ public:
null_ptr_arg ? null_ptr_arg : item_arg->maybe_null ?
&err : NullS, length), item(item_arg)
{}
- enum store_key_result copy()
+ const char *name() const { return "func"; }
+
+ protected:
+ enum store_key_result copy_inner()
{
int res= item->save_in_field(to_field, 1);
null_key= to_field->is_null() || item->null_value;
return (err != 0 || res > 2 ? STORE_KEY_FATAL : (store_key_result) res);
}
- const char *name() const { return "func"; }
};
@@ -574,7 +601,10 @@ public:
&err : NullS, length, item_arg), inited(0)
{
}
- enum store_key_result copy()
+ const char *name() const { return "const"; }
+
+protected:
+ enum store_key_result copy_inner()
{
int res;
if (!inited)
@@ -589,7 +619,6 @@ public:
null_key= to_field->is_null() || item->null_value;
return (err > 2 ? STORE_KEY_FATAL : (store_key_result) err);
}
- const char *name() const { return "const"; }
};
bool cp_buffer_from_ref(THD *thd, TABLE_REF *ref);