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
aae00014
Commit
aae00014
authored
Dec 17, 2008
by
Sergey Glukhov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug#24289 Status Variable "Questions" gets wrong values with Stored Routines(for 5.1)
parent
d566770b
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
174 additions
and
12 deletions
+174
-12
mysql-test/r/myisampack.result
mysql-test/r/myisampack.result
+1
-1
mysql-test/r/status2.result
mysql-test/r/status2.result
+73
-0
mysql-test/t/myisampack.test
mysql-test/t/myisampack.test
+1
-1
mysql-test/t/status2.test
mysql-test/t/status2.test
+68
-0
sql/mysqld.cc
sql/mysqld.cc
+1
-7
sql/sql_class.h
sql/sql_class.h
+9
-2
sql/sql_parse.cc
sql/sql_parse.cc
+21
-1
No files found.
mysql-test/r/myisampack.result
View file @
aae00014
...
...
@@ -28,7 +28,7 @@ Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1;
drop table if exists t1;
create table t1(f1 int, f2
var
char(255));
create table t1(f1 int, f2 char(255));
insert into t1 values(1, 'foo'), (2, 'bar');
insert into t1 select * from t1;
insert into t1 select * from t1;
...
...
mysql-test/r/status2.result
0 → 100644
View file @
aae00014
#
# Bug#24289 Status Variable "Questions" gets wrong values with Stored Routines
#
FLUSH STATUS;
CREATE FUNCTION testQuestion() RETURNS INTEGER
BEGIN
DECLARE foo INTEGER;
DECLARE bar INTEGER;
SET foo=1;
SET bar=2;
RETURN foo;
END $$
CREATE PROCEDURE testQuestion2()
BEGIN
SELECT 1;
END $$
DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 (c1 INT);
CREATE TABLE t2 (c1 INT);
CREATE EVENT ev1 ON SCHEDULE EVERY 1 SECOND
DO INSERT INTO t1 VALUES(1);
Assert Questions == 7
SHOW STATUS LIKE 'Questions';
Variable_name Value
Questions 7
SELECT testQuestion();
testQuestion()
1
Assert Questions == 9
SHOW STATUS LIKE 'Questions';
Variable_name Value
Questions 9
CALL testQuestion2();
1
1
Assert Questions == 11
SHOW STATUS LIKE 'Questions';
Variable_name Value
Questions 11
SELECT 1;
1
1
Assert Questions == 13
SHOW STATUS LIKE 'Questions';
Variable_name Value
Questions 13
SELECT 1;
1
1
Assert Questions == 14
SHOW STATUS LIKE 'Questions';
Variable_name Value
Questions 14
CREATE TRIGGER trigg1 AFTER INSERT ON t1
FOR EACH ROW BEGIN
INSERT INTO t2 VALUES (1);
END;
$$
Assert Questions == 16
SHOW STATUS LIKE 'Questions';
Variable_name Value
Questions 16
INSERT INTO t1 VALUES (1);
Assert Questions == 18
SHOW STATUS LIKE 'Questions';
Variable_name Value
Questions 18
DROP PROCEDURE testQuestion2;
DROP TRIGGER trigg1;
DROP FUNCTION testQuestion;
DROP EVENT ev1;
DROP TABLE t1,t2;
End of 6.0 tests
mysql-test/t/myisampack.test
View file @
aae00014
...
...
@@ -38,7 +38,7 @@ DROP TABLE t1;
--
disable_warnings
drop
table
if
exists
t1
;
--
enable_warnings
create
table
t1
(
f1
int
,
f2
var
char
(
255
));
create
table
t1
(
f1
int
,
f2
char
(
255
));
insert
into
t1
values
(
1
,
'foo'
),
(
2
,
'bar'
);
insert
into
t1
select
*
from
t1
;
insert
into
t1
select
*
from
t1
;
...
...
mysql-test/t/status2.test
0 → 100644
View file @
aae00014
--
source
include
/
not_embedded
.
inc
--
echo
#
--
echo
# Bug#24289 Status Variable "Questions" gets wrong values with Stored Routines
--
echo
#
FLUSH
STATUS
;
DELIMITER
$$
;
CREATE
FUNCTION
testQuestion
()
RETURNS
INTEGER
BEGIN
DECLARE
foo
INTEGER
;
DECLARE
bar
INTEGER
;
SET
foo
=
1
;
SET
bar
=
2
;
RETURN
foo
;
END
$$
CREATE
PROCEDURE
testQuestion2
()
BEGIN
SELECT
1
;
END
$$
DELIMITER
;
$$
--
disable_warnings
DROP
TABLE
IF
EXISTS
t1
,
t2
;
--
enable_warnings
CREATE
TABLE
t1
(
c1
INT
);
CREATE
TABLE
t2
(
c1
INT
);
CREATE
EVENT
ev1
ON
SCHEDULE
EVERY
1
SECOND
DO
INSERT
INTO
t1
VALUES
(
1
);
--
echo
Assert
Questions
==
7
SHOW
STATUS
LIKE
'Questions'
;
SELECT
testQuestion
();
--
echo
Assert
Questions
==
9
SHOW
STATUS
LIKE
'Questions'
;
CALL
testQuestion2
();
--
echo
Assert
Questions
==
11
SHOW
STATUS
LIKE
'Questions'
;
SELECT
1
;
--
echo
Assert
Questions
==
13
SHOW
STATUS
LIKE
'Questions'
;
connect
(
con1
,
localhost
,
root
,,);
connection
con1
;
SELECT
1
;
connection
default
;
disconnect
con1
;
--
echo
Assert
Questions
==
14
SHOW
STATUS
LIKE
'Questions'
;
DELIMITER
$$
;
CREATE
TRIGGER
trigg1
AFTER
INSERT
ON
t1
FOR
EACH
ROW
BEGIN
INSERT
INTO
t2
VALUES
(
1
);
END
;
$$
DELIMITER
;
$$
--
echo
Assert
Questions
==
16
SHOW
STATUS
LIKE
'Questions'
;
INSERT
INTO
t1
VALUES
(
1
);
--
echo
Assert
Questions
==
18
SHOW
STATUS
LIKE
'Questions'
;
# TODO: Uncomment the lines below when FLUSH GLOBAL STATUS is implemented.
# FLUSH STATUS;
# SHOW GLOBAL STATUS LIKE 'Questions';
DROP
PROCEDURE
testQuestion2
;
DROP
TRIGGER
trigg1
;
DROP
FUNCTION
testQuestion
;
DROP
EVENT
ev1
;
DROP
TABLE
t1
,
t2
;
--
echo
End
of
6.0
tests
sql/mysqld.cc
View file @
aae00014
...
...
@@ -6867,12 +6867,6 @@ The minimum value for this variable is 4096.",
{
0
,
0
,
0
,
0
,
0
,
0
,
GET_NO_ARG
,
NO_ARG
,
0
,
0
,
0
,
0
,
0
,
0
}
};
static
int
show_question
(
THD
*
thd
,
SHOW_VAR
*
var
,
char
*
buff
)
{
var
->
type
=
SHOW_LONGLONG
;
var
->
value
=
(
char
*
)
&
thd
->
query_id
;
return
0
;
}
static
int
show_net_compression
(
THD
*
thd
,
SHOW_VAR
*
var
,
char
*
buff
)
{
...
...
@@ -7289,7 +7283,7 @@ SHOW_VAR status_vars[]= {
{
"Qcache_queries_in_cache"
,
(
char
*
)
&
query_cache
.
queries_in_cache
,
SHOW_LONG_NOFLUSH
},
{
"Qcache_total_blocks"
,
(
char
*
)
&
query_cache
.
total_blocks
,
SHOW_LONG_NOFLUSH
},
#endif
/*HAVE_QUERY_CACHE*/
{
"Questions"
,
(
char
*
)
&
show_question
,
SHOW_FUNC
},
{
"Questions"
,
(
char
*
)
offsetof
(
STATUS_VAR
,
questions
),
SHOW_LONG_STATUS
},
#ifdef HAVE_REPLICATION
{
"Rpl_status"
,
(
char
*
)
&
show_rpl_status
,
SHOW_FUNC
},
#endif
...
...
sql/sql_class.h
View file @
aae00014
...
...
@@ -456,8 +456,15 @@ typedef struct system_status_var
ulong
com_stmt_fetch
;
ulong
com_stmt_reset
;
ulong
com_stmt_close
;
/*
Number of statements sent from the client
*/
ulong
questions
;
/*
IMPORTANT!
SEE last_system_status_var DEFINITION BELOW.
Below 'last_system_status_var' are all variables which doesn't make any
sense to add to the /global/ status variable counter.
Status variables which it does not make sense to add to
global status variable counter
*/
...
...
@@ -470,7 +477,7 @@ typedef struct system_status_var
counter
*/
#define last_system_status_var
com_stmt_close
#define last_system_status_var
questions
void
mark_transaction_to_rollback
(
THD
*
thd
,
bool
all
);
...
...
sql/sql_parse.cc
View file @
aae00014
...
...
@@ -971,8 +971,24 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
thd
->
set_time
();
VOID
(
pthread_mutex_lock
(
&
LOCK_thread_count
));
thd
->
query_id
=
global_query_id
;
if
(
command
!=
COM_STATISTICS
&&
command
!=
COM_PING
)
switch
(
command
)
{
/* Ignore these statements. */
case
COM_STATISTICS
:
case
COM_PING
:
break
;
/* Only increase id on these statements but don't count them. */
case
COM_STMT_PREPARE
:
case
COM_STMT_CLOSE
:
case
COM_STMT_RESET
:
next_query_id
();
break
;
/* Increase id and count all other statements. */
default:
statistic_increment
(
thd
->
status_var
.
questions
,
&
LOCK_status
);
next_query_id
();
}
thread_running
++
;
/* TODO: set thd->lex->sql_command to SQLCOM_END here */
VOID
(
pthread_mutex_unlock
(
&
LOCK_thread_count
));
...
...
@@ -1229,6 +1245,10 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
VOID
(
pthread_mutex_lock
(
&
LOCK_thread_count
));
thd
->
query_length
=
length
;
thd
->
query
=
beginning_of_next_stmt
;
/*
Count each statement from the client.
*/
statistic_increment
(
thd
->
status_var
.
questions
,
&
LOCK_status
);
thd
->
query_id
=
next_query_id
();
thd
->
set_time
();
/* Reset the query start time. */
/* TODO: set thd->lex->sql_command to SQLCOM_END here */
...
...
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