From 919c5596d4b006742d0f7f4e54f9c36bca418ae0 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 25 Jul 2006 16:12:48 -0700 Subject: 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. --- sql/field.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'sql/field.h') diff --git a/sql/field.h b/sql/field.h index 09638b9a979..cb061f6f859 100644 --- a/sql/field.h +++ b/sql/field.h @@ -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(); } @@ -386,6 +391,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; } }; @@ -1330,6 +1336,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); } -- cgit v1.2.1