summaryrefslogtreecommitdiffstats
path: root/sql/item.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/item.cc')
-rw-r--r--sql/item.cc34
1 files changed, 28 insertions, 6 deletions
diff --git a/sql/item.cc b/sql/item.cc
index c6d51e47..6f9eb9d1 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -2674,7 +2674,11 @@ bool Type_std_attributes::agg_item_set_converter(const DTCollation &coll,
if (conv->fix_fields_if_needed(thd, arg))
return TRUE;
- if (!thd->stmt_arena->is_conventional())
+ if (!thd->stmt_arena->is_conventional() &&
+ ((!thd->lex->current_select &&
+ (thd->stmt_arena->is_stmt_prepare_or_first_sp_execute() ||
+ thd->stmt_arena->is_stmt_prepare_or_first_stmt_execute())) ||
+ thd->lex->current_select->first_cond_optimization))
{
Query_arena *arena, backup;
arena= thd->activate_stmt_arena_if_needed(&backup);
@@ -2798,11 +2802,11 @@ Item_sp::func_name_cstring(THD *thd, bool is_package_function) const
quoted `pkg` and `func` separately, so the entire result looks like:
`db`.`pkg`.`func`
*/
- Database_qualified_name tmp= Database_qualified_name::split(m_name->m_name);
- DBUG_ASSERT(tmp.m_db.length);
- append_identifier(thd, &qname, &tmp.m_db);
+ Identifier_chain2 tmp= Identifier_chain2::split(m_name->m_name);
+ DBUG_ASSERT(tmp[0].length);
+ append_identifier(thd, &qname, &tmp[0]);
qname.append('.');
- append_identifier(thd, &qname, &tmp.m_name);
+ append_identifier(thd, &qname, &tmp[1]);
}
else
append_identifier(thd, &qname, &m_name->m_name);
@@ -7040,7 +7044,25 @@ Item *Item_float::neg(THD *thd)
else if (value < 0 && max_length)
max_length--;
value= -value;
- presentation= 0;
+ if (presentation)
+ {
+ if (*presentation == '-')
+ {
+ // Strip double minus: -(-1) -> '1' instead of '--1'
+ presentation++;
+ }
+ else
+ {
+ size_t presentation_length= strlen(presentation);
+ if (char *tmp= (char*) thd->alloc(presentation_length + 2))
+ {
+ tmp[0]= '-';
+ // Copy with the trailing '\0'
+ memcpy(tmp + 1, presentation, presentation_length + 1);
+ presentation= tmp;
+ }
+ }
+ }
name= null_clex_str;
return this;
}