summaryrefslogtreecommitdiff
path: root/sql/item.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/item.cc')
-rw-r--r--sql/item.cc65
1 files changed, 64 insertions, 1 deletions
diff --git a/sql/item.cc b/sql/item.cc
index 5e74820a3f8..6eb2adb9392 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -533,7 +533,9 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
cause error ER_NON_UNIQ_ERROR in find_field_in_tables.
*/
SELECT_LEX *last= 0;
-
+#ifdef EMBEDDED_LIBRARY
+ thd->net.last_errno= 0;
+#endif
Item **refer= (Item **)not_found_item;
// Prevent using outer fields in subselects, that is not supported now
SELECT_LEX *cursel=(SELECT_LEX *) thd->lex.current_select;
@@ -918,11 +920,72 @@ bool Item::send(THD *thd, String *packet)
return net_store_data(packet,res->ptr(),res->length());
}
+
bool Item_null::send(THD *thd, String *packet)
{
return net_store_null(packet);
}
+#ifdef EMBEDDED_LIBRARY
+bool Item::embedded_send(const CONVERT *convert, CHARSET_INFO *charset, MEM_ROOT *alloc,
+ char **result, ulong *length)
+{
+ char buff[MAX_FIELD_WIDTH];
+ String s(buff, sizeof(buff), charset), *value;
+ if (!(value=val_str(&s)) ||
+ !(*result=alloc_root(alloc, value->length() + 1)))
+ {
+ *result= NULL;
+ *length= 0;
+ return false;
+ }
+ if (!(*result=alloc_root(alloc, value->length() + 1)))
+ return true;
+ *length= value->length();
+ if (convert)
+ convert->convert_back(*result, value->ptr(), *length);
+ else
+ memcpy(*result, value->ptr(), *length);
+ (*result)[*length]= 0;
+ return false;
+}
+
+bool Item_null::embedded_send(const CONVERT *convert, CHARSET_INFO *charset, MEM_ROOT *alloc,
+ char **result, ulong *length)
+{
+ *result= NULL;
+ *length= 0;
+ return false;
+}
+
+bool Item_field::embedded_send(const CONVERT *convert, CHARSET_INFO *charset, MEM_ROOT *alloc,
+ char **result, ulong *length)
+{
+ if (result_field->is_null())
+ {
+ *result= NULL;
+ *length= 0;
+ return false;
+ }
+
+ char buff[MAX_FIELD_WIDTH];
+ String tmp(buff,sizeof(buff),default_charset_info);
+ result_field->val_str(&tmp,&tmp);
+
+ if (!(*result=alloc_root(alloc, tmp.length() + 1)))
+ return true;
+ *length= tmp.length();
+ if (convert)
+ convert->convert_back(*result, tmp.ptr(), *length);
+ else
+ memcpy(*result, tmp.ptr(), *length);
+ (*result)[*length]= 0;
+ return false;
+}
+
+#endif
+
+
/*
This is used for HAVING clause
Find field in select list having the same name