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
0aaab85f
Commit
0aaab85f
authored
Jan 31, 2003
by
venu@myvenu.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Force to read all unread packets on stmt_close
parent
5c1d2a56
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 @
0aaab85f
...
...
@@ -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
)
{
MYSQL
*
mysql
;
my_bool
error
=
0
;
DBUG_ENTER
(
"mysql_stmt_close"
);
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
)
{
char
buff
[
4
];
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
);
}
...
...
tests/client_test.c
View file @
0aaab85f
...
...
@@ -5332,6 +5332,44 @@ static void test_open_direct()
myassert
(
2
==
my_process_result_set
(
result
));
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()
while
(
mysql_fetch
(
stmt
)
!=
MYSQL_NO_DATA
)
{
rc
++
;
fprintf
(
stdout
,
"
\n
CURRENT_DATABASE(): %s
(%ld)
"
,
str
[
0
]);
fprintf
(
stdout
,
"
\n
CURRENT_USER() : %s
(%ld)
"
,
str
[
1
]);
fprintf
(
stdout
,
"
\n
CURRENT_DATE() : %s
(%ld)
"
,
str
[
2
]);
fprintf
(
stdout
,
"
\n
CURRENT_TIME() : %s
(%ld)
"
,
str
[
3
]);
fprintf
(
stdout
,
"
\n
CURRENT_DATABASE(): %s"
,
str
[
0
]);
fprintf
(
stdout
,
"
\n
CURRENT_USER() : %s"
,
str
[
1
]);
fprintf
(
stdout
,
"
\n
CURRENT_DATE() : %s"
,
str
[
2
]);
fprintf
(
stdout
,
"
\n
CURRENT_TIME() : %s"
,
str
[
3
]);
}
fprintf
(
stdout
,
"
\n
total rows: %d"
,
rc
);
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