summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/item_create.cc2
-rw-r--r--sql/item_func.cc9
-rw-r--r--sql/item_func.h10
-rw-r--r--sql/sql_select.cc6
4 files changed, 25 insertions, 2 deletions
diff --git a/sql/item_create.cc b/sql/item_create.cc
index 4977ba2c5d3..4290a25e348 100644
--- a/sql/item_create.cc
+++ b/sql/item_create.cc
@@ -154,7 +154,7 @@ Item *create_func_found_rows(void)
{
THD *thd=current_thd;
thd->lex->safe_to_cache_query= 0;
- return new Item_int(NullS,(longlong) thd->found_rows(),21);
+ return new Item_func_found_rows();
}
Item *create_func_from_days(Item* a)
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 192ed118766..e3874d8e4fa 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -3234,3 +3234,12 @@ longlong Item_func_is_used_lock::val_int()
null_value=0;
return ull->thread_id;
}
+
+
+longlong Item_func_found_rows::val_int()
+{
+ DBUG_ASSERT(fixed == 1);
+ THD *thd= current_thd;
+
+ return thd->found_rows();
+}
diff --git a/sql/item_func.h b/sql/item_func.h
index 39c0a47ed7c..c05c1b01259 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -1071,3 +1071,13 @@ enum Cast_target
ITEM_CAST_BINARY, ITEM_CAST_SIGNED_INT, ITEM_CAST_UNSIGNED_INT,
ITEM_CAST_DATE, ITEM_CAST_TIME, ITEM_CAST_DATETIME, ITEM_CAST_CHAR
};
+
+
+class Item_func_found_rows :public Item_int_func
+{
+public:
+ Item_func_found_rows() :Item_int_func() {}
+ longlong val_int();
+ const char *func_name() const { return "found_rows"; }
+ void fix_length_and_dec() { decimals= 0; maybe_null=0; }
+};
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 09b0b66933a..f1f93343a63 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1088,12 +1088,14 @@ JOIN::exec()
DBUG_ENTER("JOIN::exec");
error= 0;
- thd->limit_found_rows= thd->examined_row_count= 0;
if (procedure)
{
if (procedure->change_columns(fields_list) ||
result->prepare(fields_list, unit))
+ {
+ thd->limit_found_rows= thd->examined_row_count= 0;
DBUG_VOID_RETURN;
+ }
}
if (!tables_list)
@@ -1119,8 +1121,10 @@ JOIN::exec()
else
error=(int) result->send_eof();
}
+ thd->limit_found_rows= thd->examined_row_count= 0;
DBUG_VOID_RETURN;
}
+ thd->limit_found_rows= thd->examined_row_count= 0;
if (zero_result_cause)
{