summaryrefslogtreecommitdiff
path: root/sql/item_func.h
diff options
context:
space:
mode:
authoracurtis@xiphis.org <>2005-04-20 18:08:42 +0100
committeracurtis@xiphis.org <>2005-04-20 18:08:42 +0100
commit8689083aca0c97457701551b776b1a9c9743c10d (patch)
tree07e3fe7c833631d8a9038ef91df990a4483c109a /sql/item_func.h
parent77a9429c134ddf6eaf3936286280e216b2be03af (diff)
downloadmariadb-git-8689083aca0c97457701551b776b1a9c9743c10d.tar.gz
Bug#9775 - Stored procedures: crash if create function that returns enum or set
Fix bug and implement return type casting.
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();