diff options
author | unknown <jimw@rama.(none)> | 2006-07-25 16:12:48 -0700 |
---|---|---|
committer | unknown <jimw@rama.(none)> | 2006-07-25 16:12:48 -0700 |
commit | 919c5596d4b006742d0f7f4e54f9c36bca418ae0 (patch) | |
tree | 2ee821524da6a0ed1c332768a180a75d80d5cdff /sql/ha_federated.cc | |
parent | 39486004bbf13987b5962056bf0bf0ed4bf7b86d (diff) | |
download | mariadb-git-919c5596d4b006742d0f7f4e54f9c36bca418ae0.tar.gz |
Bug #21284: Add Field::needs_quote() method and use it in Federated
The fix for bug 17608 removed the behavior of only adding quotes to values
that needed it when constructing the queries sent by the federated storage
engine. This restores that behavior, but using a new virtual Field method.
(The old one had a hardcoded list of field types.)
No test included. The behavior can be verified by inspecting the query log
on the slave in the federated test.
sql/field.h:
Add str_needs_quotes() method to indicate whether the results of val_str()
requires quoting when used in constructing an SQL query.
sql/ha_federated.cc:
Restore behavior of only quoting values that need it, using the new
Field::str_needs_quotes() method.
Diffstat (limited to 'sql/ha_federated.cc')
-rw-r--r-- | sql/ha_federated.cc | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/sql/ha_federated.cc b/sql/ha_federated.cc index 2267c2b5d79..b444bc105f7 100644 --- a/sql/ha_federated.cc +++ b/sql/ha_federated.cc @@ -1136,7 +1136,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) @@ -1588,10 +1588,13 @@ int ha_federated::write_row(byte *buf) insert_field_value_string.append(FEDERATED_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); } @@ -1804,11 +1807,14 @@ int ha_federated::update_row(const byte *old_data, byte *new_data) update_string.append(FEDERATED_NULL); else { + bool needs_quote= (*field)->str_needs_quotes(); /* otherwise = */ (*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); } @@ -1816,12 +1822,15 @@ int ha_federated::update_row(const byte *old_data, byte *new_data) where_string.append(FEDERATED_ISNULL); else { + bool needs_quote= (*field)->str_needs_quotes(); where_string.append(FEDERATED_EQ); (*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); } @@ -1895,11 +1904,14 @@ int ha_federated::delete_row(const byte *buf) } else { + bool needs_quote= cur_field->str_needs_quotes(); delete_string.append(FEDERATED_EQ); cur_field->val_str(&data_string); - delete_string.append('\''); + if (needs_quote) + delete_string.append('\''); data_string.print(&delete_string); - delete_string.append('\''); + if (needs_quote) + delete_string.append('\''); } delete_string.append(FEDERATED_AND); |