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
8470c364
Commit
8470c364
authored
Jun 13, 2002
by
venu@myvenu.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
client_test.c:
Forgot to include the portable changes from previous commit
parent
143fb1fc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
119 additions
and
158 deletions
+119
-158
tests/client_test.c
tests/client_test.c
+119
-158
No files found.
tests/client_test.c
View file @
8470c364
...
@@ -48,35 +48,42 @@
...
@@ -48,35 +48,42 @@
#define false 0
#define false 0
#endif
#endif
static
char
*
opt_db
=
"test"
,
*
opt_user
=
"venu"
,
*
opt_password
=
"venu"
;
/* set default options */
static
char
*
opt_host
=
0
,
*
opt_mysql_unix_port
=
0
;
static
char
*
opt_db
=
(
char
*
)
"test"
;
static
uint
opt_mysql_port
;
static
char
*
opt_user
=
(
char
*
)
"root"
;
static
char
*
opt_password
=
(
char
*
)
""
;
static
char
*
opt_host
=
0
;
static
char
*
opt_unix_socket
=
0
;
static
uint
opt_port
;
static
my_bool
tty_password
=
0
;
#define myheader(str) { printf("\n\n#######################\n"); \
#define myheader(str) { printf("\n\n#######################\n"); \
printf("%s",str); \
printf("%s",str); \
printf("\n#######################\n"); \
printf("\n#######################\n"); \
}
}
void
print_error
(
MYSQL
*
mysql
,
const
char
*
msg
,
int
line
,
char
*
file
)
#define init_bind(x) (bzero(x,sizeof(x)))
void
print_error
(
MYSQL
*
mysql
,
const
char
*
msg
)
{
{
if
(
mysql
)
if
(
mysql
)
{
{
fprintf
(
stderr
,
"
\n
%d@[MySQL]%s
\n
"
,
line
,
mysql_error
(
mysql
));
fprintf
(
stderr
,
"
\n
[MySQL]%s
\n
"
,
mysql_error
(
mysql
));
}
}
else
if
(
msg
)
fprintf
(
stderr
,
"
%d@%s
\n
"
,
line
,
msg
);
else
if
(
msg
)
fprintf
(
stderr
,
"
%s
\n
"
,
msg
);
}
}
void
print_st_error
(
MYSQL_STMT
*
stmt
,
const
char
*
msg
,
int
line
,
char
*
file
)
void
print_st_error
(
MYSQL_STMT
*
stmt
,
const
char
*
msg
)
{
{
if
(
stmt
)
if
(
stmt
)
{
{
fprintf
(
stderr
,
"
\n
%d@[MySQL]%s
\n
"
,
line
,
mysql_stmt_error
(
stmt
));
fprintf
(
stderr
,
"
\n
[MySQL]%s
\n
"
,
mysql_stmt_error
(
stmt
));
}
}
else
if
(
msg
)
fprintf
(
stderr
,
"
%d@%s
\n
"
,
line
,
msg
);
else
if
(
msg
)
fprintf
(
stderr
,
"
%s
\n
"
,
msg
);
}
}
#define myerror(mysql, msg) print_error(mysql, msg
, __LINE__, __FILE__
)
#define myerror(mysql, msg) print_error(mysql, msg)
#define mysterror(stmt, msg) print_st_error(stmt, msg
, __LINE__, __FILE__
)
#define mysterror(stmt, msg) print_st_error(stmt, msg)
#define myassert(x) if(x) {\
#define myassert(x) if(x) {\
fprintf(stderr,"ASSERTION FAILED AT %d@%s\n",__LINE__, __FILE__);\
fprintf(stderr,"ASSERTION FAILED AT %d@%s\n",__LINE__, __FILE__);\
...
@@ -148,8 +155,8 @@ MYSQL *client_connect()
...
@@ -148,8 +155,8 @@ MYSQL *client_connect()
exit
(
0
);
exit
(
0
);
}
}
if
(
!
(
mysql_real_connect
(
mysql
,
opt_host
,
opt_user
,
if
(
!
(
mysql_real_connect
(
mysql
,
opt_host
,
opt_user
,
opt_password
,
opt_db
,
opt_
mysql_
port
,
opt_password
,
opt_db
,
opt_port
,
opt_
mysql_unix_por
t
,
0
)))
opt_
unix_socke
t
,
0
)))
{
{
myerror
(
mysql
,
"connection failed"
);
myerror
(
mysql
,
"connection failed"
);
exit
(
0
);
exit
(
0
);
...
@@ -304,7 +311,7 @@ int my_process_result_set(MYSQL *mysql, MYSQL_RES *result)
...
@@ -304,7 +311,7 @@ int my_process_result_set(MYSQL *mysql, MYSQL_RES *result)
if
(
mysql_errno
(
mysql
)
!=
0
)
if
(
mysql_errno
(
mysql
)
!=
0
)
fprintf
(
stderr
,
"
\n\t
mysql_fetch_row() failed
\n
"
);
fprintf
(
stderr
,
"
\n\t
mysql_fetch_row() failed
\n
"
);
else
else
fprintf
(
stdout
,
"
\n\t
%
lu
rows returned
\n
"
,
row_count
);
fprintf
(
stdout
,
"
\n\t
%
d
rows returned
\n
"
,
row_count
);
return
(
row_count
);
return
(
row_count
);
}
}
...
@@ -722,7 +729,7 @@ void test_prepare(MYSQL *mysql)
...
@@ -722,7 +729,7 @@ void test_prepare(MYSQL *mysql)
MYSQL_STMT
*
stmt
;
MYSQL_STMT
*
stmt
;
int
rc
,
param_count
;
int
rc
,
param_count
;
char
query
[
200
];
char
query
[
200
];
long
int_data
;
int
int_data
;
char
str_data
[
50
];
char
str_data
[
50
];
char
tiny_data
;
char
tiny_data
;
short
small_data
;
short
small_data
;
...
@@ -730,10 +737,11 @@ void test_prepare(MYSQL *mysql)
...
@@ -730,10 +737,11 @@ void test_prepare(MYSQL *mysql)
double
real_data
;
double
real_data
;
double
double_data
;
double
double_data
;
MYSQL_RES
*
result
;
MYSQL_RES
*
result
;
MYSQL_BIND
bind
[
8
]
=
{
0
}
;
MYSQL_BIND
bind
[
8
];
myheader
(
"test_prepare"
);
myheader
(
"test_prepare"
);
init_bind
(
bind
);
rc
=
mysql_autocommit
(
mysql
,
true
);
rc
=
mysql_autocommit
(
mysql
,
true
);
myquery
(
mysql
,
rc
);
myquery
(
mysql
,
rc
);
...
@@ -831,10 +839,11 @@ void test_double_compare(MYSQL *mysql)
...
@@ -831,10 +839,11 @@ void test_double_compare(MYSQL *mysql)
char
query
[
200
],
real_data
[
10
],
tiny_data
;
char
query
[
200
],
real_data
[
10
],
tiny_data
;
double
double_data
;
double
double_data
;
MYSQL_RES
*
result
;
MYSQL_RES
*
result
;
MYSQL_BIND
bind
[
3
]
=
{
0
}
;
MYSQL_BIND
bind
[
3
];
myheader
(
"test_double_compare"
);
myheader
(
"test_double_compare"
);
init_bind
(
bind
);
rc
=
mysql_autocommit
(
mysql
,
true
);
rc
=
mysql_autocommit
(
mysql
,
true
);
myquery
(
mysql
,
rc
);
myquery
(
mysql
,
rc
);
...
@@ -912,10 +921,11 @@ void test_null(MYSQL *mysql)
...
@@ -912,10 +921,11 @@ void test_null(MYSQL *mysql)
const
char
*
query
;
const
char
*
query
;
int
nData
=
1
;
int
nData
=
1
;
MYSQL_RES
*
result
;
MYSQL_RES
*
result
;
MYSQL_BIND
bind
[
2
]
=
{
0
}
;
MYSQL_BIND
bind
[
2
];
myheader
(
"test_null"
);
myheader
(
"test_null"
);
init_bind
(
bind
);
rc
=
mysql_query
(
mysql
,
"DROP TABLE IF EXISTS test_null"
);
rc
=
mysql_query
(
mysql
,
"DROP TABLE IF EXISTS test_null"
);
myquery
(
mysql
,
rc
);
myquery
(
mysql
,
rc
);
...
@@ -1022,7 +1032,6 @@ void test_select_simple(MYSQL *mysql)
...
@@ -1022,7 +1032,6 @@ void test_select_simple(MYSQL *mysql)
}
}
/********************************************************
/********************************************************
* to test simple select *
* to test simple select *
*********************************************************/
*********************************************************/
...
@@ -1031,14 +1040,15 @@ void test_select(MYSQL *mysql)
...
@@ -1031,14 +1040,15 @@ void test_select(MYSQL *mysql)
MYSQL_STMT
*
stmt
;
MYSQL_STMT
*
stmt
;
int
rc
,
param_count
=
0
;
int
rc
,
param_count
=
0
;
const
char
*
query
;
const
char
*
query
;
char
*
szData
=
"updated-value"
;
char
*
szData
=
(
char
*
)
"updated-value"
;
int
nData
=
1
;
int
nData
=
1
;
MYSQL_BIND
bind
[
2
]
=
{
0
}
;
MYSQL_BIND
bind
[
2
];
MYSQL_RES
*
result
;
MYSQL_RES
*
result
;
myheader
(
"test_select"
);
myheader
(
"test_select"
);
init_bind
(
bind
);
rc
=
mysql_autocommit
(
mysql
,
true
);
rc
=
mysql_autocommit
(
mysql
,
true
);
myquery
(
mysql
,
rc
);
myquery
(
mysql
,
rc
);
...
@@ -1078,7 +1088,8 @@ void test_select(MYSQL *mysql)
...
@@ -1078,7 +1088,8 @@ void test_select(MYSQL *mysql)
assert
(
param_count
==
2
);
assert
(
param_count
==
2
);
/* string data */
/* string data */
nData
=
10
;
szData
=
"venu"
;
nData
=
10
;
szData
=
(
char
*
)
"venu"
;
bind
[
1
].
buffer_type
=
FIELD_TYPE_STRING
;
bind
[
1
].
buffer_type
=
FIELD_TYPE_STRING
;
bind
[
1
].
buffer
=
szData
;
bind
[
1
].
buffer
=
szData
;
bind
[
0
].
buffer
=
(
gptr
)
&
nData
;
bind
[
0
].
buffer
=
(
gptr
)
&
nData
;
...
@@ -1113,14 +1124,15 @@ void test_simple_update(MYSQL *mysql)
...
@@ -1113,14 +1124,15 @@ void test_simple_update(MYSQL *mysql)
MYSQL_STMT
*
stmt
;
MYSQL_STMT
*
stmt
;
int
rc
,
param_count
;
int
rc
,
param_count
;
const
char
*
query
;
const
char
*
query
;
char
*
szData
=
"updated-value"
;
char
*
szData
=
(
char
*
)
"updated-value"
;
int
nData
=
1
;
int
nData
=
1
;
MYSQL_RES
*
result
;
MYSQL_RES
*
result
;
MYSQL_BIND
bind
[
2
]
=
{
0
}
;
MYSQL_BIND
bind
[
2
];
myheader
(
"test_simple_update"
);
myheader
(
"test_simple_update"
);
init_bind
(
bind
);
rc
=
mysql_autocommit
(
mysql
,
true
);
rc
=
mysql_autocommit
(
mysql
,
true
);
myquery
(
mysql
,
rc
);
myquery
(
mysql
,
rc
);
...
@@ -1198,11 +1210,12 @@ void test_long_data(MYSQL *mysql)
...
@@ -1198,11 +1210,12 @@ void test_long_data(MYSQL *mysql)
char
*
data
=
NullS
;
char
*
data
=
NullS
;
int
length
;
int
length
;
MYSQL_RES
*
result
;
MYSQL_RES
*
result
;
MYSQL_BIND
bind
[
2
]
=
{
0
}
;
MYSQL_BIND
bind
[
2
];
myheader
(
"test_long_data"
);
myheader
(
"test_long_data"
);
init_bind
(
bind
);
rc
=
mysql_autocommit
(
mysql
,
true
);
rc
=
mysql_autocommit
(
mysql
,
true
);
myquery
(
mysql
,
rc
);
myquery
(
mysql
,
rc
);
...
@@ -1245,7 +1258,7 @@ void test_long_data(MYSQL *mysql)
...
@@ -1245,7 +1258,7 @@ void test_long_data(MYSQL *mysql)
fprintf
(
stdout
,
"mysql_execute() returned %d
\n
"
,
rc
);
fprintf
(
stdout
,
"mysql_execute() returned %d
\n
"
,
rc
);
assert
(
rc
==
MYSQL_NEED_DATA
);
assert
(
rc
==
MYSQL_NEED_DATA
);
data
=
"Micheal"
;
data
=
(
char
*
)
"Micheal"
;
/* supply data in pieces */
/* supply data in pieces */
rc
=
mysql_send_long_data
(
stmt
,
0
,
data
,
7
);
rc
=
mysql_send_long_data
(
stmt
,
0
,
data
,
7
);
...
@@ -1261,7 +1274,7 @@ void test_long_data(MYSQL *mysql)
...
@@ -1261,7 +1274,7 @@ void test_long_data(MYSQL *mysql)
/* append data again ..*/
/* append data again ..*/
/* supply data in pieces */
/* supply data in pieces */
data
=
" 'monty' widenius"
;
data
=
(
char
*
)
" 'monty' widenius"
;
rc
=
mysql_send_long_data
(
stmt
,
0
,
data
,
17
);
rc
=
mysql_send_long_data
(
stmt
,
0
,
data
,
17
);
mystmt
(
stmt
,
rc
);
mystmt
(
stmt
,
rc
);
...
@@ -1300,11 +1313,12 @@ void test_long_data_str(MYSQL *mysql)
...
@@ -1300,11 +1313,12 @@ void test_long_data_str(MYSQL *mysql)
char
data
[
255
];
char
data
[
255
];
int
length
;
int
length
;
MYSQL_RES
*
result
;
MYSQL_RES
*
result
;
MYSQL_BIND
bind
[
2
]
=
{
0
}
;
MYSQL_BIND
bind
[
2
];
myheader
(
"test_long_data_str"
);
myheader
(
"test_long_data_str"
);
init_bind
(
bind
);
rc
=
mysql_autocommit
(
mysql
,
true
);
rc
=
mysql_autocommit
(
mysql
,
true
);
myquery
(
mysql
,
rc
);
myquery
(
mysql
,
rc
);
...
@@ -1398,14 +1412,15 @@ void test_long_data_str1(MYSQL *mysql)
...
@@ -1398,14 +1412,15 @@ void test_long_data_str1(MYSQL *mysql)
MYSQL_STMT
*
stmt
;
MYSQL_STMT
*
stmt
;
int
rc
,
param_count
;
int
rc
,
param_count
;
const
char
*
query
;
const
char
*
query
;
char
*
data
=
"MySQL AB"
;
char
*
data
=
(
char
*
)
"MySQL AB"
;
int
length
;
int
length
;
MYSQL_RES
*
result
;
MYSQL_RES
*
result
;
MYSQL_BIND
bind
[
2
]
=
{
0
}
;
MYSQL_BIND
bind
[
2
];
myheader
(
"test_long_data_str1"
);
myheader
(
"test_long_data_str1"
);
init_bind
(
bind
);
rc
=
mysql_autocommit
(
mysql
,
true
);
rc
=
mysql_autocommit
(
mysql
,
true
);
myquery
(
mysql
,
rc
);
myquery
(
mysql
,
rc
);
...
@@ -1511,11 +1526,12 @@ void test_long_data_bin(MYSQL *mysql)
...
@@ -1511,11 +1526,12 @@ void test_long_data_bin(MYSQL *mysql)
char
data
[
255
];
char
data
[
255
];
int
length
;
int
length
;
MYSQL_RES
*
result
;
MYSQL_RES
*
result
;
MYSQL_BIND
bind
[
2
]
=
{
0
}
;
MYSQL_BIND
bind
[
2
];
myheader
(
"test_long_data_bin"
);
myheader
(
"test_long_data_bin"
);
init_bind
(
bind
);
rc
=
mysql_autocommit
(
mysql
,
true
);
rc
=
mysql_autocommit
(
mysql
,
true
);
myquery
(
mysql
,
rc
);
myquery
(
mysql
,
rc
);
...
@@ -1597,7 +1613,6 @@ void test_long_data_bin(MYSQL *mysql)
...
@@ -1597,7 +1613,6 @@ void test_long_data_bin(MYSQL *mysql)
assert
(
1
==
my_process_result_set
(
mysql
,
result
));
assert
(
1
==
my_process_result_set
(
mysql
,
result
));
mysql_free_result
(
result
);
mysql_free_result
(
result
);
free
(
data
);
}
}
...
@@ -1612,11 +1627,12 @@ void test_simple_delete(MYSQL *mysql)
...
@@ -1612,11 +1627,12 @@ void test_simple_delete(MYSQL *mysql)
char
szData
[
30
]
=
{
0
};
char
szData
[
30
]
=
{
0
};
int
nData
=
1
;
int
nData
=
1
;
MYSQL_RES
*
result
;
MYSQL_RES
*
result
;
MYSQL_BIND
bind
[
2
]
=
{
0
}
;
MYSQL_BIND
bind
[
2
];
myheader
(
"test_simple_delete"
);
myheader
(
"test_simple_delete"
);
init_bind
(
bind
);
rc
=
mysql_autocommit
(
mysql
,
true
);
rc
=
mysql_autocommit
(
mysql
,
true
);
myquery
(
mysql
,
rc
);
myquery
(
mysql
,
rc
);
...
@@ -1695,14 +1711,15 @@ void test_update(MYSQL *mysql)
...
@@ -1695,14 +1711,15 @@ void test_update(MYSQL *mysql)
MYSQL_STMT
*
stmt
;
MYSQL_STMT
*
stmt
;
int
rc
,
param_count
;
int
rc
,
param_count
;
const
char
*
query
;
const
char
*
query
;
char
*
szData
=
"updated-value"
;
char
*
szData
=
(
char
*
)
"updated-value"
;
int
nData
=
1
;
int
nData
=
1
;
MYSQL_RES
*
result
;
MYSQL_RES
*
result
;
MYSQL_BIND
bind
[
2
]
=
{
0
}
;
MYSQL_BIND
bind
[
2
];
myheader
(
"test_update"
);
myheader
(
"test_update"
);
init_bind
(
bind
);
rc
=
mysql_autocommit
(
mysql
,
true
);
rc
=
mysql_autocommit
(
mysql
,
true
);
myquery
(
mysql
,
rc
);
myquery
(
mysql
,
rc
);
...
@@ -1729,7 +1746,7 @@ void test_update(MYSQL *mysql)
...
@@ -1729,7 +1746,7 @@ void test_update(MYSQL *mysql)
assert
(
param_count
==
2
);
assert
(
param_count
==
2
);
/* string data */
/* string data */
szData
=
"inserted-data"
;
szData
=
(
char
*
)
"inserted-data"
;
bind
[
0
].
buffer_type
=
FIELD_TYPE_STRING
;
bind
[
0
].
buffer_type
=
FIELD_TYPE_STRING
;
bind
[
0
].
buffer
=
szData
;
bind
[
0
].
buffer
=
szData
;
bind
[
1
].
buffer
=
(
gptr
)
&
nData
;
bind
[
1
].
buffer
=
(
gptr
)
&
nData
;
...
@@ -1754,7 +1771,7 @@ void test_update(MYSQL *mysql)
...
@@ -1754,7 +1771,7 @@ void test_update(MYSQL *mysql)
param_count
=
mysql_param_count
(
stmt
);
param_count
=
mysql_param_count
(
stmt
);
fprintf
(
stdout
,
" total parameters in update:%d
\n
"
,
param_count
);
fprintf
(
stdout
,
" total parameters in update:%d
\n
"
,
param_count
);
assert
(
param_count
==
2
);
assert
(
param_count
==
2
);
nData
=
100
;
szData
=
"updated-data"
;
nData
=
100
;
szData
=
(
char
*
)
"updated-data"
;
bind
[
0
].
buffer_type
=
FIELD_TYPE_STRING
;
bind
[
0
].
buffer_type
=
FIELD_TYPE_STRING
;
...
@@ -1853,10 +1870,11 @@ void test_bind_result(MYSQL *mysql)
...
@@ -1853,10 +1870,11 @@ void test_bind_result(MYSQL *mysql)
const
char
query
[
100
];
const
char
query
[
100
];
int
nData
;
int
nData
;
char
szData
[
100
];
char
szData
[
100
];
MYSQL_BIND
bind
[
2
]
=
{
0
}
;
MYSQL_BIND
bind
[
2
];
myheader
(
"test_bind_result"
);
myheader
(
"test_bind_result"
);
init_bind
(
bind
);
rc
=
mysql_query
(
mysql
,
"DROP TABLE IF EXISTS test_bind_result"
);
rc
=
mysql_query
(
mysql
,
"DROP TABLE IF EXISTS test_bind_result"
);
myquery
(
mysql
,
rc
);
myquery
(
mysql
,
rc
);
...
@@ -1929,18 +1947,20 @@ void test_prepare_ext(MYSQL *mysql)
...
@@ -1929,18 +1947,20 @@ void test_prepare_ext(MYSQL *mysql)
char
tData
=
1
;
char
tData
=
1
;
short
sData
=
10
;
short
sData
=
10
;
longlong
bData
=
20
;
longlong
bData
=
20
;
MYSQL_BIND
bind_int
[
6
]
=
{
0
}
;
MYSQL_BIND
bind_int
[
6
];
myheader
(
"test_prepare_ext"
);
myheader
(
"test_prepare_ext"
);
init_bind
(
bind_int
);
rc
=
mysql_query
(
mysql
,
"DROP TABLE IF EXISTS test_prepare_ext"
);
rc
=
mysql_query
(
mysql
,
"DROP TABLE IF EXISTS test_prepare_ext"
);
myquery
(
mysql
,
rc
);
myquery
(
mysql
,
rc
);
rc
=
mysql_commit
(
mysql
);
rc
=
mysql_commit
(
mysql
);
myquery
(
mysql
,
rc
);
myquery
(
mysql
,
rc
);
query
=
"CREATE TABLE test_prepare_ext\
query
=
(
char
*
)
"CREATE TABLE test_prepare_ext\
(\
(\
c1 tinyint,\
c1 tinyint,\
c2 smallint,\
c2 smallint,\
...
@@ -1979,7 +1999,7 @@ void test_prepare_ext(MYSQL *mysql)
...
@@ -1979,7 +1999,7 @@ void test_prepare_ext(MYSQL *mysql)
myquery
(
mysql
,
rc
);
myquery
(
mysql
,
rc
);
/* insert by prepare - all integers */
/* insert by prepare - all integers */
query
=
"INSERT INTO test_prepare_ext(c1,c2,c3,c4,c5,c6) VALUES(?,?,?,?,?,?)"
;
query
=
(
char
*
)
"INSERT INTO test_prepare_ext(c1,c2,c3,c4,c5,c6) VALUES(?,?,?,?,?,?)"
;
stmt
=
mysql_prepare
(
mysql
,
query
);
stmt
=
mysql_prepare
(
mysql
,
query
);
myquery
(
mysql
,
rc
);
myquery
(
mysql
,
rc
);
...
@@ -2093,36 +2113,6 @@ void test_field_names(MYSQL *mysql)
...
@@ -2093,36 +2113,6 @@ void test_field_names(MYSQL *mysql)
mysql_free_result
(
result
);
mysql_free_result
(
result
);
}
}
/********************************************************
* to test multi-query execution *
*********************************************************/
void
test_multi_query
(
MYSQL
*
mysql
)
{
#if 0
int rc;
MYSQL_RES *result;
char *sql;
ulong length;
myheader("test_multi_query");
sql = "DROP TABLE IF EXISTS t_multi_query;CREATE TABLE t_multi_query(id int,str char(20));\
INSERT INTO t_multi_query VALUES(10,'original;');\
UPDATE t_multi_query SET id=100,str='upd;one' WHERE id = 10;\
SELECT * FROM t_multi_query";
length = strlen(sql);
rc = mysql_multi_query(mysql,sql,length);
myquery(mysql,rc);
while((result = mysql_next_result(mysql)))
{
my_process_result_set(mysql,result);
mysql_free_result(result);
}
#endif
}
/********************************************************
/********************************************************
* to test warnings *
* to test warnings *
*********************************************************/
*********************************************************/
...
@@ -2179,7 +2169,7 @@ void test_insert(MYSQL *mysql)
...
@@ -2179,7 +2169,7 @@ void test_insert(MYSQL *mysql)
char
str_data
[
50
];
char
str_data
[
50
];
char
tiny_data
;
char
tiny_data
;
MYSQL_RES
*
result
;
MYSQL_RES
*
result
;
MYSQL_BIND
bind
[
2
]
=
{
0
}
;
MYSQL_BIND
bind
[
2
];
myheader
(
"test_insert"
);
myheader
(
"test_insert"
);
...
@@ -2197,6 +2187,7 @@ void test_insert(MYSQL *mysql)
...
@@ -2197,6 +2187,7 @@ void test_insert(MYSQL *mysql)
myquery
(
mysql
,
rc
);
myquery
(
mysql
,
rc
);
/* insert by prepare */
/* insert by prepare */
bzero
(
bind
,
sizeof
(
bind
));
strcpy
(
query
,
"INSERT INTO test_prep_insert VALUES(?,?)"
);
strcpy
(
query
,
"INSERT INTO test_prep_insert VALUES(?,?)"
);
stmt
=
mysql_prepare
(
mysql
,
query
);
stmt
=
mysql_prepare
(
mysql
,
query
);
myxquery
(
mysql
,
stmt
);
myxquery
(
mysql
,
stmt
);
...
@@ -2251,7 +2242,6 @@ void test_prepare_resultset(MYSQL *mysql)
...
@@ -2251,7 +2242,6 @@ void test_prepare_resultset(MYSQL *mysql)
int
rc
,
param_count
;
int
rc
,
param_count
;
char
query
[
200
];
char
query
[
200
];
MYSQL_RES
*
result
;
MYSQL_RES
*
result
;
MYSQL_BIND
bind
[
2
]
=
{
0
};
myheader
(
"test_prepare_resultset"
);
myheader
(
"test_prepare_resultset"
);
...
@@ -2300,22 +2290,9 @@ void test_prepare_resultset(MYSQL *mysql)
...
@@ -2300,22 +2290,9 @@ void test_prepare_resultset(MYSQL *mysql)
my_print_result_metadata
(
result
);
my_print_result_metadata
(
result
);
mysql_free_result
(
result
);
mysql_free_result
(
result
);
mysql_stmt_close
(
stmt
);
mysql_stmt_close
(
stmt
);
}
}
void
test_extra
()
{
printf
(
"
\n
sizeof(sshort):%d"
,
sizeof
(
signed
short
));
printf
(
"
\n
sizeof(ushort):%d"
,
sizeof
(
unsigned
short
));
printf
(
"
\n
sizeof(sint):%d"
,
sizeof
(
signed
int
));
printf
(
"
\n
sizeof(uint):%d"
,
sizeof
(
unsigned
int
));
printf
(
"
\n
sizeof(slong):%d"
,
sizeof
(
signed
long
));
printf
(
"
\n
sizeof(ulong):%d"
,
sizeof
(
unsigned
long
));
printf
(
"
\n
sizeof(float):%d"
,
sizeof
(
float
));
printf
(
"
\n
sizeof(double):%d"
,
sizeof
(
double
));
}
/********************************************************
/********************************************************
* to test field flags (verify .NET provider) *
* to test field flags (verify .NET provider) *
*********************************************************/
*********************************************************/
...
@@ -2377,31 +2354,24 @@ void test_field_flags(MYSQL *mysql)
...
@@ -2377,31 +2354,24 @@ void test_field_flags(MYSQL *mysql)
mysql_free_result
(
result
);
mysql_free_result
(
result
);
}
}
/********************************************************
static
struct
my_option
myctest_long_options
[]
=
* parsing the test arguments *
*********************************************************/
static
struct
my_option
long_options
[]
=
{
{
{
"help"
,
'?'
,
"Display this help information and exit."
,
0
,
0
,
0
,
{
"help"
,
'?'
,
"Display this help and exit"
,
0
,
0
,
0
,
GET_NO_ARG
,
NO_ARG
,
0
,
GET_NO_ARG
,
NO_ARG
,
0
,
0
,
0
,
0
,
0
,
0
},
0
,
0
,
0
,
0
,
0
},
{
"database"
,
'D'
,
"Initial database after connection."
,
(
gptr
*
)
&
opt_db
,
(
gptr
*
)
&
opt_db
,
0
,
{
"database"
,
'D'
,
"Database to use"
,
(
gptr
*
)
&
opt_db
,
(
gptr
*
)
&
opt_db
,
GET_STR
,
REQUIRED_ARG
,
0
,
0
,
0
,
0
,
0
,
0
},
0
,
GET_STR_ALLOC
,
REQUIRED_ARG
,
0
,
0
,
0
,
0
,
0
,
0
},
{
"host"
,
'h'
,
"Connect to host"
,
(
gptr
*
)
&
opt_host
,
(
gptr
*
)
&
opt_host
,
0
,
{
"host"
,
'h'
,
"Connect to host"
,
(
gptr
*
)
&
opt_host
,
(
gptr
*
)
&
opt_host
,
0
,
GET_STR
,
GET_STR
,
REQUIRED_ARG
,
0
,
0
,
0
,
0
,
0
,
0
},
REQUIRED_ARG
,
0
,
0
,
0
,
0
,
0
,
0
},
#ifdef __WIN__
{
"password"
,
'p'
,
{
"pipe"
,
'W'
,
"Use named pipes to connect to server."
,
0
,
0
,
0
,
"Password to use when connecting to server. If password is not given it's asked from the tty."
,
GET_NO_ARG
,
NO_ARG
,
0
,
0
,
0
,
0
,
0
,
0
},
0
,
0
,
0
,
GET_STR
,
OPT_ARG
,
0
,
0
,
0
,
0
,
0
,
0
},
#endif
{
"user"
,
'u'
,
"User for login if not current user"
,
(
gptr
*
)
&
opt_user
,
{
"port"
,
'P'
,
"Port number to use for connection."
,
0
,
0
,
0
,
(
gptr
*
)
&
opt_user
,
0
,
GET_STR_ALLOC
,
REQUIRED_ARG
,
0
,
0
,
0
,
0
,
0
,
0
},
GET_LONG
,
REQUIRED_ARG
,
0
,
0
,
0
,
0
,
0
,
0
},
{
"port"
,
'P'
,
"Port number to use for connection"
,
(
gptr
*
)
&
opt_port
,
{
"socket"
,
'S'
,
"Socket file to use for connection."
,
0
,
0
,
0
,
(
gptr
*
)
&
opt_port
,
0
,
GET_UINT
,
REQUIRED_ARG
,
0
,
0
,
0
,
0
,
0
,
0
},
GET_STR
,
REQUIRED_ARG
,
0
,
0
,
0
,
0
,
0
,
0
},
{
"socket"
,
'S'
,
"Socket file to use for connection"
,
(
gptr
*
)
&
opt_unix_socket
,
{
"user"
,
'u'
,
"User for login if not current user."
,
(
gptr
*
)
&
opt_user
,
(
gptr
*
)
&
opt_user
,
0
,
(
gptr
*
)
&
opt_unix_socket
,
0
,
GET_STR_ALLOC
,
REQUIRED_ARG
,
0
,
0
,
0
,
0
,
0
,
0
},
GET_STR
,
REQUIRED_ARG
,
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
,
GET_NO_ARG
,
NO_ARG
,
0
,
0
,
0
,
0
,
0
,
0
}
{
"password"
,
'p'
,
"Password to use when connecting to server"
,
0
,
0
,
0
,
GET_STR
,
OPT_ARG
,
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
}
};
};
static
void
usage
(
void
)
static
void
usage
(
void
)
...
@@ -2436,65 +2406,58 @@ static void usage(void)
...
@@ -2436,65 +2406,58 @@ static void usage(void)
printf
(
"*********************************************************************
\n
"
);
printf
(
"*********************************************************************
\n
"
);
}
}
static
my_bool
static
void
get_options
(
register
int
*
argc
,
register
char
***
argv
)
get_one_option
(
int
optid
,
const
struct
my_option
*
opt
__attribute__
((
unused
)),
char
*
argument
)
{
{
int
c
,
option_index
=
0
;
switch
(
optid
)
{
while
((
c
=
getopt_long
(
*
argc
,
*
argv
,
"D:h:p:u::WP:S:V"
,
long_options
,
&
option_index
))
!=
EOF
)
{
switch
(
c
)
{
case
'D'
:
opt_db
=
optarg
;
case
'h'
:
opt_host
=
optarg
;
break
;
case
'W'
:
#ifdef __WIN__
opt_mysql_unix_port
=
MYSQL_NAMEDPIPE
;
#endif
break
;
case
'P'
:
opt_mysql_port
=
(
unsigned
int
)
atoi
(
optarg
);
break
;
case
'S'
:
opt_mysql_unix_port
=
optarg
;
break
;
case
'u'
:
opt_user
=
optarg
;
break
;
case
'p'
:
case
'p'
:
opt_password
=
optarg
;
if
(
argument
)
while
(
*
optarg
)
*
optarg
++=
'x'
;
/* Destroy argument */
{
my_free
(
opt_password
,
MYF
(
MY_ALLOW_ZERO_PTR
));
opt_password
=
my_strdup
(
argument
,
MYF
(
MY_FAE
));
while
(
*
argument
)
*
argument
++=
'x'
;
/* Destroy argument */
}
else
tty_password
=
1
;
break
;
break
;
case
'?'
:
case
'?'
:
case
'I'
:
/* Info */
usage
();
usage
();
exit
(
0
);
exit
(
1
);
}
break
;
}
(
*
argc
)
-=
optind
;
(
*
argv
)
+=
optind
;
if
(
*
argc
!=
0
)
{
fprintf
(
stderr
,
"Too many arguments (%d)
\n
"
,
*
argc
);
usage
();
exit
(
-
1
);
}
}
return
;
return
0
;
}
}
static
const
char
*
load_default_groups
[]
=
{
"client"
,
0
};
static
void
get_options
(
int
argc
,
char
**
argv
)
{
int
ho_error
;
load_defaults
(
"my"
,
load_default_groups
,
&
argc
,
&
argv
);
if
((
ho_error
=
handle_options
(
&
argc
,
&
argv
,
myctest_long_options
,
get_one_option
)))
exit
(
ho_error
);
free_defaults
(
argv
);
if
(
tty_password
)
opt_password
=
get_tty_password
(
NullS
);
return
;
}
/********************************************************
/********************************************************
* main routine *
* main routine *
*********************************************************/
*********************************************************/
int
main
(
int
argc
,
char
*
argv
[]
)
int
main
(
int
argc
,
char
*
*
argv
)
{
{
MYSQL
*
mysql
;
MYSQL
*
mysql
;
MY_INIT
(
argv
[
0
]);
MY_INIT
(
argv
[
0
]);
get_options
(
&
argc
,
&
argv
);
get_options
(
argc
,
argv
);
/* don't work -- options : TODO */
mysql
=
client_connect
();
/* connect to server */
mysql
=
client_connect
();
/* connect to server */
...
@@ -2526,14 +2489,12 @@ int main(int argc, char *argv[])
...
@@ -2526,14 +2489,12 @@ int main(int argc, char *argv[])
test_long_data_bin
(
mysql
);
/* long binary insertion */
test_long_data_bin
(
mysql
);
/* long binary insertion */
test_warnings
(
mysql
);
/* show warnings test */
test_warnings
(
mysql
);
/* show warnings test */
test_errors
(
mysql
);
/* show errors test */
test_errors
(
mysql
);
/* show errors test */
test_extra
();
/* misc case */
test_select_simple
(
mysql
);
/* simple select prepare */
test_select_simple
(
mysql
);
/* simple select prepare */
test_prepare_resultset
(
mysql
);
/* prepare meta info test */
test_prepare_resultset
(
mysql
);
/* prepare meta info test */
test_multi_query
(
mysql
);
/* Not yet supported */
client_disconnect
(
mysql
);
/* disconnect from server */
client_disconnect
(
mysql
);
/* disconnect from server */
fprintf
(
stdout
,
"
\n
done !!!
\n
"
);
fprintf
(
stdout
,
"
\n
done !!!
\n
"
);
return
(
0
);
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