diff options
author | unknown <pem@mysql.comhem.se> | 2004-09-10 16:28:11 +0200 |
---|---|---|
committer | unknown <pem@mysql.comhem.se> | 2004-09-10 16:28:11 +0200 |
commit | 749c03840ade0fe36d78069d54e0f43b60149acb (patch) | |
tree | ff8b7de4aa2beb41f5797fa160bf00b13fd14840 /sql/sp_rcontext.cc | |
parent | fc8da24a712a661c08da8c644f906abffbe538ff (diff) | |
download | mariadb-git-749c03840ade0fe36d78069d54e0f43b60149acb.tar.gz |
Fixed BUG#4941: Stored procedure crash fetching null value into variable.
mysql-test/r/sp.result:
New test case for BUG#4941.
mysql-test/t/sp.test:
New test case for BUG#4941.
sql/protocol_cursor.cc:
Handle null values.
sql/sp_rcontext.cc:
Handle null values.
Diffstat (limited to 'sql/sp_rcontext.cc')
-rw-r--r-- | sql/sp_rcontext.cc | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc index 1bdd022470b..2f7bdbffa2b 100644 --- a/sql/sp_rcontext.cc +++ b/sql/sp_rcontext.cc @@ -230,21 +230,24 @@ sp_cursor::fetch(THD *thd, List<struct sp_pvar> *vars) return -1; } s= row[fldcount]; - switch (sp_map_result_type(pv->type)) - { - case INT_RESULT: - it= new Item_int(s); - break; - case REAL_RESULT: - it= new Item_real(s, strlen(s)); - break; - default: + if (!s) + it= new Item_null(); + else + switch (sp_map_result_type(pv->type)) { - uint len= strlen(s); - it= new Item_string(thd->strmake(s, len), len, thd->db_charset); + case INT_RESULT: + it= new Item_int(s); break; + case REAL_RESULT: + it= new Item_real(s, strlen(s)); + break; + default: + { + uint len= strlen(s); + it= new Item_string(thd->strmake(s, len), len, thd->db_charset); + break; + } } - } thd->spcont->set_item(pv->offset, it); } if (fldcount < m_prot->get_field_count()) |