From 218e00ac681c300ddfb59889d8b6dd7faa0e71f6 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Sat, 19 Feb 2005 18:58:27 +0200 Subject: Fixed BUILD script to use --with-berkeley-db instead of --with-bdb Lots of small fixes to multi-precision-math path Give Note for '123.4e' Added helper functions type 'val_string_from_real() Don't give warnings for end space for string2decimal() Changed storage of values for SP so that we can detect length of argument without strlen() Changed interface for str2dec() so that we must supple the pointer to the last character in the buffer --- sql/sp_rcontext.cc | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'sql/sp_rcontext.cc') diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc index 0c6c8c5aa70..5b177650726 100644 --- a/sql/sp_rcontext.cc +++ b/sql/sp_rcontext.cc @@ -243,27 +243,36 @@ sp_cursor::fetch(THD *thd, List *vars) if (!s) it= new Item_null(); else - switch (sp_map_result_type(pv->type)) - { + { + /* + Length of data can be calculated as: + pointer_to_next_not_null_object - s -1 + where the last -1 is to remove the end \0 + */ + uint len; + MYSQL_ROW next= row+fldcount+1; + while (!*next) // Skip nulls + next++; + len= (*next -s)-1; + switch (sp_map_result_type(pv->type)) { case INT_RESULT: it= new Item_int(s); break; case REAL_RESULT: - it= new Item_float(s, strlen(s)); + it= new Item_float(s, len); break; case DECIMAL_RESULT: - it= new Item_decimal(s, strlen(s), thd->db_charset); + it= new Item_decimal(s, len, thd->db_charset); break; case STRING_RESULT: - { - uint len= strlen(s); - it= new Item_string(thd->strmake(s, len), len, thd->db_charset); - break; - } + /* TODO: Document why we do an extra copy of the string 's' here */ + it= new Item_string(thd->strmake(s, len), len, thd->db_charset); + break; case ROW_RESULT: default: DBUG_ASSERT(0); } + } thd->spcont->set_item(pv->offset, it); } if (fldcount < m_prot->get_field_count()) -- cgit v1.2.1