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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
b58dd39b
Commit
b58dd39b
authored
Jan 31, 2003
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Force to read all unread packets on stmt_close
tests/client_test.c: tests for un cleared packets
parent
28f3c41f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
11 deletions
+69
-11
libmysql/libmysql.c
libmysql/libmysql.c
+27
-7
tests/client_test.c
tests/client_test.c
+42
-4
No files found.
libmysql/libmysql.c
View file @
b58dd39b
...
@@ -5340,22 +5340,42 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt)
...
@@ -5340,22 +5340,42 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt)
*/
*/
static
my_bool
stmt_close
(
MYSQL_STMT
*
stmt
,
my_bool
skip_list
)
static
my_bool
stmt_close
(
MYSQL_STMT
*
stmt
,
my_bool
skip_list
)
{
{
MYSQL
*
mysql
;
my_bool
error
=
0
;
my_bool
error
=
0
;
DBUG_ENTER
(
"mysql_stmt_close"
);
DBUG_ENTER
(
"mysql_stmt_close"
);
DBUG_ASSERT
(
stmt
!=
0
);
DBUG_ASSERT
(
stmt
!=
0
);
mysql
=
stmt
->
mysql
;
if
(
mysql
->
status
!=
MYSQL_STATUS_READY
)
{
/* Clear the current execution status */
DBUG_PRINT
(
"warning"
,(
"Not all packets read, clearing them"
));
for
(;;)
{
ulong
pkt_len
;
if
((
pkt_len
=
net_safe_read
(
mysql
))
==
packet_error
)
break
;
if
(
pkt_len
<=
8
&&
mysql
->
net
.
read_pos
[
0
]
==
254
)
break
;
}
mysql
->
status
=
MYSQL_STATUS_READY
;
}
if
(
stmt
->
state
==
MY_ST_PREPARE
||
stmt
->
state
==
MY_ST_EXECUTE
)
if
(
stmt
->
state
==
MY_ST_PREPARE
||
stmt
->
state
==
MY_ST_EXECUTE
)
{
{
char
buff
[
4
];
char
buff
[
4
];
int4store
(
buff
,
stmt
->
stmt_id
);
int4store
(
buff
,
stmt
->
stmt_id
);
error
=
simple_command
(
stmt
->
mysql
,
COM_CLOSE_STMT
,
buff
,
4
,
1
);
error
=
simple_command
(
mysql
,
COM_CLOSE_STMT
,
buff
,
4
,
1
);
}
if
(
!
error
)
{
mysql_free_result
(
stmt
->
result
);
free_root
(
&
stmt
->
mem_root
,
MYF
(
0
));
if
(
!
skip_list
)
mysql
->
stmts
=
list_delete
(
mysql
->
stmts
,
&
stmt
->
list
);
mysql
->
status
=
MYSQL_STATUS_READY
;
my_free
((
gptr
)
stmt
,
MYF
(
MY_WME
));
}
}
mysql_free_result
(
stmt
->
result
);
free_root
(
&
stmt
->
mem_root
,
MYF
(
0
));
if
(
!
skip_list
)
stmt
->
mysql
->
stmts
=
list_delete
(
stmt
->
mysql
->
stmts
,
&
stmt
->
list
);
stmt
->
mysql
->
status
=
MYSQL_STATUS_READY
;
my_free
((
gptr
)
stmt
,
MYF
(
MY_WME
));
DBUG_RETURN
(
error
);
DBUG_RETURN
(
error
);
}
}
...
...
tests/client_test.c
View file @
b58dd39b
...
@@ -5332,6 +5332,44 @@ static void test_open_direct()
...
@@ -5332,6 +5332,44 @@ static void test_open_direct()
myassert
(
2
==
my_process_result_set
(
result
));
myassert
(
2
==
my_process_result_set
(
result
));
mysql_stmt_close
(
stmt
);
mysql_stmt_close
(
stmt
);
/* run a direct query in the middle of a fetch */
stmt
=
mysql_prepare
(
mysql
,
"SELECT * FROM test_open_direct"
,
100
);
mystmt_init
(
stmt
);
rc
=
mysql_execute
(
stmt
);
mystmt
(
stmt
,
rc
);
rc
=
mysql_fetch
(
stmt
);
mystmt
(
stmt
,
rc
);
rc
=
mysql_query
(
mysql
,
"INSERT INTO test_open_direct(id) VALUES(20)"
);
myquery_r
(
rc
);
rc
=
mysql_stmt_close
(
stmt
);
mystmt
(
stmt
,
rc
);
rc
=
mysql_query
(
mysql
,
"INSERT INTO test_open_direct(id) VALUES(20)"
);
myquery
(
rc
);
/* run a direct query with store result */
stmt
=
mysql_prepare
(
mysql
,
"SELECT * FROM test_open_direct"
,
100
);
mystmt_init
(
stmt
);
rc
=
mysql_execute
(
stmt
);
mystmt
(
stmt
,
rc
);
rc
=
mysql_stmt_store_result
(
stmt
);
mystmt
(
stmt
,
rc
);
rc
=
mysql_fetch
(
stmt
);
mystmt
(
stmt
,
rc
);
rc
=
mysql_query
(
mysql
,
"drop table test_open_direct"
);
myquery
(
rc
);
rc
=
mysql_stmt_close
(
stmt
);
mystmt
(
stmt
,
rc
);
}
}
/*
/*
...
@@ -5378,10 +5416,10 @@ static void test_fetch_nobuffs()
...
@@ -5378,10 +5416,10 @@ static void test_fetch_nobuffs()
while
(
mysql_fetch
(
stmt
)
!=
MYSQL_NO_DATA
)
while
(
mysql_fetch
(
stmt
)
!=
MYSQL_NO_DATA
)
{
{
rc
++
;
rc
++
;
fprintf
(
stdout
,
"
\n
CURRENT_DATABASE(): %s
(%ld)
"
,
str
[
0
]);
fprintf
(
stdout
,
"
\n
CURRENT_DATABASE(): %s"
,
str
[
0
]);
fprintf
(
stdout
,
"
\n
CURRENT_USER() : %s
(%ld)
"
,
str
[
1
]);
fprintf
(
stdout
,
"
\n
CURRENT_USER() : %s"
,
str
[
1
]);
fprintf
(
stdout
,
"
\n
CURRENT_DATE() : %s
(%ld)
"
,
str
[
2
]);
fprintf
(
stdout
,
"
\n
CURRENT_DATE() : %s"
,
str
[
2
]);
fprintf
(
stdout
,
"
\n
CURRENT_TIME() : %s
(%ld)
"
,
str
[
3
]);
fprintf
(
stdout
,
"
\n
CURRENT_TIME() : %s"
,
str
[
3
]);
}
}
fprintf
(
stdout
,
"
\n
total rows: %d"
,
rc
);
fprintf
(
stdout
,
"
\n
total rows: %d"
,
rc
);
myassert
(
rc
==
1
);
myassert
(
rc
==
1
);
...
...
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