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 | |
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')
-rw-r--r-- | sql/protocol_cursor.cc | 3 | ||||
-rw-r--r-- | sql/sp_rcontext.cc | 27 |
2 files changed, 17 insertions, 13 deletions
diff --git a/sql/protocol_cursor.cc b/sql/protocol_cursor.cc index 31eaa894045..8904aba7b88 100644 --- a/sql/protocol_cursor.cc +++ b/sql/protocol_cursor.cc @@ -112,7 +112,8 @@ bool Protocol_cursor::write() for (; cur_field < fields_end; ++cur_field, ++data_tmp) { - if ((len= net_field_length((uchar **)&cp)) == 0) + if ((len= net_field_length((uchar **)&cp)) == 0 || + len == NULL_LENGTH) { *data_tmp= 0; } 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()) |