Commit 79072b50 authored by unknown's avatar unknown

Merge baker@bk-internal.mysql.com:/home/bk/mysql-5.1-new-maint

into  zim.(none):/home/brian/mysql/remove-bdb-5.1

parents bcc3b17f 3662bc59
...@@ -118,6 +118,11 @@ public: ...@@ -118,6 +118,11 @@ public:
*/ */
virtual String *val_str(String*,String *)=0; virtual String *val_str(String*,String *)=0;
String *val_int_as_str(String *val_buffer, my_bool unsigned_flag); String *val_int_as_str(String *val_buffer, my_bool unsigned_flag);
/*
str_needs_quotes() returns TRUE if the value returned by val_str() needs
to be quoted when used in constructing an SQL query.
*/
virtual bool str_needs_quotes() { return FALSE; }
virtual Item_result result_type () const=0; virtual Item_result result_type () const=0;
virtual Item_result cmp_type () const { return result_type(); } virtual Item_result cmp_type () const { return result_type(); }
virtual Item_result cast_to_int_type () const { return result_type(); } virtual Item_result cast_to_int_type () const { return result_type(); }
...@@ -412,6 +417,7 @@ public: ...@@ -412,6 +417,7 @@ public:
uint32 max_length() { return field_length; } uint32 max_length() { return field_length; }
friend class create_field; friend class create_field;
my_decimal *val_decimal(my_decimal *); my_decimal *val_decimal(my_decimal *);
virtual bool str_needs_quotes() { return TRUE; }
uint is_equal(create_field *new_field); uint is_equal(create_field *new_field);
}; };
...@@ -1379,6 +1385,7 @@ public: ...@@ -1379,6 +1385,7 @@ public:
double val_real(void); double val_real(void);
longlong val_int(void); longlong val_int(void);
String *val_str(String*, String *); String *val_str(String*, String *);
virtual bool str_needs_quotes() { return TRUE; }
my_decimal *val_decimal(my_decimal *); my_decimal *val_decimal(my_decimal *);
int cmp(const char *a, const char *b) int cmp(const char *a, const char *b)
{ return cmp_binary(a, b); } { return cmp_binary(a, b); }
......
...@@ -1142,7 +1142,7 @@ bool ha_federated::create_where_from_key(String *to, ...@@ -1142,7 +1142,7 @@ bool ha_federated::create_where_from_key(String *to,
Field *field= key_part->field; Field *field= key_part->field;
uint store_length= key_part->store_length; uint store_length= key_part->store_length;
uint part_length= min(store_length, length); uint part_length= min(store_length, length);
needs_quotes= 1; needs_quotes= field->str_needs_quotes();
DBUG_DUMP("key, start of loop", (char *) ptr, length); DBUG_DUMP("key, start of loop", (char *) ptr, length);
if (key_part->null_bit) if (key_part->null_bit)
...@@ -1663,23 +1663,22 @@ int ha_federated::write_row(byte *buf) ...@@ -1663,23 +1663,22 @@ int ha_federated::write_row(byte *buf)
{ {
commas_added= TRUE; commas_added= TRUE;
if ((*field)->is_null()) if ((*field)->is_null())
insert_field_value_string.append(STRING_WITH_LEN(" NULL ")); values_string.append(STRING_WITH_LEN(" NULL "));
else else
{ {
bool needs_quote= (*field)->str_needs_quotes();
(*field)->val_str(&insert_field_value_string); (*field)->val_str(&insert_field_value_string);
values_string.append('\''); if (needs_quote)
values_string.append('\'');
insert_field_value_string.print(&values_string); insert_field_value_string.print(&values_string);
values_string.append('\''); if (needs_quote)
values_string.append('\'');
insert_field_value_string.length(0); insert_field_value_string.length(0);
} }
/* append the field name */ /* append the field name */
insert_string.append((*field)->field_name); insert_string.append((*field)->field_name);
/* append the value */
values_string.append(insert_field_value_string);
insert_field_value_string.length(0);
/* append commas between both fields and fieldnames */ /* append commas between both fields and fieldnames */
/* /*
unfortunately, we can't use the logic if *(fields + 1) to unfortunately, we can't use the logic if *(fields + 1) to
...@@ -1884,12 +1883,15 @@ int ha_federated::update_row(const byte *old_data, byte *new_data) ...@@ -1884,12 +1883,15 @@ int ha_federated::update_row(const byte *old_data, byte *new_data)
update_string.append(STRING_WITH_LEN(" NULL ")); update_string.append(STRING_WITH_LEN(" NULL "));
else else
{ {
my_bitmap_map *old_map= tmp_use_all_columns(table, table->read_set);
/* otherwise = */ /* otherwise = */
my_bitmap_map *old_map= tmp_use_all_columns(table, table->read_set);
bool needs_quote= (*field)->str_needs_quotes();
(*field)->val_str(&field_value); (*field)->val_str(&field_value);
update_string.append('\''); if (needs_quote)
update_string.append('\'');
field_value.print(&update_string); field_value.print(&update_string);
update_string.append('\''); if (needs_quote)
update_string.append('\'');
field_value.length(0); field_value.length(0);
tmp_restore_column_map(table->read_set, old_map); tmp_restore_column_map(table->read_set, old_map);
} }
...@@ -1903,12 +1905,15 @@ int ha_federated::update_row(const byte *old_data, byte *new_data) ...@@ -1903,12 +1905,15 @@ int ha_federated::update_row(const byte *old_data, byte *new_data)
where_string.append(STRING_WITH_LEN(" IS NULL ")); where_string.append(STRING_WITH_LEN(" IS NULL "));
else else
{ {
bool needs_quote= (*field)->str_needs_quotes();
where_string.append(STRING_WITH_LEN(" = ")); where_string.append(STRING_WITH_LEN(" = "));
(*field)->val_str(&field_value, (*field)->val_str(&field_value,
(char*) (old_data + (*field)->offset())); (char*) (old_data + (*field)->offset()));
where_string.append('\''); if (needs_quote)
where_string.append('\'');
field_value.print(&where_string); field_value.print(&where_string);
where_string.append('\''); if (needs_quote)
where_string.append('\'');
field_value.length(0); field_value.length(0);
} }
where_string.append(STRING_WITH_LEN(" AND ")); where_string.append(STRING_WITH_LEN(" AND "));
...@@ -1983,11 +1988,14 @@ int ha_federated::delete_row(const byte *buf) ...@@ -1983,11 +1988,14 @@ int ha_federated::delete_row(const byte *buf)
} }
else else
{ {
delete_string.append(STRING_WITH_LEN(" = ")); bool needs_quote= cur_field->str_needs_quotes();
cur_field->val_str(&data_string); delete_string.append(STRING_WITH_LEN(" = "));
delete_string.append('\''); cur_field->val_str(&data_string);
data_string.print(&delete_string); if (needs_quote)
delete_string.append('\''); delete_string.append('\'');
data_string.print(&delete_string);
if (needs_quote)
delete_string.append('\'');
} }
delete_string.append(STRING_WITH_LEN(" AND ")); delete_string.append(STRING_WITH_LEN(" AND "));
} }
......
This diff is collapsed.
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