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
cb00984a
Commit
cb00984a
authored
Jan 27, 2003
by
venu@myvenu.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge myvenu.com:/home/venu/bk/src-4.1
into myvenu.com:/home/venu/work/sql/dev-4.1
parents
1c4c824b
ca62e9f6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
33 deletions
+49
-33
libmysql/libmysql.c
libmysql/libmysql.c
+9
-7
tests/client_test.c
tests/client_test.c
+40
-26
No files found.
libmysql/libmysql.c
View file @
cb00984a
...
...
@@ -5289,7 +5289,7 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt)
*/
static
my_bool
stmt_close
(
MYSQL_STMT
*
stmt
,
my_bool
skip_list
)
{
my_bool
error
=
0
;
my_bool
error
=
0
;
DBUG_ENTER
(
"mysql_stmt_close"
);
DBUG_ASSERT
(
stmt
!=
0
);
...
...
@@ -5299,12 +5299,14 @@ static my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list)
int4store
(
buff
,
stmt
->
stmt_id
);
error
=
simple_command
(
stmt
->
mysql
,
COM_CLOSE_STMT
,
buff
,
4
,
1
);
}
mysql_free_result
(
stmt
->
result
);
free_root
(
&
stmt
->
mem_root
,
MYF
(
0
));
my_free
((
gptr
)
stmt
->
query
,
MYF
(
MY_WME
|
MY_ALLOW_ZERO_PTR
));
if
(
!
skip_list
)
stmt
->
mysql
->
stmts
=
list_delete
(
stmt
->
mysql
->
stmts
,
&
stmt
->
list
);
my_free
((
gptr
)
stmt
,
MYF
(
MY_WME
));
if
(
!
error
)
{
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
);
my_free
((
gptr
)
stmt
,
MYF
(
MY_WME
));
}
DBUG_RETURN
(
error
);
}
...
...
tests/client_test.c
View file @
cb00984a
...
...
@@ -161,6 +161,7 @@ static void client_connect()
char
buff
[
255
];
myheader_r
(
"client_connect"
);
fprintf
(
stdout
,
"
\n
Establishig a connection ..."
);
if
(
!
(
mysql
=
mysql_init
(
NULL
)))
{
myerror
(
"mysql_init() failed"
);
...
...
@@ -174,15 +175,19 @@ static void client_connect()
mysql_close
(
mysql
);
exit
(
0
);
}
fprintf
(
stdout
,
" OK"
);
/* set AUTOCOMMIT to ON*/
mysql_autocommit
(
mysql
,
TRUE
);
fprintf
(
stdout
,
"
\n
Creating a test database '%s' ..."
,
current_db
);
sprintf
(
buff
,
"CREATE DATABASE IF NOT EXISTS %s"
,
current_db
);
rc
=
mysql_query
(
mysql
,
buff
);
myquery
(
rc
);
sprintf
(
buff
,
"USE %s"
,
current_db
);
rc
=
mysql_query
(
mysql
,
buff
);
myquery
(
rc
);
fprintf
(
stdout
,
" OK"
);
}
/********************************************************
...
...
@@ -195,11 +200,13 @@ static void client_disconnect()
if
(
mysql
)
{
char
buff
[
255
];
fprintf
(
stdout
,
"
\n
droping the test database '%s'"
,
current_db
);
fprintf
(
stdout
,
"
\n
droping the test database '%s'
...
"
,
current_db
);
sprintf
(
buff
,
"DROP DATABASE IF EXISTS %s"
,
current_db
);
mysql_query
(
mysql
,
buff
);
fprintf
(
stdout
,
"
\n
closing the connection
\n
"
);
fprintf
(
stdout
,
" OK"
);
fprintf
(
stdout
,
"
\n
closing the connection ..."
);
mysql_close
(
mysql
);
fprintf
(
stdout
,
" OK
\n
"
);
}
}
...
...
@@ -3548,63 +3555,68 @@ static void test_stmt_close()
myheader
(
"test_stmt_close"
);
fprintf
(
stdout
,
"
\n
Establishing a test connection ..."
);
if
(
!
(
lmysql
=
mysql_init
(
NULL
)))
{
myerror
(
"mysql_init() failed"
);
exit
(
0
);
}
if
(
!
(
mysql_real_connect
(
lmysql
,
opt_host
,
opt_user
,
opt_password
,
opt_db
?
opt_db
:
"inter_client_test_db"
,
opt_port
,
opt_password
,
current_db
,
opt_port
,
opt_unix_socket
,
0
)))
{
myerror
(
"connection failed"
);
exit
(
0
);
}
if
(
opt_db
)
strmov
(
current_db
,
opt_db
);
fprintf
(
stdout
,
" OK"
);
/* set AUTOCOMMIT to ON*/
mysql_autocommit
(
lmysql
,
TRUE
);
mysql_query
(
lmysql
,
"DROP TABLE IF EXISTS test_stmt_close"
);
mysql_query
(
lmysql
,
"CREATE TABLE test_stmt_close(id int)"
);
rc
=
mysql_query
(
lmysql
,
"DROP TABLE IF EXISTS test_stmt_close"
);
myquery
(
rc
);
rc
=
mysql_query
(
lmysql
,
"CREATE TABLE test_stmt_close(id int)"
);
myquery
(
rc
);
strmov
(
query
,
"ALTER TABLE test_stmt_close ADD name varchar(20)"
);
stmt1
=
PREPARE
(
lmysql
,
query
);
mystmt_init
(
stmt1
);
count
=
mysql_param_count
(
stmt1
);
fprintf
(
stdout
,
"
\n
total params in alter: %d"
,
count
);
myassert
(
count
==
0
);
verify_param_count
(
stmt1
,
0
);
strmov
(
query
,
"INSERT INTO test_stmt_close(id) VALUES(?)"
);
stmt_x
=
PREPARE
(
mysql
,
query
);
mystmt_init
(
stmt_x
);
count
=
mysql_param_count
(
stmt_x
);
fprintf
(
stdout
,
"
\n
total params in insert: %d"
,
count
);
myassert
(
count
==
1
);
verify_param_count
(
stmt_x
,
1
);
strmov
(
query
,
"UPDATE test_stmt_close SET id=? WHERE id=?"
);
stmt3
=
PREPARE
(
lmysql
,
query
);
mystmt_init
(
stmt3
);
count
=
mysql_param_count
(
stmt3
);
fprintf
(
stdout
,
"
\n
total params in update: %d"
,
count
);
myassert
(
count
==
2
);
verify_param_count
(
stmt3
,
2
);
strmov
(
query
,
"SELECT * FROM test_stmt_close WHERE id=?"
);
stmt2
=
PREPARE
(
lmysql
,
query
);
mystmt_init
(
stmt2
);
count
=
mysql_param_count
(
stmt2
);
fprintf
(
stdout
,
"
\n
total params in select: %d"
,
count
);
myassert
(
count
==
1
);
verify_param_count
(
stmt2
,
1
);
rc
=
mysql_stmt_close
(
stmt1
);
fprintf
(
stdout
,
"
\n
mysql_close_stmt(1) returned: %d"
,
rc
);
myassert
(
rc
==
0
);
mysql_close
(
lmysql
);
/* it should free all stmts */
#if NOT_VALID
mysql_close
(
lmysql
);
/* it should free all open stmts(stmt3, stmt2) */
rc
=
mysql_stmt_close
(
stmt3
);
fprintf
(
stdout
,
"
\n
mysql_close_stmt(3) returned: %d"
,
rc
);
myassert
(
rc
==
1
);
rc
=
mysql_stmt_close
(
stmt2
);
fprintf
(
stdout
,
"
\n
mysql_close_stmt(2) returned: %d"
,
rc
);
myassert
(
rc
==
1
);
#endif
count
=
100
;
bind
[
0
].
buffer
=
(
char
*
)
&
count
;
...
...
@@ -3616,7 +3628,7 @@ static void test_stmt_close()
rc
=
mysql_execute
(
stmt_x
);
mystmt
(
stmt_x
,
rc
);
rc
=
(
ulong
)
mysql_
affected_rows
(
stmt_x
->
mysql
);
rc
=
(
ulong
)
mysql_
stmt_affected_rows
(
stmt_x
);
fprintf
(
stdout
,
"
\n
total rows affected: %d"
,
rc
);
myassert
(
rc
==
1
);
...
...
@@ -3624,7 +3636,6 @@ static void test_stmt_close()
fprintf
(
stdout
,
"
\n
mysql_close_stmt(x) returned: %d"
,
rc
);
myassert
(
rc
==
0
);
/*verify_col_data("test_stmt_close", "id", "100");*/
rc
=
mysql_query
(
mysql
,
"SELECT id FROM test_stmt_close"
);
myquery
(
rc
);
...
...
@@ -5291,7 +5302,7 @@ int main(int argc, char **argv)
test_warnings
();
/* show warnings test */
test_errors
();
/* show errors test */
test_prepare_resultset
();
/* prepare meta info test */
/*test_stmt_close(); */
/* mysql_stmt_close() test -- hangs */
test_stmt_close
();
/* mysql_stmt_close() test -- hangs */
test_prepare_field_result
();
/* prepare meta info */
test_multi_stmt
();
/* multi stmt test -TODO*/
test_multi_query
();
/* test multi query execution */
...
...
@@ -5312,7 +5323,10 @@ int main(int argc, char **argv)
}
client_disconnect
();
/* disconnect from server */
fprintf
(
stdout
,
"
\n\n
SUCCESS !!!
\n
"
);
fprintf
(
stdout
,
"
\n\n
All '%d' tests were successful (in '%d' iterations)"
,
test_count
-
1
,
opt_count
);
fprintf
(
stdout
,
"
\n
SUCCESS !!!
\n
"
);
return
(
0
);
}
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