summaryrefslogtreecommitdiff
path: root/sql/item_func.cc
diff options
context:
space:
mode:
authorpem@mysql.com <>2003-09-24 11:29:38 +0200
committerpem@mysql.com <>2003-09-24 11:29:38 +0200
commit8d884c02bb2ca2f2b4bce6dccbaf69d6935e293d (patch)
tree4f2fa31d20ec4c9a54f602c624b20c1cf4ddf493 /sql/item_func.cc
parentefd94f5ba972bb10d2d10fe46fc9153536941e92 (diff)
parentb8e4dc03d809838f6f589ef24089e52ea806da33 (diff)
downloadmariadb-git-8d884c02bb2ca2f2b4bce6dccbaf69d6935e293d.tar.gz
Merging 4.1 -> 5.0
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r--sql/item_func.cc80
1 files changed, 77 insertions, 3 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 125f87aecec..164b895fb01 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -28,6 +28,9 @@
#include <time.h>
#include <ft_global.h>
+#include "sp_head.h"
+#include "sp_rcontext.h"
+#include "sp.h"
static void my_coll_agg_error(DTCollation &c1, DTCollation &c2,
const char *fname)
@@ -2324,7 +2327,7 @@ void Item_func_get_user_var::fix_length_and_dec()
if ((var_entry= get_variable(&thd->user_vars, name, 0)))
{
- if (opt_bin_log && is_update_query(thd->lex.sql_command) &&
+ if (opt_bin_log && is_update_query(thd->lex->sql_command) &&
var_entry->used_query_id != thd->query_id)
{
uint size;
@@ -2744,7 +2747,7 @@ Item *get_system_var(THD *thd, enum_var_type var_type, LEX_STRING name,
}
if (!(item=var->item(thd, var_type, component_name)))
return 0; // Impossible
- thd->lex.uncacheable();
+ thd->lex->uncacheable();
buff[0]='@';
buff[1]='@';
pos=buff+2;
@@ -2784,7 +2787,7 @@ Item *get_system_var(THD *thd, enum_var_type var_type, const char *var_name,
DBUG_ASSERT(var != 0);
if (!(item=var->item(thd, var_type, &null_lex_string)))
return 0; // Impossible
- thd->lex.uncacheable();
+ thd->lex->uncacheable();
item->set_name(item_name, 0, system_charset_info); // Will use original name
return item;
}
@@ -2845,3 +2848,74 @@ longlong Item_func_is_used_lock::val_int()
null_value=0;
return ull->thread_id;
}
+
+int
+Item_func_sp::execute(Item **itp)
+{
+ DBUG_ENTER("Item_func_sp::execute");
+ THD *thd= current_thd;
+
+ if (! m_sp)
+ m_sp= sp_find_function(thd, &m_name);
+ if (! m_sp)
+ DBUG_RETURN(-1);
+
+ DBUG_RETURN(m_sp->execute_function(thd, args, arg_count, itp));
+}
+
+enum enum_field_types
+Item_func_sp::field_type() const
+{
+ DBUG_ENTER("Item_func_sp::field_type");
+
+ if (! m_sp)
+ m_sp= sp_find_function(current_thd, const_cast<LEX_STRING*>(&m_name));
+ if (m_sp)
+ {
+ DBUG_PRINT("info", ("m_returns = %d", m_sp->m_returns));
+ DBUG_RETURN(m_sp->m_returns);
+ }
+ DBUG_RETURN(MYSQL_TYPE_STRING);
+}
+
+Item_result
+Item_func_sp::result_type() const
+{
+ DBUG_ENTER("Item_func_sp::result_type");
+ DBUG_PRINT("info", ("m_sp = %p", m_sp));
+
+ if (! m_sp)
+ m_sp= sp_find_function(current_thd, const_cast<LEX_STRING*>(&m_name));
+ if (m_sp)
+ {
+ DBUG_RETURN(m_sp->result());
+ }
+ DBUG_RETURN(STRING_RESULT);
+}
+
+void
+Item_func_sp::fix_length_and_dec()
+{
+ DBUG_ENTER("Item_func_sp::fix_length_and_dec");
+
+ if (! m_sp)
+ m_sp= sp_find_function(current_thd, &m_name);
+ if (m_sp)
+ {
+ switch (m_sp->result()) {
+ case STRING_RESULT:
+ maybe_null= 1;
+ max_length= 0;
+ break;
+ case REAL_RESULT:
+ decimals= NOT_FIXED_DEC;
+ max_length= float_length(decimals);
+ break;
+ case INT_RESULT:
+ decimals= 0;
+ max_length= 21;
+ break;
+ }
+ }
+ DBUG_VOID_RETURN;
+}