summaryrefslogtreecommitdiff
path: root/sql/item_func.h
diff options
context:
space:
mode:
authorunknown <acurtis@xiphis.org>2005-04-20 18:08:42 +0100
committerunknown <acurtis@xiphis.org>2005-04-20 18:08:42 +0100
commitde8a3b31218f66948ecfc4ce4fee85a0285ae161 (patch)
tree07e3fe7c833631d8a9038ef91df990a4483c109a /sql/item_func.h
parentf054047f022096efaeeec46381ddf86d59eed517 (diff)
downloadmariadb-git-de8a3b31218f66948ecfc4ce4fee85a0285ae161.tar.gz
Bug#9775 - Stored procedures: crash if create function that returns enum or set
Fix bug and implement return type casting. mysql-test/r/sp.result: Bug#9775 Test for bug + feature Fix previous tests mysql-test/t/sp.test: Bug#9775 Test for bug + feature Fix previous tests sql/item_func.cc: Bug#9775 new method Item_func_sp::execute(Field **) some optimizations. sql/item_func.h: Bug#9775 results for Item_func_sp pass through a Field of the return type. new method Item_func_sp::execute(Field **) sql/sp_head.cc: Bug#9775 missing initialiation for type_lengths in sp_head::create_typelib()
Diffstat (limited to 'sql/item_func.h')
-rw-r--r--sql/item_func.h58
1 files changed, 17 insertions, 41 deletions
diff --git a/sql/item_func.h b/sql/item_func.h
index b39786e5544..ba5a6101e4c 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -1283,8 +1283,11 @@ private:
sp_name *m_name;
mutable sp_head *m_sp;
TABLE *dummy_table;
+ Field *result_field;
+ char result_buf[64];
int execute(Item **itp);
+ int execute(Field **flp);
Field *sp_result_field(void) const;
public:
@@ -1296,6 +1299,12 @@ public:
virtual ~Item_func_sp()
{}
+ void cleanup()
+ {
+ Item_func::cleanup();
+ result_field= NULL;
+ }
+
const char *func_name() const;
enum enum_field_types field_type() const;
@@ -1308,63 +1317,30 @@ public:
longlong val_int()
{
- Item *it;
- longlong l;
-
- if (execute(&it))
- {
- null_value= 1;
+ if (execute(&result_field))
return 0LL;
- }
- l= it->val_int();
- null_value= it->null_value;
- return l;
+ return result_field->val_int();
}
double val_real()
{
- Item *it;
- double d;
-
- if (execute(&it))
- {
- null_value= 1;
+ if (execute(&result_field))
return 0.0;
- }
- d= it->val_real();
- null_value= it->null_value;
- return d;
+ return result_field->val_real();
}
my_decimal *val_decimal(my_decimal *dec_buf)
{
- Item *it;
- my_decimal *result;
-
- if (execute(&it))
- {
- null_value= 1;
+ if (execute(&result_field))
return NULL;
- }
- result= it->val_decimal(dec_buf);
- null_value= it->null_value;
- return result;
+ return result_field->val_decimal(dec_buf);
}
-
String *val_str(String *str)
{
- Item *it;
- String *s;
-
- if (execute(&it))
- {
- null_value= 1;
+ if (execute(&result_field))
return NULL;
- }
- s= it->val_str(str);
- null_value= it->null_value;
- return s;
+ return result_field->val_str(str);
}
void fix_length_and_dec();