Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
34ddd9c5
Commit
34ddd9c5
authored
Jun 22, 2004
by
pem@mysql.comhem.se
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed BUG#3486: FOUND_ROWS() fails inside stored procedure [and prepared statement].
parent
ec09e5f6
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
59 additions
and
2 deletions
+59
-2
mysql-test/r/ps.result
mysql-test/r/ps.result
+18
-0
mysql-test/t/ps.test
mysql-test/t/ps.test
+16
-0
sql/item_create.cc
sql/item_create.cc
+1
-1
sql/item_func.cc
sql/item_func.cc
+9
-0
sql/item_func.h
sql/item_func.h
+10
-0
sql/sql_select.cc
sql/sql_select.cc
+5
-1
No files found.
mysql-test/r/ps.result
View file @
34ddd9c5
...
@@ -119,3 +119,21 @@ EXECUTE stmt1 USING @var;
...
@@ -119,3 +119,21 @@ EXECUTE stmt1 USING @var;
_utf8 'A' collate utf8_bin = ?
_utf8 'A' collate utf8_bin = ?
1
1
DEALLOCATE PREPARE stmt1;
DEALLOCATE PREPARE stmt1;
create table t1 (id int);
prepare stmt1 from "select FOUND_ROWS()";
select SQL_CALC_FOUND_ROWS * from t1;
id
execute stmt1;
FOUND_ROWS()
0
insert into t1 values (1);
select SQL_CALC_FOUND_ROWS * from t1;
id
1
execute stmt1;
FOUND_ROWS()
1
execute stmt1;
FOUND_ROWS()
0
deallocate prepare stmt1;
mysql-test/t/ps.test
View file @
34ddd9c5
...
@@ -124,3 +124,19 @@ PREPARE stmt1 FROM "select _utf8 'A' collate utf8_bin = ?";
...
@@ -124,3 +124,19 @@ PREPARE stmt1 FROM "select _utf8 'A' collate utf8_bin = ?";
set
@
var
=
'A'
;
set
@
var
=
'A'
;
EXECUTE
stmt1
USING
@
var
;
EXECUTE
stmt1
USING
@
var
;
DEALLOCATE
PREPARE
stmt1
;
DEALLOCATE
PREPARE
stmt1
;
#
# BUG#3486: FOUND_ROWS() fails inside stored procedure [and prepared statement]
#
create
table
t1
(
id
int
);
prepare
stmt1
from
"select FOUND_ROWS()"
;
select
SQL_CALC_FOUND_ROWS
*
from
t1
;
# Expect 0
execute
stmt1
;
insert
into
t1
values
(
1
);
select
SQL_CALC_FOUND_ROWS
*
from
t1
;
# Expect 1
execute
stmt1
;
# Expect 0
execute
stmt1
;
deallocate
prepare
stmt1
;
sql/item_create.cc
View file @
34ddd9c5
...
@@ -154,7 +154,7 @@ Item *create_func_found_rows(void)
...
@@ -154,7 +154,7 @@ Item *create_func_found_rows(void)
{
{
THD
*
thd
=
current_thd
;
THD
*
thd
=
current_thd
;
thd
->
lex
->
safe_to_cache_query
=
0
;
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
)
Item
*
create_func_from_days
(
Item
*
a
)
...
...
sql/item_func.cc
View file @
34ddd9c5
...
@@ -3234,3 +3234,12 @@ longlong Item_func_is_used_lock::val_int()
...
@@ -3234,3 +3234,12 @@ longlong Item_func_is_used_lock::val_int()
null_value
=
0
;
null_value
=
0
;
return
ull
->
thread_id
;
return
ull
->
thread_id
;
}
}
longlong
Item_func_found_rows
::
val_int
()
{
DBUG_ASSERT
(
fixed
==
1
);
THD
*
thd
=
current_thd
;
return
thd
->
found_rows
();
}
sql/item_func.h
View file @
34ddd9c5
...
@@ -1071,3 +1071,13 @@ enum Cast_target
...
@@ -1071,3 +1071,13 @@ enum Cast_target
ITEM_CAST_BINARY
,
ITEM_CAST_SIGNED_INT
,
ITEM_CAST_UNSIGNED_INT
,
ITEM_CAST_BINARY
,
ITEM_CAST_SIGNED_INT
,
ITEM_CAST_UNSIGNED_INT
,
ITEM_CAST_DATE
,
ITEM_CAST_TIME
,
ITEM_CAST_DATETIME
,
ITEM_CAST_CHAR
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
;
}
};
sql/sql_select.cc
View file @
34ddd9c5
...
@@ -1088,13 +1088,15 @@ JOIN::exec()
...
@@ -1088,13 +1088,15 @@ JOIN::exec()
DBUG_ENTER
(
"JOIN::exec"
);
DBUG_ENTER
(
"JOIN::exec"
);
error
=
0
;
error
=
0
;
thd
->
limit_found_rows
=
thd
->
examined_row_count
=
0
;
if
(
procedure
)
if
(
procedure
)
{
{
if
(
procedure
->
change_columns
(
fields_list
)
||
if
(
procedure
->
change_columns
(
fields_list
)
||
result
->
prepare
(
fields_list
,
unit
))
result
->
prepare
(
fields_list
,
unit
))
{
thd
->
limit_found_rows
=
thd
->
examined_row_count
=
0
;
DBUG_VOID_RETURN
;
DBUG_VOID_RETURN
;
}
}
}
if
(
!
tables_list
)
if
(
!
tables_list
)
{
// Only test of functions
{
// Only test of functions
...
@@ -1119,8 +1121,10 @@ JOIN::exec()
...
@@ -1119,8 +1121,10 @@ JOIN::exec()
else
else
error
=
(
int
)
result
->
send_eof
();
error
=
(
int
)
result
->
send_eof
();
}
}
thd
->
limit_found_rows
=
thd
->
examined_row_count
=
0
;
DBUG_VOID_RETURN
;
DBUG_VOID_RETURN
;
}
}
thd
->
limit_found_rows
=
thd
->
examined_row_count
=
0
;
if
(
zero_result_cause
)
if
(
zero_result_cause
)
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment