Commit a06a5822 authored by baker/brian@zim.(none)'s avatar baker/brian@zim.(none)

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

into  zim.(none):/home/brian/mysql/remove-bdb-5.1
parents 5a466cc4 2e87907e
......@@ -118,6 +118,11 @@ public:
*/
virtual String *val_str(String*,String *)=0;
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 cmp_type () const { return result_type(); }
virtual Item_result cast_to_int_type () const { return result_type(); }
......@@ -412,6 +417,7 @@ public:
uint32 max_length() { return field_length; }
friend class create_field;
my_decimal *val_decimal(my_decimal *);
virtual bool str_needs_quotes() { return TRUE; }
uint is_equal(create_field *new_field);
};
......@@ -1379,6 +1385,7 @@ public:
double val_real(void);
longlong val_int(void);
String *val_str(String*, String *);
virtual bool str_needs_quotes() { return TRUE; }
my_decimal *val_decimal(my_decimal *);
int cmp(const char *a, const char *b)
{ return cmp_binary(a, b); }
......
......@@ -1142,7 +1142,7 @@ bool ha_federated::create_where_from_key(String *to,
Field *field= key_part->field;
uint store_length= key_part->store_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);
if (key_part->null_bit)
......@@ -1663,23 +1663,22 @@ int ha_federated::write_row(byte *buf)
{
commas_added= TRUE;
if ((*field)->is_null())
insert_field_value_string.append(STRING_WITH_LEN(" NULL "));
values_string.append(STRING_WITH_LEN(" NULL "));
else
{
bool needs_quote= (*field)->str_needs_quotes();
(*field)->val_str(&insert_field_value_string);
values_string.append('\'');
if (needs_quote)
values_string.append('\'');
insert_field_value_string.print(&values_string);
values_string.append('\'');
if (needs_quote)
values_string.append('\'');
insert_field_value_string.length(0);
}
/* append the 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 */
/*
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)
update_string.append(STRING_WITH_LEN(" NULL "));
else
{
my_bitmap_map *old_map= tmp_use_all_columns(table, table->read_set);
/* 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);
update_string.append('\'');
if (needs_quote)
update_string.append('\'');
field_value.print(&update_string);
update_string.append('\'');
if (needs_quote)
update_string.append('\'');
field_value.length(0);
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)
where_string.append(STRING_WITH_LEN(" IS NULL "));
else
{
bool needs_quote= (*field)->str_needs_quotes();
where_string.append(STRING_WITH_LEN(" = "));
(*field)->val_str(&field_value,
(char*) (old_data + (*field)->offset()));
where_string.append('\'');
if (needs_quote)
where_string.append('\'');
field_value.print(&where_string);
where_string.append('\'');
if (needs_quote)
where_string.append('\'');
field_value.length(0);
}
where_string.append(STRING_WITH_LEN(" AND "));
......@@ -1983,11 +1988,14 @@ int ha_federated::delete_row(const byte *buf)
}
else
{
delete_string.append(STRING_WITH_LEN(" = "));
cur_field->val_str(&data_string);
delete_string.append('\'');
data_string.print(&delete_string);
delete_string.append('\'');
bool needs_quote= cur_field->str_needs_quotes();
delete_string.append(STRING_WITH_LEN(" = "));
cur_field->val_str(&data_string);
if (needs_quote)
delete_string.append('\'');
data_string.print(&delete_string);
if (needs_quote)
delete_string.append('\'');
}
delete_string.append(STRING_WITH_LEN(" AND "));
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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