Commit 2185f1a5 authored by monty@mysql.com's avatar monty@mysql.com

Remove usage of !$ from mysql-tests

Added protocol::flush() for easier embedded-server code
Increase block allocation variables a bit as they where a bit too small for MySQL 4.1
Added option --silent to client_test
parent f5c77f6a
......@@ -42,7 +42,7 @@
**********************************************************************/
#define MTEST_VERSION "2.3"
#define MTEST_VERSION "2.4"
#include <my_global.h>
#include <mysql_embed.h>
......@@ -243,8 +243,7 @@ VAR var_reg[10];
HASH var_hash;
my_bool disable_query_log=0, disable_result_log=0, disable_warnings=0;
my_bool disable_info= 1; /* By default off */
/* default for disable_abort_on_error: false = abort on unmasked error */
my_bool disable_abort_on_error= 0;
my_bool abort_on_error= 1;
struct connection cons[MAX_CONS];
struct connection* cur_con, *next_con, *cons_end;
......@@ -370,7 +369,7 @@ const char *command_names[]=
};
TYPELIB command_typelib= {array_elements(command_names),"",
command_names};
command_names, 0};
DYNAMIC_STRING ds_res;
static void die(const char *fmt, ...);
......@@ -744,7 +743,7 @@ err:
DBUG_RETURN(0);
}
static VAR* var_obtain(char* name, int len)
static VAR *var_obtain(const char* name, int len)
{
VAR* v;
if ((v = (VAR*)hash_search(&var_hash, name, len)))
......@@ -754,28 +753,33 @@ static VAR* var_obtain(char* name, int len)
return v;
}
int var_set(char* var_name, char* var_name_end, char* var_val,
char* var_val_end)
int var_set(const char *var_name, const char *var_name_end,
const char *var_val, const char *var_val_end)
{
int digit;
VAR* v;
DBUG_ENTER("var_set");
DBUG_PRINT("enter", ("var_name: '%.*s' = '%.*s' (length: %d)",
(int) (var_name_end - var_name), var_name,
(int) (var_val_end - var_val), var_val,
(int) (var_val_end - var_val)));
if (*var_name++ != '$')
{
--var_name;
*var_name_end = 0;
var_name--;
die("Variable name in %s does not start with '$'", var_name);
}
digit = *var_name - '0';
if (!(digit < 10 && digit >= 0))
{
v = var_obtain(var_name, var_name_end - var_name);
v = var_obtain(var_name, (uint) (var_name_end - var_name));
}
else
v = var_reg + digit;
return eval_expr(v, var_val, (const char**)&var_val_end);
}
int open_file(const char* name)
{
char buff[FN_REFLEN];
......@@ -1244,18 +1248,22 @@ int do_let(struct st_query* q)
return var_set(var_name, var_name_end, var_val_start, q->end);
}
/* Store an integer (typically the returncode of the last SQL) */
/* statement in the mysqltest builtin variable $mysql_errno, by */
/* simulating of a user statement "let $mysql_errno= <integer>" */
int var_set_errno(int sql_errno )
/*
Store an integer (typically the returncode of the last SQL)
statement in the mysqltest builtin variable $mysql_errno, by
simulating of a user statement "let $mysql_errno= <integer>"
*/
int var_set_errno(int sql_errno)
{
char var_name[] = "$mysql_errno", var_val[30];
sprintf(var_val, "%d", sql_errno);
/* On some odd systems, the return value from sprintf() isn't */
/* always the length of the string, so we use strlen() */
return var_set(var_name, var_name + 12, var_val, var_val + strlen(var_val));
const char *var_name= "$mysql_errno";
char var_val[21];
uint length= my_sprintf(var_val, (var_val, "%d", sql_errno));
return var_set(var_name, var_name + 12, var_val, var_val + length);
}
int do_rpl_probe(struct st_query* q __attribute__((unused)))
{
DBUG_ENTER("do_rpl_probe");
......@@ -1264,12 +1272,14 @@ int do_rpl_probe(struct st_query* q __attribute__((unused)))
DBUG_RETURN(0);
}
int do_enable_rpl_parse(struct st_query* q __attribute__((unused)))
{
mysql_enable_rpl_parse(&cur_con->mysql);
return 0;
}
int do_disable_rpl_parse(struct st_query* q __attribute__((unused)))
{
mysql_disable_rpl_parse(&cur_con->mysql);
......@@ -2013,7 +2023,7 @@ int read_query(struct st_query** q_ptr)
memcpy((gptr) q->expected_errno, (gptr) global_expected_errno,
sizeof(global_expected_errno));
q->expected_errors= global_expected_errors;
q->abort_on_error= (global_expected_errors == 0 && !disable_abort_on_error);
q->abort_on_error= (global_expected_errors == 0 && abort_on_error);
bzero((gptr) global_expected_errno, sizeof(global_expected_errno));
global_expected_errors=0;
if (p[0] == '-' && p[1] == '-')
......@@ -2422,7 +2432,7 @@ static int run_query(MYSQL *mysql, struct st_query *q, int flags)
if (ps_protocol_enabled && disable_info &&
(flags & QUERY_SEND) && (flags & QUERY_REAP) && ps_match_re(q->query))
return run_query_stmt (mysql, q, flags);
return run_query_stmt(mysql, q, flags);
return run_query_normal(mysql, q, flags);
}
......@@ -2659,9 +2669,12 @@ end:
dynstr_free(&ds_tmp);
if (q->type == Q_EVAL)
dynstr_free(&eval_query);
/* We save the return code (mysql_errno(mysql)) from the last call sent */
/* to the server into the mysqltest builtin variable $mysql_errno. This */
/* variable then can be used from the test case itself. */
/*
We save the return code (mysql_errno(mysql)) from the last call sent
to the server into the mysqltest builtin variable $mysql_errno. This
variable then can be used from the test case itself.
*/
var_set_errno(mysql_errno(mysql));
DBUG_RETURN(error);
}
......@@ -3012,6 +3025,7 @@ end:
dynstr_free(&ds_tmp);
if (q->type == Q_EVAL)
dynstr_free(&eval_query);
var_set_errno(mysql_stmt_errno(stmt));
mysql_stmt_close(stmt);
DBUG_RETURN(error);
}
......@@ -3319,7 +3333,7 @@ static VAR* var_from_env(const char *name, const char *def_val)
if (!(tmp = getenv(name)))
tmp = def_val;
v = var_init(0, name, 0, tmp, 0);
v = var_init(0, name, strlen(name), tmp, strlen(tmp));
my_hash_insert(&var_hash, (byte*)v);
return v;
}
......@@ -3416,9 +3430,11 @@ int main(int argc, char **argv)
init_var_hash(&cur_con->mysql);
/* Initialize $mysql_errno with -1, so we can */
/* - distinguish it from valid values ( >= 0 ) and */
/* - detect if there was never a command sent to the server */
/*
Initialize $mysql_errno with -1, so we can
- distinguish it from valid values ( >= 0 ) and
- detect if there was never a command sent to the server
*/
var_set_errno(-1);
while (!read_query(&q))
......@@ -3440,8 +3456,8 @@ int main(int argc, char **argv)
case Q_DISABLE_RPL_PARSE: do_disable_rpl_parse(q); break;
case Q_ENABLE_QUERY_LOG: disable_query_log=0; break;
case Q_DISABLE_QUERY_LOG: disable_query_log=1; break;
case Q_ENABLE_ABORT_ON_ERROR: disable_abort_on_error=0; break;
case Q_DISABLE_ABORT_ON_ERROR: disable_abort_on_error=1; break;
case Q_ENABLE_ABORT_ON_ERROR: abort_on_error=1; break;
case Q_DISABLE_ABORT_ON_ERROR: abort_on_error=0; break;
case Q_ENABLE_RESULT_LOG: disable_result_log=0; break;
case Q_DISABLE_RESULT_LOG: disable_result_log=1; break;
case Q_ENABLE_WARNINGS: disable_warnings=0; break;
......
......@@ -282,13 +282,7 @@ void my_net_local_init(NET *net);
void net_end(NET *net);
void net_clear(NET *net);
my_bool net_realloc(NET *net, unsigned long length);
#ifndef EMBEDDED_LIBRARY /* To be removed by HF */
my_bool net_flush(NET *net);
#else
#define net_flush(A)
#endif
my_bool my_net_write(NET *net,const char *packet,unsigned long len);
my_bool net_write_command(NET *net,unsigned char command,
const char *header, unsigned long head_len,
......
......@@ -7,11 +7,6 @@ otto
select otto from (select 1 as otto) as t1;
otto
1
select otto from (select 1 as otto) as t1;
otto
1
select friedrich from (select 1 as otto) as t1;
ERROR 42S22: Unknown column 'friedrich' in 'field list'
select friedrich from (select 1 as otto) as t1;
ERROR 42S22: Unknown column 'friedrich' in 'field list'
select otto from (select 1 as otto) as t1;
......@@ -147,5 +142,3 @@ after_--enable_abort_on_error
1064
select 3 from t1 ;
ERROR 42S02: Table 'test.t1' doesn't exist
select 3 from t1 ;
ERROR 42S02: Table 'test.t1' doesn't exist
--disable_result_log
--exec $TESTS_BINDIR/client_test --testcase --user=root --socket=$MASTER_MYSOCK --port=$MYSQL_TCP_PORT
--exec $TESTS_BINDIR/client_test --testcase --user=root --socket=$MASTER_MYSOCK --port=$MYSQL_TCP_PORT --silent
......@@ -5,7 +5,8 @@
select 1+2/*hello*/+3;
select 1 /* long
multi line comment */;
!$1065 ;
--error 1065
;
select 1 /*!32301 +1 */;
select 1 /*!52301 +1 */;
select 1--1;
......
......@@ -34,11 +34,14 @@ explain select t1.*,t2.* from t1 left join t2 on t1.a=t2.a where isnull(t2.a)=1;
select t1.*,t2.*,t3.a from t1 left join t2 on (t1.a=t2.a) left join t1 as t3 on (t2.a=t3.a);
# The next query should rearange the left joins to get this to work
!$1120 explain select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a);
!$1120 select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a);
--error 1120
explain select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a);
--error 1120
select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a);
# The next query should give an error in MySQL
!$1120 select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t2.a=t3.a);
--error 1120
select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t2.a=t3.a);
# Test of inner join
select t1.*,t2.* from t1 inner join t2 using (a);
......@@ -94,7 +97,8 @@ WHERE t1.uniq_id = 4
ORDER BY t2.c_amount;
INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes');
!$1062 INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes');
--error 1062
INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes');
INSERT INTO t2 VALUES (7,3,1000,2000,0,0,746294,937484,'yes');
#3rd select should show that one record is returned with null entries for the
......@@ -288,7 +292,8 @@ insert into t3 values (1);
insert into t4 values (1,1);
insert into t5 values (1,1);
!$1120 explain select * from t3 left join t4 on t4.seq_1_id = t2.t2_id left join t1 on t1.t1_id = t4.seq_0_id left join t5 on t5.seq_0_id = t1.t1_id left join t2 on t2.t2_id = t5.seq_1_id where t3.t3_id = 23;
--error 1120
explain select * from t3 left join t4 on t4.seq_1_id = t2.t2_id left join t1 on t1.t1_id = t4.seq_0_id left join t5 on t5.seq_0_id = t1.t1_id left join t2 on t2.t2_id = t5.seq_1_id where t3.t3_id = 23;
drop table t1,t2,t3,t4,t5;
......
......@@ -146,7 +146,8 @@ create table t1
);
INSERT INTO t1 VALUES (1, 1, 1, 1, 'a');
INSERT INTO t1 VALUES (1, 1, 1, 1, 'b');
!$1062 INSERT INTO t1 VALUES (1, 1, 1, 1, 'a');
--error 1062
INSERT INTO t1 VALUES (1, 1, 1, 1, 'a');
drop table t1;
#
......
......@@ -20,12 +20,10 @@ eval select $mysql_errno as "before_use_test" ;
select otto from (select 1 as otto) as t1;
# expectation = response
!$0 select otto from (select 1 as otto) as t1;
--error 0
select otto from (select 1 as otto) as t1;
# expectation <> response
-- // !$1054 select otto from (select 1 as otto) as t1;
-- // --error 1054
-- // select otto from (select 1 as otto) as t1;
......@@ -38,12 +36,10 @@ select otto from (select 1 as otto) as t1;
# ----------------------------------------------------------------------------
# expectation <> response
#!$0 select friedrich from (select 1 as otto) as t1;
#--error 0
#select friedrich from (select 1 as otto) as t1;
# expectation = response
!$1054 select friedrich from (select 1 as otto) as t1;
--error 1054
select friedrich from (select 1 as otto) as t1;
......@@ -94,130 +90,130 @@ select friedrich from (select 1 as otto) as t1;
#
# The following test cases often initialize $mysql_errno to 1064 by
# a command with wrong syntax.
# Example: !$1064 To prevent the abort after the error.
# Example: --error 1064 To prevent the abort after the error.
# garbage ;
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# 1. check mysql_errno = 0 after successful statement
# check mysql_errno = 0 after successful statement
# ----------------------------------------------------------------------------
select otto from (select 1 as otto) as t1;
eval select $mysql_errno as "after_successful_stmt_errno" ;
#----------------------------------------------------------------------------
# 2. check mysql_errno = 1064 after statement with wrong syntax
# check mysql_errno = 1064 after statement with wrong syntax
# ----------------------------------------------------------------------------
!$1064
--error 1064
garbage ;
eval select $mysql_errno as "after_wrong_syntax_errno" ;
# ----------------------------------------------------------------------------
# 3. check if let $my_var= 'abc' ; affects $mysql_errno
# check if let $my_var= 'abc' ; affects $mysql_errno
# ----------------------------------------------------------------------------
!$1064
--error 1064
garbage ;
let $my_var= 'abc' ;
eval select $mysql_errno as "after_let_var_equal_value" ;
# ----------------------------------------------------------------------------
# 4. check if set @my_var= 'abc' ; affects $mysql_errno
# check if set @my_var= 'abc' ; affects $mysql_errno
# ----------------------------------------------------------------------------
!$1064
--error 1064
garbage ;
set @my_var= 'abc' ;
eval select $mysql_errno as "after_set_var_equal_value" ;
# ----------------------------------------------------------------------------
# 5. check if the setting of --disable-warnings itself affects $mysql_errno
# check if the setting of --disable-warnings itself affects $mysql_errno
# (May be --<whatever> modifies $mysql_errno.)
# ----------------------------------------------------------------------------
!$1064
--error 1064
garbage ;
--disable_warnings
eval select $mysql_errno as "after_disable_warnings_command" ;
# ----------------------------------------------------------------------------
# 6. check if --disable-warnings + command with warning affects the errno
# check if --disable-warnings + command with warning affects the errno
# stored within $mysql_errno
# (May be disabled warnings affect $mysql_errno.)
# ----------------------------------------------------------------------------
drop table if exists t1 ;
!$1064
--error 1064
garbage ;
drop table if exists t1 ;
eval select $mysql_errno as "after_disable_warnings" ;
--enable_warnings
# ----------------------------------------------------------------------------
# 7. check if masked errors affect $mysql_errno
# check if masked errors affect $mysql_errno
# ----------------------------------------------------------------------------
!$1064
--error 1064
garbage ;
--error 1146
select 3 from t1 ;
eval select $mysql_errno as "after_minus_masked" ;
!$1064
--error 1064
garbage ;
!$1146
--error 1146
select 3 from t1 ;
eval select $mysql_errno as "after_!_masked" ;
# ----------------------------------------------------------------------------
# 8. Will manipulations of $mysql_errno be possible and visible ?
# Will manipulations of $mysql_errno be possible and visible ?
# ----------------------------------------------------------------------------
!$1064
--error 1064
garbage ;
let $mysql_errno= -1;
eval select $mysql_errno as "after_let_errno_equal_value" ;
# ----------------------------------------------------------------------------
# 9. How affect actions on prepared statements $mysql_errno ?
# How affect actions on prepared statements $mysql_errno ?
# ----------------------------------------------------------------------------
# failing prepare
!$1064
--error 1064
garbage ;
!$1146
--error 1146
prepare stmt from "select 3 from t1" ;
eval select $mysql_errno as "after_failing_prepare" ;
create table t1 ( f1 char(10));
# successful prepare
!$1064
--error 1064
garbage ;
prepare stmt from "select 3 from t1" ;
eval select $mysql_errno as "after_successful_prepare" ;
# successful execute
!$1064
--error 1064
garbage ;
execute stmt;
eval select $mysql_errno as "after_successful_execute" ;
# failing execute (table dropped)
drop table t1;
!$1064
--error 1064
garbage ;
!$1146
--error 1146
execute stmt;
eval select $mysql_errno as "after_failing_execute" ;
# failing execute (unknown statement)
!$1064
--error 1064
garbage ;
!$1243
--error 1243
execute __stmt_;
eval select $mysql_errno as "after_failing_execute" ;
# successful deallocate
!$1064
--error 1064
garbage ;
deallocate prepare stmt;
eval select $mysql_errno as "after_successful_deallocate" ;
# failing deallocate ( statement handle does not exist )
!$1064
--error 1064
garbage ;
!$1243
--error 1243
deallocate prepare __stmt_;
eval select $mysql_errno as "after_failing_deallocate" ;
......@@ -231,7 +227,7 @@ eval select $mysql_errno as "after_failing_deallocate" ;
# The default is "--enable_abort_on_error".
#
# "Maskings" are
# !$<error number> and --error <error number>
# --error <error number> and --error <error number>
# in the line before the failing statement.
#
# There are some additional test case for $mysql_errno
......@@ -240,58 +236,53 @@ eval select $mysql_errno as "after_failing_deallocate" ;
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# 1. Switch the abort on error off and check the effect on $mysql_errno
# Switch the abort on error off and check the effect on $mysql_errno
# ----------------------------------------------------------------------------
!$1064
--error 1064
garbage ;
--disable_abort_on_error
eval select $mysql_errno as "after_--disable_abort_on_error" ;
# ----------------------------------------------------------------------------
# 2. "unmasked" failing statement should not cause an abort
# "unmasked" failing statement should not cause an abort
# ----------------------------------------------------------------------------
select 3 from t1 ;
# ----------------------------------------------------------------------------
# 3. masked failing statements
# masked failing statements
# ----------------------------------------------------------------------------
# expected error = response
--error 1146
select 3 from t1 ;
!$1146
--error 1146
select 3 from t1 ;
eval select $mysql_errno as "after_!errno_masked_error" ;
# expected error <> response
# --error 1000
# select 3 from t1 ;
# !$1000
# --error 1000
# select 3 from t1 ;
# ----------------------------------------------------------------------------
# 4. Switch the abort on error on and check the effect on $mysql_errno
# Switch the abort on error on and check the effect on $mysql_errno
# ----------------------------------------------------------------------------
!$1064
--error 1064
garbage ;
--enable_abort_on_error
eval select $mysql_errno as "after_--enable_abort_on_error" ;
# ----------------------------------------------------------------------------
# 5. masked failing statements
# masked failing statements
# ----------------------------------------------------------------------------
# expected error = response
--error 1146
select 3 from t1 ;
!$1146
select 3 from t1 ;
# ----------------------------------------------------------------------------
# 6. check that the old default behaviour is not changed
# check that the old default behaviour is not changed
# Please remove the '#' to get the abort on error
# ----------------------------------------------------------------------------
#--error 1064
#select 3 from t1 ;
#
#!$1064
#select 3 from t1 ;
#
#select 3 from t1 ;
......@@ -21,7 +21,8 @@ check table t1 changed;
check table t1 medium;
check table t1 extended;
show index from t1;
!$1062 insert into t1 values (5,5,5);
--error 1062
insert into t1 values (5,5,5);
optimize table t1;
optimize table t1;
drop table t1;
......
......@@ -20,8 +20,10 @@ create TEMPORARY TABLE t2 engine=heap select * from t1;
create TEMPORARY TABLE IF NOT EXISTS t2 (a int) engine=heap;
# This should give errors
!$1050 CREATE TEMPORARY TABLE t1 (a int not null, b char (10) not null);
!$1050 ALTER TABLE t1 RENAME t2;
--error 1050
CREATE TEMPORARY TABLE t1 (a int not null, b char (10) not null);
--error 1050
ALTER TABLE t1 RENAME t2;
select * from t2;
alter table t2 add primary key (a,b);
......
......@@ -135,7 +135,8 @@ drop table t1,t2;
create table t1 (c int);
insert into t1 values(1),(2);
create table t2 select * from t1;
!$1060 create table t3 select * from t1, t2; # Should give an error
--error 1060
create table t3 select * from t1, t2; # Should give an error
create table t3 select t1.c AS c1, t2.c AS c2,1 as "const" from t1, t2;
show full columns from t3;
drop table t1,t2,t3;
......
......@@ -5026,12 +5026,12 @@ The minimum value for this variable is 4096.",
"Persistent buffer for query parsing and execution",
(gptr*) &global_system_variables.query_prealloc_size,
(gptr*) &max_system_variables.query_prealloc_size, 0, GET_ULONG,
REQUIRED_ARG, QUERY_ALLOC_PREALLOC_SIZE, 1024, ~0L, 0, 1024, 0},
REQUIRED_ARG, QUERY_ALLOC_PREALLOC_SIZE, 16384, ~0L, 0, 1024, 0},
{"range_alloc_block_size", OPT_RANGE_ALLOC_BLOCK_SIZE,
"Allocation block size for storing ranges during optimization",
(gptr*) &global_system_variables.range_alloc_block_size,
(gptr*) &max_system_variables.range_alloc_block_size, 0, GET_ULONG,
REQUIRED_ARG, RANGE_ALLOC_BLOCK_SIZE, 1024, ~0L, 0, 1024, 0},
REQUIRED_ARG, RANGE_ALLOC_BLOCK_SIZE, 4096, ~0L, 0, 1024, 0},
{"read_buffer_size", OPT_RECORD_BUFFER,
"Each thread that does a sequential scan allocates a buffer of this size for each table it scans. If you do many sequential scans, you may want to increase this value.",
(gptr*) &global_system_variables.read_buff_size,
......
......@@ -53,19 +53,9 @@
#include <errno.h>
#ifdef EMBEDDED_LIBRARY
#undef MYSQL_SERVER
#ifndef MYSQL_CLIENT
#undef MYSQL_CLIENT
#define MYSQL_CLIENT
#endif
#undef net_flush
extern "C" {
my_bool net_flush(NET *net);
}
#endif /*EMBEDDED_LIBRARY */
......
......@@ -470,6 +470,15 @@ void Protocol::init(THD *thd_arg)
}
bool Protocol::flush()
{
#ifndef EMBEDDED_LIBRARY
return net_flush(&thd->net);
#else
return 0;
#endif
}
/*
Send name and type of result to client.
......
......@@ -75,6 +75,7 @@ public:
field_count=item_list->elements;
return 0;
}
virtual bool flush();
virtual void prepare_for_resend()=0;
virtual bool store_null()=0;
......
......@@ -153,6 +153,8 @@ static bool send_prep_stmt(Prepared_statement *stmt, uint columns)
{
NET *net= &stmt->thd->net;
char buff[9];
DBUG_ENTER("send_prep_stmt");
buff[0]= 0; /* OK packet indicator */
int4store(buff+1, stmt->id);
int2store(buff+5, columns);
......@@ -161,12 +163,11 @@ static bool send_prep_stmt(Prepared_statement *stmt, uint columns)
Send types and names of placeholders to the client
XXX: fix this nasty upcast from List<Item_param> to List<Item>
*/
return my_net_write(net, buff, sizeof(buff)) ||
DBUG_RETURN(my_net_write(net, buff, sizeof(buff)) ||
(stmt->param_count &&
stmt->thd->protocol_simple.send_fields((List<Item> *)
&stmt->lex->param_list, 0)) ||
net_flush(net);
return 0;
&stmt->lex->param_list,
0)));
}
#else
static bool send_prep_stmt(Prepared_statement *stmt,
......@@ -1088,7 +1089,7 @@ static int mysql_test_select(Prepared_statement *stmt,
{
if (lex->describe)
{
if (send_prep_stmt(stmt, 0))
if (send_prep_stmt(stmt, 0) || thd->protocol->flush())
goto err_prep;
}
else
......@@ -1106,11 +1107,8 @@ static int mysql_test_select(Prepared_statement *stmt,
prepared in unit->prepare call above.
*/
if (send_prep_stmt(stmt, lex->result->field_count(fields)) ||
lex->result->send_fields(fields, 0)
#ifndef EMBEDDED_LIBRARY
|| net_flush(&thd->net)
#endif
)
lex->result->send_fields(fields, 0) ||
thd->protocol->flush())
goto err_prep;
}
}
......@@ -1389,7 +1387,6 @@ static int send_prepare_results(Prepared_statement *stmt, bool text_protocol)
enum enum_sql_command sql_command= lex->sql_command;
int res= 0;
DBUG_ENTER("send_prepare_results");
DBUG_PRINT("enter",("command: %d, param_count: %ld",
sql_command, stmt->param_count));
......@@ -1475,7 +1472,8 @@ static int send_prepare_results(Prepared_statement *stmt, bool text_protocol)
goto error;
}
if (res == 0)
DBUG_RETURN(text_protocol? 0 : send_prep_stmt(stmt, 0));
DBUG_RETURN(text_protocol? 0 : (send_prep_stmt(stmt, 0) ||
thd->protocol->flush()));
error:
if (res < 0)
send_error(thd, thd->killed ? ER_SERVER_SHUTDOWN : 0);
......
......@@ -1081,7 +1081,7 @@ mysqld_list_fields(THD *thd, TABLE_LIST *table_list, const char *wild)
restore_record(table,default_values); // Get empty record
if (thd->protocol->send_fields(&field_list,2))
DBUG_VOID_RETURN;
net_flush(&thd->net);
thd->protocol->flush();
DBUG_VOID_RETURN;
}
......@@ -1098,13 +1098,11 @@ mysqld_dump_create_info(THD *thd, TABLE *table, int fd)
if (store_create_info(thd, table, packet))
DBUG_RETURN(-1);
//if (protocol->convert)
// protocol->convert->convert((char*) packet->ptr(), packet->length());
if (fd < 0)
{
if (protocol->write())
DBUG_RETURN(-1);
net_flush(&thd->net);
protocol->flush();
}
else
{
......
/* Copyright (C) 2003 MySQL AB
/* Copyright (C) 2003-2004 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -27,6 +27,7 @@
#include <my_getopt.h>
#include <m_string.h>
#define VER "2.0"
#define MAX_TEST_QUERY_LENGTH 300 /* MAX QUERY BUFFER LENGTH */
/* set default options */
......@@ -37,7 +38,7 @@ static char *opt_password= 0;
static char *opt_host= 0;
static char *opt_unix_socket= 0;
static unsigned int opt_port;
static my_bool tty_password= 0;
static my_bool tty_password= 0, opt_silent= 0;
static MYSQL *mysql= 0;
static char query[MAX_TEST_QUERY_LENGTH];
......@@ -52,6 +53,7 @@ static double total_time;
const char *default_dbug_option= "d:t:o,/tmp/client_test.trace";
#define myheader(str) \
if (opt_silent < 2) \
{ \
fprintf(stdout, "\n\n#####################################\n"); \
fprintf(stdout, "%d of (%d/%d): %s", test_count++, iter_count, \
......@@ -59,6 +61,7 @@ const char *default_dbug_option= "d:t:o,/tmp/client_test.trace";
fprintf(stdout, " \n#####################################\n"); \
}
#define myheader_r(str) \
if (!opt_silent) \
{ \
fprintf(stdout, "\n\n#####################################\n"); \
fprintf(stdout, "%s", str); \
......@@ -144,6 +147,8 @@ DIE_UNLESS(stmt == 0);\
static void print_error(const char *msg)
{
if (!opt_silent)
{
if (mysql && mysql_errno(mysql))
{
if (mysql->server_version)
......@@ -152,12 +157,16 @@ static void print_error(const char *msg)
fprintf(stdout, "\n [MySQL]");
fprintf(stdout, "[%d] %s\n", mysql_errno(mysql), mysql_error(mysql));
}
else if (msg) fprintf(stderr, " [MySQL] %s\n", msg);
else if (msg)
fprintf(stderr, " [MySQL] %s\n", msg);
}
}
static void print_st_error(MYSQL_STMT *stmt, const char *msg)
{
if (!opt_silent)
{
if (stmt && mysql_stmt_errno(stmt))
{
if (stmt->mysql && stmt->mysql->server_version)
......@@ -170,6 +179,7 @@ static void print_st_error(MYSQL_STMT *stmt, const char *msg)
}
else if (msg)
fprintf(stderr, " [MySQL] %s\n", msg);
}
}
......@@ -198,6 +208,7 @@ static void client_connect()
int rc;
myheader_r("client_connect");
if (!opt_silent)
fprintf(stdout, "\n Establishing a connection to '%s' ...",
opt_host ? opt_host : "");
......@@ -217,11 +228,13 @@ static void client_connect()
exit(1);
}
if (!opt_silent)
fprintf(stdout, " OK");
/* set AUTOCOMMIT to ON*/
mysql_autocommit(mysql, TRUE);
if (!opt_silent)
fprintf(stdout, "\n Creating a test database '%s' ...", current_db);
strxmov(query, "CREATE DATABASE IF NOT EXISTS ", current_db, NullS);
......@@ -232,6 +245,7 @@ static void client_connect()
rc= mysql_query(mysql, query);
myquery(rc);
if (!opt_silent)
fprintf(stdout, " OK");
}
......@@ -244,12 +258,15 @@ static void client_disconnect()
if (mysql)
{
if (!opt_silent)
fprintf(stdout, "\n dropping the test database '%s' ...", current_db);
strxmov(query, "DROP DATABASE IF EXISTS ", current_db, NullS);
mysql_query(mysql, query);
if (!opt_silent)
fprintf(stdout, " OK");
if (!opt_silent)
fprintf(stdout, "\n closing the connection ...");
mysql_close(mysql);
fprintf(stdout, " OK\n");
......@@ -331,8 +348,11 @@ static void my_print_result_metadata(MYSQL_RES *result)
unsigned int field_count;
mysql_field_seek(result, 0);
if (!opt_silent)
{
fputc('\n', stdout);
fputc('\n', stdout);
}
field_count= mysql_num_fields(result);
for(i= 0; i< field_count; i++)
......@@ -345,18 +365,25 @@ static void my_print_result_metadata(MYSQL_RES *result)
j= 4;
field->max_length= j;
}
if (!opt_silent)
{
my_print_dashes(result);
fputc('\t', stdout);
fputc('|', stdout);
}
mysql_field_seek(result, 0);
for(i= 0; i< field_count; i++)
{
field= mysql_fetch_field(result);
if (!opt_silent)
fprintf(stdout, " %-*s |", (int) field->max_length, field->name);
}
if (!opt_silent)
{
fputc('\n', stdout);
my_print_dashes(result);
}
}
......@@ -377,12 +404,17 @@ int my_process_result_set(MYSQL_RES *result)
while ((row= mysql_fetch_row(result)) != NULL)
{
mysql_field_seek(result, 0);
if (!opt_silent)
{
fputc('\t', stdout);
fputc('|', stdout);
}
for(i= 0; i< mysql_num_fields(result); i++)
{
field= mysql_fetch_field(result);
if (!opt_silent)
{
if (row[i] == NULL)
fprintf(stdout, " %-*s |", (int) field->max_length, "NULL");
else if (IS_NUM(field->type))
......@@ -390,10 +422,16 @@ int my_process_result_set(MYSQL_RES *result)
else
fprintf(stdout, " %-*s |", (int) field->max_length, row[i]);
}
}
if (!opt_silent)
{
fputc('\t', stdout);
fputc('\n', stdout);
}
row_count++;
}
if (!opt_silent)
{
if (row_count)
my_print_dashes(result);
......@@ -402,6 +440,7 @@ int my_process_result_set(MYSQL_RES *result)
else
fprintf(stdout, "\n\t%d %s returned\n", row_count,
row_count == 1 ? "row" : "rows");
}
return row_count;
}
......@@ -469,14 +508,18 @@ int my_process_stmt_result(MYSQL_STMT *stmt)
mysql_field_seek(result, 0);
while (mysql_stmt_fetch(stmt) == 0)
{
if (!opt_silent)
{
fputc('\t', stdout);
fputc('|', stdout);
}
mysql_field_seek(result, 0);
for (i= 0; i < field_count; i++)
{
field= mysql_fetch_field(result);
if (!opt_silent)
{
if (is_null[i])
fprintf(stdout, " %-*s |", (int) field->max_length, "NULL");
else if (length[i] == 0)
......@@ -489,15 +532,21 @@ int my_process_stmt_result(MYSQL_STMT *stmt)
else
fprintf(stdout, " %-*s |", (int) field->max_length, data[i]);
}
}
if (!opt_silent)
{
fputc('\t', stdout);
fputc('\n', stdout);
}
row_count++;
}
if (!opt_silent)
{
if (row_count)
my_print_dashes(result);
fprintf(stdout, "\n\t%d %s returned\n", row_count,
row_count == 1 ? "row" : "rows");
}
mysql_free_result(result);
return row_count;
}
......@@ -511,6 +560,7 @@ int my_stmt_result(const char *buff)
int row_count;
int rc;
if (!opt_silent)
fprintf(stdout, "\n\n %s", buff);
stmt= mysql_simple_prepare(mysql, buff);
check_stmt(stmt);
......@@ -537,6 +587,7 @@ static void verify_col_data(const char *table, const char *col,
if (table && col)
{
strxmov(query, "SELECT ", col, " FROM ", table, " LIMIT 1", NullS);
if (!opt_silent)
fprintf(stdout, "\n %s", query);
rc= mysql_query(mysql, query);
myquery(rc);
......@@ -565,8 +616,10 @@ static void verify_col_data(const char *table, const char *col,
/* Utility function to verify the field members */
static void verify_prepare_field(MYSQL_RES *result,
unsigned int no, const char *name, const char *org_name,
enum enum_field_types type, const char *table,
unsigned int no, const char *name,
const char *org_name,
enum enum_field_types type,
const char *table,
const char *org_table, const char *db,
unsigned long length, const char *def)
{
......@@ -577,6 +630,8 @@ static void verify_prepare_field(MYSQL_RES *result,
fprintf(stdout, "\n *** ERROR: FAILED TO GET THE RESULT ***");
exit(1);
}
if (!opt_silent)
{
fprintf(stdout, "\n field[%d]:", no);
fprintf(stdout, "\n name :`%s`\t(expected: `%s`)", field->name, name);
fprintf(stdout, "\n org_name :`%s`\t(expected: `%s`)",
......@@ -594,6 +649,7 @@ static void verify_prepare_field(MYSQL_RES *result,
fprintf(stdout, "\n default :`%s`\t(expected: `%s`)",
field->def ? field->def : "(null)", def ? def: "(null)");
fprintf(stdout, "\n");
}
DIE_UNLESS(strcmp(field->name, name) == 0);
DIE_UNLESS(strcmp(field->org_name, org_name) == 0);
DIE_UNLESS(field->type == type);
......@@ -611,6 +667,7 @@ static void verify_prepare_field(MYSQL_RES *result,
static void verify_param_count(MYSQL_STMT *stmt, long exp_count)
{
long param_count= mysql_stmt_param_count(stmt);
if (!opt_silent)
fprintf(stdout, "\n total parameters in stmt: `%ld` (expected: `%ld`)",
param_count, exp_count);
DIE_UNLESS(param_count == exp_count);
......@@ -622,6 +679,7 @@ static void verify_param_count(MYSQL_STMT *stmt, long exp_count)
static void verify_st_affected_rows(MYSQL_STMT *stmt, ulonglong exp_count)
{
ulonglong affected_rows= mysql_stmt_affected_rows(stmt);
if (!opt_silent)
fprintf(stdout, "\n total affected rows: `%lld` (expected: `%lld`)",
affected_rows, exp_count);
DIE_UNLESS(affected_rows == exp_count);
......@@ -633,6 +691,7 @@ static void verify_st_affected_rows(MYSQL_STMT *stmt, ulonglong exp_count)
static void verify_affected_rows(ulonglong exp_count)
{
ulonglong affected_rows= mysql_affected_rows(mysql);
if (!opt_silent)
fprintf(stdout, "\n total affected rows: `%lld` (expected: `%lld`)",
affected_rows, exp_count);
DIE_UNLESS(affected_rows == exp_count);
......@@ -644,6 +703,7 @@ static void verify_affected_rows(ulonglong exp_count)
static void verify_field_count(MYSQL_RES *result, uint exp_count)
{
uint field_count= mysql_num_fields(result);
if (!opt_silent)
fprintf(stdout, "\n total fields in the result set: `%d` (expected: `%d`)",
field_count, exp_count);
DIE_UNLESS(field_count == exp_count);
......@@ -665,6 +725,7 @@ static void execute_prepare_query(const char *query, ulonglong exp_count)
myquery(rc);
affected_rows= mysql_stmt_affected_rows(stmt);
if (!opt_silent)
fprintf(stdout, "\n total affected rows: `%lld` (expected: `%lld`)",
affected_rows, exp_count);
......@@ -722,6 +783,7 @@ static my_bool thread_query(char *query)
my_bool error;
error= 0;
if (!opt_silent)
fprintf(stdout, "\n in thread_query(%s)", query);
if (!(l_mysql= mysql_init(NULL)))
{
......@@ -753,6 +815,7 @@ end:
static void test_debug_example()
{
DBUG_ENTER("fill_tables");
int rc;
MYSQL_RES *result;
......@@ -1033,6 +1096,7 @@ static void test_prepare_field_result()
my_print_result_metadata(result);
if (!opt_silent)
fprintf(stdout, "\n\n field attributes:\n");
verify_prepare_field(result, 0, "int_c", "int_c", MYSQL_TYPE_LONG,
"t1", "test_prepare_field_result", current_db, 11, 0);
......@@ -1207,6 +1271,8 @@ static void test_prepare()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
{
fprintf(stdout, "\n");
fprintf(stdout, "\n\t tiny : %d (%lu)", tiny_data, length[0]);
......@@ -1218,6 +1284,7 @@ static void test_prepare()
fprintf(stdout, "\n\t double : %f (%lu)", double_data, length[6]);
fprintf(stdout, "\n\t str : %s (%lu)", str_data, length[1]);
}
DIE_UNLESS(tiny_data == o_tiny_data);
DIE_UNLESS(is_null[0] == 0);
......@@ -1578,10 +1645,12 @@ static void test_fetch_null()
rc++;
for (i= 0; i < 10; i++)
{
if (!opt_silent)
fprintf(stdout, "\n data[%d] : %s", i,
is_null[i] ? "NULL" : "NOT NULL");
DIE_UNLESS(is_null[i]);
}
if (!opt_silent)
fprintf(stdout, "\n data[%d]: %d", i, nData);
DIE_UNLESS(nData == 1000 || nData == 88 || nData == 389789);
DIE_UNLESS(is_null[i] == 0);
......@@ -2367,6 +2436,7 @@ static void test_long_data()
/* execute */
rc= mysql_stmt_execute(stmt);
if (!opt_silent)
fprintf(stdout, " mysql_stmt_execute() returned %d\n", rc);
check_execute(stmt, rc);
......@@ -2450,6 +2520,7 @@ static void test_long_data_str()
}
/* execute */
rc= mysql_stmt_execute(stmt);
if (!opt_silent)
fprintf(stdout, " mysql_stmt_execute() returned %d\n", rc);
check_execute(stmt, rc);
......@@ -2541,6 +2612,7 @@ static void test_long_data_str1()
/* execute */
rc= mysql_stmt_execute(stmt);
if (!opt_silent)
fprintf(stdout, " mysql_stmt_execute() returned %d\n", rc);
check_execute(stmt, rc);
......@@ -2692,6 +2764,7 @@ static void test_long_data_bin()
}
/* execute */
rc= mysql_stmt_execute(stmt);
if (!opt_silent)
fprintf(stdout, " mysql_stmt_execute() returned %d\n", rc);
check_execute(stmt, rc);
......@@ -2999,6 +3072,7 @@ static void test_bind_result()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n row 1: %d, %s(%lu)", nData, szData, length1);
DIE_UNLESS(nData == 10);
DIE_UNLESS(strcmp(szData, "venu") == 0);
......@@ -3007,6 +3081,7 @@ static void test_bind_result()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n row 2: %d, %s(%lu)", nData, szData, length1);
DIE_UNLESS(nData == 20);
DIE_UNLESS(strcmp(szData, "MySQL") == 0);
......@@ -3016,7 +3091,7 @@ static void test_bind_result()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (is_null[0])
if (!opt_silent && is_null[0])
fprintf(stdout, "\n row 3: NULL, %s(%lu)", szData, length1);
DIE_UNLESS(is_null[0]);
DIE_UNLESS(strcmp(szData, "monty") == 0);
......@@ -3114,6 +3189,8 @@ static void test_bind_result_ext()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
{
fprintf(stdout, "\n data (tiny) : %d", t_data);
fprintf(stdout, "\n data (short) : %d", s_data);
fprintf(stdout, "\n data (int) : %d", i_data);
......@@ -3126,7 +3203,7 @@ static void test_bind_result_ext()
bData[bLength]= '\0'; /* bData is binary */
fprintf(stdout, "\n data (bin) : %s(%lu)", bData, bLength);
}
DIE_UNLESS(t_data == 19);
DIE_UNLESS(s_data == 2999);
......@@ -3234,6 +3311,8 @@ static void test_bind_result_ext1()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
{
fprintf(stdout, "\n data (tiny) : %s(%lu)", t_data, length[0]);
fprintf(stdout, "\n data (short) : %f(%lu)", s_data, length[1]);
fprintf(stdout, "\n data (int) : %d(%lu)", i_data, length[2]);
......@@ -3244,6 +3323,7 @@ static void test_bind_result_ext1()
fprintf(stdout, "\n data (bin) : %ld(%lu)", bData, length[6]);
fprintf(stdout, "\n data (str) : %g(%lu)", szData, length[7]);
}
DIE_UNLESS(strcmp(t_data, "120") == 0);
DIE_UNLESS(i_data == 3999);
......@@ -3368,6 +3448,8 @@ static void bind_fetch(int row_count)
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
{
fprintf(stdout, "\n");
fprintf(stdout, "\n tiny : %ld(%lu)", (ulong) i8_data, length[0]);
fprintf(stdout, "\n short : %ld(%lu)", (ulong) i16_data, length[1]);
......@@ -3376,7 +3458,7 @@ static void bind_fetch(int row_count)
fprintf(stdout, "\n float : %f(%lu)", f_data, length[4]);
fprintf(stdout, "\n double : %g(%lu)", d_data, length[5]);
fprintf(stdout, "\n char : %s(%lu)", s_data, length[6]);
}
rc= 10+row_count;
/* TINY */
......@@ -3518,6 +3600,8 @@ static void test_fetch_date()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
{
fprintf(stdout, "\n date : %s(%lu)", date, d_length);
fprintf(stdout, "\n time : %s(%lu)", time, t_length);
fprintf(stdout, "\n ts : %s(%lu)", ts, ts_length);
......@@ -3525,6 +3609,7 @@ static void test_fetch_date()
fprintf(stdout, "\n dt : %s(%lu)", dt, dt_length);
fprintf(stdout, "\n ts(4) : %s(%lu)", ts_4, ts4_length);
fprintf(stdout, "\n ts(6) : %s(%lu)", ts_6, ts6_length);
}
DIE_UNLESS(strcmp(date, "2002-01-02") == 0);
DIE_UNLESS(d_length == 10);
......@@ -3851,6 +3936,7 @@ static void test_field_names()
myheader("test_field_names");
if (!opt_silent)
fprintf(stdout, "\n %d, %d, %d", MYSQL_TYPE_DECIMAL, MYSQL_TYPE_NEWDATE, MYSQL_TYPE_ENUM);
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_field_names1");
myquery(rc);
......@@ -3902,6 +3988,7 @@ static void test_warnings()
rc= mysql_query(mysql, "DROP TABLE if exists test_non_exists");
myquery(rc);
if (!opt_silent)
fprintf(stdout, "\n total warnings: %d", mysql_warning_count(mysql));
rc= mysql_query(mysql, "SHOW WARNINGS");
myquery(rc);
......@@ -4084,11 +4171,14 @@ static void test_field_flags()
mytest(result);
mysql_field_seek(result, 0);
if (!opt_silent)
fputc('\n', stdout);
for(i= 0; i< mysql_num_fields(result); i++)
{
field= mysql_fetch_field(result);
if (!opt_silent)
{
fprintf(stdout, "\n field:%d", i);
if (field->flags & NOT_NULL_FLAG)
fprintf(stdout, "\n NOT_NULL_FLAG");
......@@ -4102,6 +4192,7 @@ static void test_field_flags()
fprintf(stdout, "\n AUTO_INCREMENT_FLAG");
}
}
mysql_free_result(result);
}
......@@ -4119,6 +4210,7 @@ static void test_stmt_close()
myheader("test_stmt_close");
if (!opt_silent)
fprintf(stdout, "\n Establishing a test connection ...");
if (!(lmysql= mysql_init(NULL)))
{
......@@ -4132,6 +4224,7 @@ static void test_stmt_close()
myerror("connection failed");
exit(1);
}
if (!opt_silent)
fprintf(stdout, " OK");
......@@ -4169,6 +4262,7 @@ static void test_stmt_close()
verify_param_count(stmt2, 1);
rc= mysql_stmt_close(stmt1);
if (!opt_silent)
fprintf(stdout, "\n mysql_close_stmt(1) returned: %d", rc);
DIE_UNLESS(rc == 0);
......@@ -4203,6 +4297,7 @@ static void test_stmt_close()
verify_st_affected_rows(stmt_x, 1);
rc= mysql_stmt_close(stmt_x);
if (!opt_silent)
fprintf(stdout, "\n mysql_close_stmt(x) returned: %d", rc);
DIE_UNLESS( rc == 0);
......@@ -4262,6 +4357,7 @@ static void test_set_variable()
rc= mysql_stmt_fetch(stmt1);
check_execute(stmt1, rc);
if (!opt_silent)
fprintf(stdout, "\n max_error_count(default): %d", get_count);
def_count= get_count;
......@@ -4292,6 +4388,7 @@ static void test_set_variable()
rc= mysql_stmt_fetch(stmt1);
check_execute(stmt1, rc);
if (!opt_silent)
fprintf(stdout, "\n max_error_count : %d", get_count);
DIE_UNLESS(get_count == set_count);
......@@ -4309,6 +4406,7 @@ static void test_set_variable()
rc= mysql_stmt_fetch(stmt1);
check_execute(stmt1, rc);
if (!opt_silent)
fprintf(stdout, "\n max_error_count(default): %d", get_count);
DIE_UNLESS(get_count == set_count);
......@@ -4367,11 +4465,13 @@ static void test_insert_meta()
mysql_field_seek(result, 0);
field= mysql_fetch_field(result);
mytest(field);
if (!opt_silent)
fprintf(stdout, "\n obtained: `%s` (expected: `%s`)", field->name, "col1");
DIE_UNLESS(strcmp(field->name, "col1") == 0);
field= mysql_fetch_field(result);
mytest(field);
if (!opt_silent)
fprintf(stdout, "\n obtained: `%s` (expected: `%s`)", field->name, "col3");
DIE_UNLESS(strcmp(field->name, "col3") == 0);
......@@ -4429,15 +4529,21 @@ static void test_update_meta()
mysql_field_seek(result, 0);
field= mysql_fetch_field(result);
mytest(field);
if (!opt_silent)
{
fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col1");
fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_update");
}
DIE_UNLESS(strcmp(field->name, "col1") == 0);
DIE_UNLESS(strcmp(field->table, "test_prep_update") == 0);
field= mysql_fetch_field(result);
mytest(field);
if (!opt_silent)
{
fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col3");
fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_update");
}
DIE_UNLESS(strcmp(field->name, "col3") == 0);
DIE_UNLESS(strcmp(field->table, "test_prep_update") == 0);
......@@ -4493,15 +4599,21 @@ static void test_select_meta()
mysql_field_seek(result, 0);
field= mysql_fetch_field(result);
mytest(field);
if (!opt_silent)
{
fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col1");
fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_select");
}
DIE_UNLESS(strcmp(field->name, "col1") == 0);
DIE_UNLESS(strcmp(field->table, "test_prep_select") == 0);
field= mysql_fetch_field(result);
mytest(field);
if (!opt_silent)
{
fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col2");
fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_select");
}
DIE_UNLESS(strcmp(field->name, "col2") == 0);
DIE_UNLESS(strcmp(field->table, "test_prep_select") == 0);
......@@ -4545,6 +4657,7 @@ static void test_func_fields()
field= mysql_fetch_field(result);
mytest(field);
if (!opt_silent)
fprintf(stdout, "\n table name: `%s` (expected: `%s`)", field->table,
"test_dateformat");
DIE_UNLESS(strcmp(field->table, "test_dateformat") == 0);
......@@ -4563,6 +4676,7 @@ static void test_func_fields()
field= mysql_fetch_field(result);
mytest(field);
if (!opt_silent)
fprintf(stdout, "\n table name: `%s` (expected: `%s`)", field->table, "");
DIE_UNLESS(field->table[0] == '\0');
......@@ -4580,8 +4694,11 @@ static void test_func_fields()
field= mysql_fetch_field(result);
mytest(field);
fprintf(stdout, "\n field name: `%s` (expected: `%s`)", field->name, "YEAR");
fprintf(stdout, "\n field org name: `%s` (expected: `%s`)", field->org_name, "");
if (!opt_silent)
{
printf("\n field name: `%s` (expected: `%s`)", field->name, "YEAR");
printf("\n field org name: `%s` (expected: `%s`)", field->org_name, "");
}
DIE_UNLESS(strcmp(field->name, "YEAR") == 0);
DIE_UNLESS(field->org_name[0] == '\0');
......@@ -4658,8 +4775,11 @@ static void test_multi_stmt()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
{
fprintf(stdout, "\n int_data: %lu(%lu)", (ulong) id, length[0]);
fprintf(stdout, "\n str_data: %s(%lu)", name, length[1]);
}
DIE_UNLESS(id == 10);
DIE_UNLESS(strcmp(name, "mysql") == 0);
......@@ -4687,8 +4807,11 @@ static void test_multi_stmt()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
{
fprintf(stdout, "\n int_data: %lu(%lu)", (ulong) id, length[0]);
fprintf(stdout, "\n str_data: %s(%lu)", name, length[1]);
}
DIE_UNLESS(id == 10);
DIE_UNLESS(strcmp(name, "updated") == 0);
......@@ -4762,11 +4885,13 @@ static void test_manual_sample()
fprintf(stderr, "\n %s", mysql_error(mysql));
exit(1);
}
if (!opt_silent)
fprintf(stdout, "\n prepare, insert successful");
/* Get the parameter count from the statement */
param_count= mysql_stmt_param_count(stmt);
if (!opt_silent)
fprintf(stdout, "\n total parameters in insert: %d", param_count);
if (param_count != 3) /* validate parameter count */
{
......@@ -4823,6 +4948,7 @@ static void test_manual_sample()
/* Get the total rows affected */
affected_rows= mysql_stmt_affected_rows(stmt);
if (!opt_silent)
fprintf(stdout, "\n total affected rows: %lld", affected_rows);
if (affected_rows != 1) /* validate affected rows */
{
......@@ -4847,6 +4973,7 @@ static void test_manual_sample()
/* Get the total rows affected */
affected_rows= mysql_stmt_affected_rows(stmt);
if (!opt_silent)
fprintf(stdout, "\n total affected rows: %lld", affected_rows);
if (affected_rows != 1) /* validate affected rows */
{
......@@ -4871,6 +4998,7 @@ static void test_manual_sample()
fprintf(stderr, "\n %s", mysql_error(mysql));
exit(1);
}
if (!opt_silent)
fprintf(stdout, "Success !!!");
}
......@@ -4993,13 +5121,14 @@ DROP TABLE IF EXISTS test_multi_tab";
for (count= 0 ; count < array_elements(rows) ; count++)
{
if (!opt_silent)
fprintf(stdout, "\n Query %d: ", count);
if ((result= mysql_store_result(mysql_local)))
{
(void) my_process_result_set(result);
mysql_free_result(result);
}
else
else if (!opt_silent)
fprintf(stdout, "OK, %lld row(s) affected, %d warning(s)\n",
mysql_affected_rows(mysql_local),
mysql_warning_count(mysql_local));
......@@ -5007,7 +5136,7 @@ DROP TABLE IF EXISTS test_multi_tab";
exp_value= (uint) mysql_affected_rows(mysql_local);
if (rows[count] != exp_value)
{
fprintf(stdout, "row %d had affected rows: %d, should be %d\n",
fprintf(stderr, "row %d had affected rows: %d, should be %d\n",
count, exp_value, rows[count]);
exit(1);
}
......@@ -5083,7 +5212,7 @@ static void test_prepare_multi_statements()
if (!(mysql_local= mysql_init(NULL)))
{
fprintf(stdout, "\n mysql_init() failed");
fprintf(stderr, "\n mysql_init() failed");
exit(1);
}
......@@ -5091,7 +5220,7 @@ static void test_prepare_multi_statements()
opt_password, current_db, opt_port,
opt_unix_socket, CLIENT_MULTI_STATEMENTS)))
{
fprintf(stdout, "\n connection failed(%s)", mysql_error(mysql_local));
fprintf(stderr, "\n connection failed(%s)", mysql_error(mysql_local));
exit(1);
}
strmov(query, "select 1; select 'another value'");
......@@ -5159,6 +5288,7 @@ static void test_store_result()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n row 1: %ld, %s(%lu)", (long) nData, szData, length1);
DIE_UNLESS(nData == 10);
DIE_UNLESS(strcmp(szData, "venu") == 0);
......@@ -5167,6 +5297,7 @@ static void test_store_result()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n row 2: %ld, %s(%lu)", (long) nData, szData, length1);
DIE_UNLESS(nData == 20);
DIE_UNLESS(strcmp(szData, "mysql") == 0);
......@@ -5176,7 +5307,7 @@ static void test_store_result()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (is_null[0])
if (!opt_silent && is_null[0])
fprintf(stdout, "\n row 3: NULL, %s(%lu)", szData, length1);
DIE_UNLESS(is_null[0]);
DIE_UNLESS(strcmp(szData, "monty") == 0);
......@@ -5194,6 +5325,7 @@ static void test_store_result()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n row 1: %ld, %s(%lu)", (long) nData, szData, length1);
DIE_UNLESS(nData == 10);
DIE_UNLESS(strcmp(szData, "venu") == 0);
......@@ -5202,6 +5334,7 @@ static void test_store_result()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n row 2: %ld, %s(%lu)", (long) nData, szData, length1);
DIE_UNLESS(nData == 20);
DIE_UNLESS(strcmp(szData, "mysql") == 0);
......@@ -5211,7 +5344,7 @@ static void test_store_result()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (is_null[0])
if (!opt_silent && is_null[0])
fprintf(stdout, "\n row 3: NULL, %s(%lu)", szData, length1);
DIE_UNLESS(is_null[0]);
DIE_UNLESS(strcmp(szData, "monty") == 0);
......@@ -5260,6 +5393,7 @@ static void test_store_result1()
rc= 0;
while (mysql_stmt_fetch(stmt) != MYSQL_NO_DATA)
rc++;
if (!opt_silent)
fprintf(stdout, "\n total rows: %d", rc);
DIE_UNLESS(rc == 3);
......@@ -5272,6 +5406,7 @@ static void test_store_result1()
rc= 0;
while (mysql_stmt_fetch(stmt) != MYSQL_NO_DATA)
rc++;
if (!opt_silent)
fprintf(stdout, "\n total rows: %d", rc);
DIE_UNLESS(rc == 3);
......@@ -5338,6 +5473,7 @@ static void test_store_result2()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n row 1: %d", nData);
DIE_UNLESS(nData == 10);
......@@ -5355,6 +5491,7 @@ static void test_store_result2()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n row 1: %d", nData);
DIE_UNLESS(nData == 20);
......@@ -5458,6 +5595,7 @@ static void test_subselect()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n row 1: %d", id);
DIE_UNLESS(id == 1);
......@@ -5471,6 +5609,7 @@ static void test_subselect()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n row 1: %d", id);
DIE_UNLESS(id == 0);
......@@ -5587,21 +5726,21 @@ static void test_bind_date_conv(uint row_count)
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n");
for (i= 0; i < array_elements(bind); i++)
{
fprintf(stdout, "\n");
fprintf(stdout, " time[%d]: %02d-%02d-%02d %02d:%02d:%02d.%02lu",
if (!opt_silent)
fprintf(stdout, "\ntime[%d]: %02d-%02d-%02d %02d:%02d:%02d.%02lu",
i, tm[i].year, tm[i].month, tm[i].day,
tm[i].hour, tm[i].minute, tm[i].second,
tm[i].second_part);
DIE_UNLESS(tm[i].year == 0 || tm[i].year == year+count);
DIE_UNLESS(tm[i].month == 0 || tm[i].month == month+count);
DIE_UNLESS(tm[i].day == 0 || tm[i].day == day+count);
DIE_UNLESS(tm[i].hour == 0 || tm[i].hour == hour+count);
#if 0
#ifdef NOT_USED
/*
minute causes problems from date<->time, don't assert, instead
validate separatly in another routine
......@@ -5856,6 +5995,7 @@ static void test_buffers()
buffer[1]= 'X';
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n data: %s (%lu)", buffer, length);
DIE_UNLESS(buffer[0] == 'M');
DIE_UNLESS(buffer[1] == 'X');
......@@ -5867,6 +6007,7 @@ static void test_buffers()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n data: %s (%lu)", buffer, length);
DIE_UNLESS(strncmp(buffer, "Database", 8) == 0);
DIE_UNLESS(length == 8);
......@@ -5877,6 +6018,7 @@ static void test_buffers()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n data: %s (%lu)", buffer, length);
DIE_UNLESS(strcmp(buffer, "Open-Source") == 0);
DIE_UNLESS(length == 11);
......@@ -5887,6 +6029,7 @@ static void test_buffers()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n data: %s (%lu)", buffer, length);
DIE_UNLESS(strncmp(buffer, "Popula", 6) == 0);
DIE_UNLESS(length == 7);
......@@ -6018,6 +6161,7 @@ static void test_fetch_nobuffs()
while (mysql_stmt_fetch(stmt) != MYSQL_NO_DATA)
rc++;
if (!opt_silent)
fprintf(stdout, "\n total rows : %d", rc);
DIE_UNLESS(rc == 1);
......@@ -6041,11 +6185,15 @@ static void test_fetch_nobuffs()
while (mysql_stmt_fetch(stmt) != MYSQL_NO_DATA)
{
rc++;
if (!opt_silent)
{
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]);
}
}
if (!opt_silent)
fprintf(stdout, "\n total rows : %d", rc);
DIE_UNLESS(rc == 1);
......@@ -6113,10 +6261,13 @@ static void test_ushort_bug()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
{
fprintf(stdout, "\n ushort : %d (%ld)", short_value, s_length);
fprintf(stdout, "\n ulong : %lu (%ld)", (ulong) long_value, l_length);
fprintf(stdout, "\n longlong : %lld (%ld)", longlong_value, ll_length);
fprintf(stdout, "\n tinyint : %d (%ld)", tiny_value, t_length);
}
DIE_UNLESS(short_value == 35999);
DIE_UNLESS(s_length == 2);
......@@ -6197,10 +6348,13 @@ static void test_sshort_bug()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
{
fprintf(stdout, "\n sshort : %d (%ld)", short_value, s_length);
fprintf(stdout, "\n slong : %ld (%ld)", (long) long_value, l_length);
fprintf(stdout, "\n longlong : %lld (%ld)", longlong_value, ll_length);
fprintf(stdout, "\n tinyint : %d (%ld)", tiny_value, t_length);
}
DIE_UNLESS(short_value == -5999);
DIE_UNLESS(s_length == 2);
......@@ -6281,10 +6435,13 @@ static void test_stiny_bug()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
{
fprintf(stdout, "\n sshort : %d (%ld)", short_value, s_length);
fprintf(stdout, "\n slong : %ld (%ld)", (long) long_value, l_length);
fprintf(stdout, "\n longlong : %lld (%ld)", longlong_value, ll_length);
fprintf(stdout, "\n tinyint : %d (%ld)", tiny_value, t_length);
}
DIE_UNLESS(short_value == -128);
DIE_UNLESS(s_length == 2);
......@@ -6373,6 +6530,7 @@ static void test_field_misc()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n default table type: %s(%ld)", table_type, type_length);
rc= mysql_stmt_fetch(stmt);
......@@ -6493,6 +6651,7 @@ static void test_set_option()
rc= mysql_query(mysql, "INSERT INTO test_limit VALUES(10), (20), (30), (40)");
myquery(rc);
if (!opt_silent)
fprintf(stdout, "\n with SQL_SELECT_LIMIT= 2 (direct)");
rc= mysql_query(mysql, "SELECT * FROM test_limit");
myquery(rc);
......@@ -6505,6 +6664,7 @@ static void test_set_option()
mysql_free_result(result);
if (!opt_silent)
fprintf(stdout, "\n with SQL_SELECT_LIMIT=2 (prepare)");
stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_limit");
check_stmt(stmt);
......@@ -6518,6 +6678,7 @@ static void test_set_option()
mysql_stmt_close(stmt);
/* RESET the LIMIT the rows count to 0 */
if (!opt_silent)
fprintf(stdout, "\n with SQL_SELECT_LIMIT=DEFAULT (prepare)");
rc= mysql_query(mysql, "SET OPTION SQL_SELECT_LIMIT=DEFAULT");
myquery(rc);
......@@ -6576,6 +6737,7 @@ static void test_prepare_grant()
MYSQL *org_mysql= mysql, *lmysql;
MYSQL_STMT *stmt;
if (!opt_silent)
fprintf(stdout, "\n Establishing a test connection ...");
if (!(lmysql= mysql_init(NULL)))
{
......@@ -6590,6 +6752,7 @@ static void test_prepare_grant()
mysql_close(lmysql);
exit(1);
}
if (!opt_silent)
fprintf(stdout, " OK");
mysql= lmysql;
......@@ -6677,6 +6840,7 @@ static void test_frm_bug()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n data directory: %s", data_dir);
rc= mysql_stmt_fetch(stmt);
......@@ -6684,6 +6848,7 @@ static void test_frm_bug()
strxmov(test_frm, data_dir, "/", current_db, "/", "test_frm_bug.frm", NullS);
if (!opt_silent)
fprintf(stdout, "\n test_frm: %s", test_frm);
if (!(test_file= my_fopen(test_frm, (int) (O_RDWR | O_CREAT), MYF(MY_WME))))
......@@ -6692,6 +6857,7 @@ static void test_frm_bug()
fprintf(stdout, "\n test cancelled");
exit(1);
}
if (!opt_silent)
fprintf(test_file, "this is a junk file for test");
rc= mysql_query(mysql, "SHOW TABLE STATUS like 'test_frm_bug'");
......@@ -6708,6 +6874,7 @@ static void test_frm_bug()
row= mysql_fetch_row(result);
mytest(row);
if (!opt_silent)
fprintf(stdout, "\n Comment: %s", row[17]);
DIE_UNLESS(row[17] != 0);
......@@ -6771,6 +6938,7 @@ static void test_decimal_bug()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n data: %s", data);
DIE_UNLESS(strcmp(data, "8.00") == 0);
......@@ -6788,6 +6956,7 @@ static void test_decimal_bug()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n data: %s", data);
DIE_UNLESS(strcmp(data, "5.61") == 0);
......@@ -6812,6 +6981,7 @@ static void test_decimal_bug()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n data: %s", data);
DIE_UNLESS(strcmp(data, "10.22") == 0);
......@@ -6852,6 +7022,7 @@ static void test_explain_bug()
result= mysql_stmt_result_metadata(stmt);
mytest(result);
if (!opt_silent)
fprintf(stdout, "\n total fields in the result: %d",
mysql_num_fields(result));
DIE_UNLESS(6 == mysql_num_fields(result));
......@@ -6889,6 +7060,7 @@ static void test_explain_bug()
result= mysql_stmt_result_metadata(stmt);
mytest(result);
if (!opt_silent)
fprintf(stdout, "\n total fields in the result: %d",
mysql_num_fields(result));
DIE_UNLESS(10 == mysql_num_fields(result));
......@@ -6911,8 +7083,12 @@ static void test_explain_bug()
verify_prepare_field(result, 5, "key", "", MYSQL_TYPE_VAR_STRING,
"", "", "", NAME_LEN, 0);
verify_prepare_field(result, 6, "key_len", "", MYSQL_TYPE_LONGLONG,
"", "", "", 3, 0);
verify_prepare_field(result, 6, "key_len", "",
(mysql_get_server_version(mysql) <= 50000 ?
MYSQL_TYPE_LONGLONG : MYSQL_TYPE_VAR_STRING),
"", "", "",
(mysql_get_server_version(mysql) <= 50000 ? 3 : 4096),
0);
verify_prepare_field(result, 7, "ref", "", MYSQL_TYPE_VAR_STRING,
"", "", "", NAME_LEN*16, 0);
......@@ -6938,11 +7114,14 @@ static void test_explain_bug()
static void check_errcode(const unsigned int err)
{
if (!opt_silent || mysql_errno(mysql) != err)
{
if (mysql->server_version)
fprintf(stdout, "\n [MySQL-%s]", mysql->server_version);
else
fprintf(stdout, "\n [MySQL]");
fprintf(stdout, "[%d] %s\n", mysql_errno(mysql), mysql_error(mysql));
}
DIE_UNLESS(mysql_errno(mysql) == err);
}
......@@ -6988,6 +7167,7 @@ static void test_drop_temp()
{
MYSQL *org_mysql= mysql, *lmysql;
if (!opt_silent)
fprintf(stdout, "\n Establishing a test connection ...");
if (!(lmysql= mysql_init(NULL)))
{
......@@ -7007,6 +7187,7 @@ static void test_drop_temp()
mysql_close(lmysql);
exit(1);
}
if (!opt_silent)
fprintf(stdout, " OK");
mysql= lmysql;
......@@ -7076,6 +7257,7 @@ static void test_cuted_rows()
myquery(rc);
count= mysql_warning_count(mysql);
if (!opt_silent)
fprintf(stdout, "\n total warnings: %d", count);
DIE_UNLESS(count == 0);
......@@ -7083,6 +7265,7 @@ static void test_cuted_rows()
myquery(rc);
count= mysql_warning_count(mysql);
if (!opt_silent)
fprintf(stdout, "\n total warnings: %d", count);
DIE_UNLESS(count == 2);
......@@ -7100,6 +7283,7 @@ static void test_cuted_rows()
myquery(rc);
count= mysql_warning_count(mysql);
if (!opt_silent)
fprintf(stdout, "\n total warnings: %d", count);
DIE_UNLESS(count == 2);
......@@ -7213,8 +7397,11 @@ static void test_logs()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
{
fprintf(stdout, "\n id : %d", id);
fprintf(stdout, "\n name : %s(%ld)", data, length);
}
DIE_UNLESS(id == 9876);
DIE_UNLESS(length == 19); /* Due to VARCHAR(20) */
......@@ -7223,6 +7410,7 @@ static void test_logs()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n name : %s(%ld)", data, length);
DIE_UNLESS(length == 1);
......@@ -7231,6 +7419,7 @@ static void test_logs()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n name : %s(%ld)", data, length);
DIE_UNLESS(length == 1);
......@@ -7239,6 +7428,7 @@ static void test_logs()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n name : %s(%ld)", data, length);
DIE_UNLESS(length == 7);
......@@ -7247,6 +7437,7 @@ static void test_logs()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n name : %s(%ld)", data, length);
DIE_UNLESS(length == 7);
......@@ -7293,6 +7484,7 @@ static void test_nstmts()
for (i= 0; i < total_stmts; i++)
{
if (!opt_silent)
fprintf(stdout, "\r stmt: %d", i);
strmov(query, "insert into test_nstmts values(?)");
......@@ -7320,6 +7512,7 @@ static void test_nstmts()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n total rows: %d", i);
DIE_UNLESS( i == total_stmts);
......@@ -7386,6 +7579,7 @@ static void test_fetch_seek()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n row 0: %ld, %s, %s", (long) c1, c2, c3);
row= mysql_stmt_row_tell(stmt);
......@@ -7395,6 +7589,7 @@ static void test_fetch_seek()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n row 2: %ld, %s, %s", (long) c1, c2, c3);
row= mysql_stmt_row_seek(stmt, row);
......@@ -7402,6 +7597,7 @@ static void test_fetch_seek()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n row 2: %ld, %s, %s", (long) c1, c2, c3);
mysql_stmt_data_seek(stmt, 0);
......@@ -7409,6 +7605,7 @@ static void test_fetch_seek()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n row 0: %ld, %s, %s", (long) c1, c2, c3);
rc= mysql_stmt_fetch(stmt);
......@@ -7477,16 +7674,19 @@ static void test_fetch_offset()
data[0]= '\0';
rc= mysql_stmt_fetch_column(stmt, bind, 0, 0);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n col 1: %s (%ld)", data, length);
DIE_UNLESS(strncmp(data, "abcd", 4) == 0 && length == 10);
rc= mysql_stmt_fetch_column(stmt, bind, 0, 5);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n col 1: %s (%ld)", data, length);
DIE_UNLESS(strncmp(data, "fg", 2) == 0 && length == 10);
rc= mysql_stmt_fetch_column(stmt, bind, 0, 9);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n col 0: %s (%ld)", data, length);
DIE_UNLESS(strncmp(data, "j", 1) == 0 && length == 10);
......@@ -7560,6 +7760,7 @@ static void test_fetch_column()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n row 0: %d, %s", bc1, bc2);
c2[0]= '\0'; l2= 0;
......@@ -7571,12 +7772,14 @@ static void test_fetch_column()
rc= mysql_stmt_fetch_column(stmt, bind, 1, 0);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n col 1: %s(%ld)", c2, l2);
DIE_UNLESS(strncmp(c2, "venu", 4) == 0 && l2 == 4);
c2[0]= '\0'; l2= 0;
rc= mysql_stmt_fetch_column(stmt, bind, 1, 0);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n col 1: %s(%ld)", c2, l2);
DIE_UNLESS(strcmp(c2, "venu") == 0 && l2 == 4);
......@@ -7589,12 +7792,14 @@ static void test_fetch_column()
rc= mysql_stmt_fetch_column(stmt, bind, 0, 0);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n col 0: %d(%ld)", c1, l1);
DIE_UNLESS(c1 == 1 && l1 == 4);
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n row 1: %d, %s", bc1, bc2);
c2[0]= '\0'; l2= 0;
......@@ -7606,12 +7811,14 @@ static void test_fetch_column()
rc= mysql_stmt_fetch_column(stmt, bind, 1, 0);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n col 1: %s(%ld)", c2, l2);
DIE_UNLESS(strncmp(c2, "mysq", 4) == 0 && l2 == 5);
c2[0]= '\0'; l2= 0;
rc= mysql_stmt_fetch_column(stmt, bind, 1, 0);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n col 1: %si(%ld)", c2, l2);
DIE_UNLESS(strcmp(c2, "mysql") == 0 && l2 == 5);
......@@ -7624,6 +7831,7 @@ static void test_fetch_column()
rc= mysql_stmt_fetch_column(stmt, bind, 0, 0);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n col 0: %d(%ld)", c1, l1);
DIE_UNLESS(c1 == 2 && l1 == 4);
......@@ -7678,7 +7886,6 @@ static void test_mem_overun()
MYSQL_RES *field_res;
int rc, i, length;
myheader("test_mem_overun");
/*
......@@ -7728,6 +7935,7 @@ static void test_mem_overun()
field_res= mysql_stmt_result_metadata(stmt);
mytest(field_res);
if (!opt_silent)
fprintf(stdout, "\n total fields : %d", mysql_num_fields(field_res));
DIE_UNLESS( 1000 == mysql_num_fields(field_res));
......@@ -7795,6 +8003,7 @@ static void test_free_result()
rc= mysql_stmt_fetch_column(stmt, bind, 0, 0);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n col 0: %s(%ld)", c2, l2);
DIE_UNLESS(strncmp(c2, "1", 1) == 0 && l2 == 1);
......@@ -7810,6 +8019,7 @@ static void test_free_result()
rc= mysql_stmt_fetch_column(stmt, bind, 0, 0);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n col 0: %d(%ld)", c1, l2);
DIE_UNLESS(c1 == 2 && l2 == 4);
......@@ -7877,6 +8087,7 @@ static void test_free_store_result()
rc= mysql_stmt_fetch_column(stmt, bind, 0, 0);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n col 1: %s(%ld)", c2, l2);
DIE_UNLESS(strncmp(c2, "1", 1) == 0 && l2 == 1);
......@@ -7892,6 +8103,7 @@ static void test_free_store_result()
rc= mysql_stmt_fetch_column(stmt, bind, 0, 0);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "\n col 0: %d(%ld)", c1, l2);
DIE_UNLESS(c1 == 2 && l2 == 4);
......@@ -7924,15 +8136,18 @@ static void test_sqlmode()
/* PIPES_AS_CONCAT */
strcpy(query, "SET SQL_MODE= \"PIPES_AS_CONCAT\"");
if (!opt_silent)
fprintf(stdout, "\n With %s", query);
rc= mysql_query(mysql, query);
myquery(rc);
strcpy(query, "INSERT INTO test_piping VALUES(?||?)");
if (!opt_silent)
fprintf(stdout, "\n query: %s", query);
stmt= mysql_simple_prepare(mysql, query);
check_stmt(stmt);
if (!opt_silent)
fprintf(stdout, "\n total parameters: %ld", mysql_stmt_param_count(stmt));
/*
......@@ -7963,20 +8178,24 @@ static void test_sqlmode()
myquery(rc);
strcpy(query, "SELECT connection_id ()");
if (!opt_silent)
fprintf(stdout, "\n query: %s", query);
stmt= mysql_simple_prepare(mysql, query);
check_stmt_r(stmt);
/* ANSI */
strcpy(query, "SET SQL_MODE= \"ANSI\"");
if (!opt_silent)
fprintf(stdout, "\n With %s", query);
rc= mysql_query(mysql, query);
myquery(rc);
strcpy(query, "INSERT INTO test_piping VALUES(?||?)");
if (!opt_silent)
fprintf(stdout, "\n query: %s", query);
stmt= mysql_simple_prepare(mysql, query);
check_stmt(stmt);
if (!opt_silent)
fprintf(stdout, "\n total parameters: %ld", mysql_stmt_param_count(stmt));
rc= mysql_stmt_bind_param(stmt, bind);
......@@ -7991,6 +8210,7 @@ static void test_sqlmode()
/* ANSI mode spaces ... */
strcpy(query, "SELECT connection_id ()");
if (!opt_silent)
fprintf(stdout, "\n query: %s", query);
stmt= mysql_simple_prepare(mysql, query);
check_stmt(stmt);
......@@ -8003,17 +8223,20 @@ static void test_sqlmode()
rc= mysql_stmt_fetch(stmt);
DIE_UNLESS(rc == MYSQL_NO_DATA);
if (!opt_silent)
fprintf(stdout, "\n returned 1 row\n");
mysql_stmt_close(stmt);
/* IGNORE SPACE MODE */
strcpy(query, "SET SQL_MODE= \"IGNORE_SPACE\"");
if (!opt_silent)
fprintf(stdout, "\n With %s", query);
rc= mysql_query(mysql, query);
myquery(rc);
strcpy(query, "SELECT connection_id ()");
if (!opt_silent)
fprintf(stdout, "\n query: %s", query);
stmt= mysql_simple_prepare(mysql, query);
check_stmt(stmt);
......@@ -8026,6 +8249,7 @@ static void test_sqlmode()
rc= mysql_stmt_fetch(stmt);
DIE_UNLESS(rc == MYSQL_NO_DATA);
if (!opt_silent)
fprintf(stdout, "\n returned 1 row");
mysql_stmt_close(stmt);
......@@ -8118,6 +8342,7 @@ static void test_ts()
sprintf(query, "SELECT a, b, c FROM test_ts WHERE %c=?", name);
if (!opt_silent)
fprintf(stdout, "\n %s", query);
stmt= mysql_simple_prepare(mysql, query);
check_stmt(stmt);
......@@ -8131,6 +8356,7 @@ static void test_ts()
while (mysql_stmt_fetch(stmt) == 0)
row_count++;
if (!opt_silent)
fprintf(stdout, "\n returned '%d' rows", row_count);
DIE_UNLESS(row_count == 2);
mysql_stmt_close(stmt);
......@@ -8273,6 +8499,7 @@ static void test_bug1946()
check_stmt(stmt);
rc= mysql_real_query(mysql, query, strlen(query));
DIE_UNLESS(rc != 0);
if (!opt_silent)
fprintf(stdout, "Got error (as expected):\n");
myerror(NULL);
......@@ -8291,18 +8518,22 @@ static void test_parse_error_and_bad_length()
rc= mysql_query(mysql, "SHOW DATABAAAA");
DIE_UNLESS(rc);
if (!opt_silent)
fprintf(stdout, "Got error (as expected): '%s'\n", mysql_error(mysql));
rc= mysql_real_query(mysql, "SHOW DATABASES", 100);
DIE_UNLESS(rc);
if (!opt_silent)
fprintf(stdout, "Got error (as expected): '%s'\n", mysql_error(mysql));
stmt= mysql_simple_prepare(mysql, "SHOW DATABAAAA");
DIE_UNLESS(!stmt);
if (!opt_silent)
fprintf(stdout, "Got error (as expected): '%s'\n", mysql_error(mysql));
stmt= mysql_stmt_init(mysql);
DIE_UNLESS(stmt);
rc= mysql_stmt_prepare(stmt, "SHOW DATABASES", 100);
DIE_UNLESS(rc != 0);
if (!opt_silent)
fprintf(stdout, "Got error (as expected): '%s'\n", mysql_stmt_error(stmt));
mysql_stmt_close(stmt);
}
......@@ -8324,6 +8555,7 @@ static void test_bug2247()
myheader("test_bug2247");
if (!opt_silent)
fprintf(stdout, "\nChecking if stmt_affected_rows is not affected by\n"
"mysql_query ... ");
/* create table and insert few rows */
......@@ -8381,6 +8613,7 @@ static void test_bug2247()
DIE_UNLESS(mysql_stmt_affected_rows(stmt) == exp_count);
mysql_stmt_close(stmt);
if (!opt_silent)
fprintf(stdout, "OK");
}
......@@ -8659,6 +8892,7 @@ static void test_bug3117()
check_execute(stmt, rc);
DIE_UNLESS(is_null == 0 && lii == 1);
if (!opt_silent)
fprintf(stdout, "\n\tLAST_INSERT_ID()= 1 ok\n");
rc= mysql_query(mysql, "INSERT INTO t1 VALUES (NULL)");
......@@ -8671,6 +8905,7 @@ static void test_bug3117()
check_execute(stmt, rc);
DIE_UNLESS(is_null == 0 && lii == 2);
if (!opt_silent)
fprintf(stdout, "\tLAST_INSERT_ID()= 2 ok\n");
mysql_stmt_close(stmt);
......@@ -8821,6 +9056,7 @@ static void test_create_drop()
{
rc= mysql_stmt_execute(stmt_create);
check_execute(stmt_create, rc);
if (!opt_silent)
fprintf(stdout, "created %i\n", i);
rc= mysql_stmt_execute(stmt_select);
......@@ -8830,10 +9066,12 @@ static void test_create_drop()
rc= mysql_stmt_execute(stmt_drop);
check_execute(stmt_drop, rc);
if (!opt_silent)
fprintf(stdout, "droped %i\n", i);
rc= mysql_stmt_execute(stmt_create_select);
check_execute(stmt_create, rc);
if (!opt_silent)
fprintf(stdout, "created select %i\n", i);
rc= mysql_stmt_execute(stmt_select);
......@@ -8843,6 +9081,7 @@ static void test_create_drop()
rc= mysql_stmt_execute(stmt_drop);
check_execute(stmt_drop, rc);
if (!opt_silent)
fprintf(stdout, "droped %i\n", i);
}
......@@ -8874,6 +9113,7 @@ static void test_rename()
rc= mysql_stmt_execute(stmt);
check_execute_r(stmt, rc);
if (!opt_silent)
fprintf(stdout, "rename without t3\n");
rc= mysql_query(mysql, "create table t3 (a int)");
......@@ -8881,10 +9121,12 @@ static void test_rename()
rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "rename with t3\n");
rc= mysql_stmt_execute(stmt);
check_execute_r(stmt, rc);
if (!opt_silent)
fprintf(stdout, "rename renamed\n");
rc= mysql_query(mysql, "rename table t2 to t1, t4 to t3");
......@@ -8892,6 +9134,7 @@ static void test_rename()
rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc);
if (!opt_silent)
fprintf(stdout, "rename reverted\n");
mysql_stmt_close(stmt);
......@@ -8926,9 +9169,11 @@ static void test_do_set()
{
rc= mysql_stmt_execute(stmt_do);
check_execute(stmt_do, rc);
if (!opt_silent)
fprintf(stdout, "do %i\n", i);
rc= mysql_stmt_execute(stmt_set);
check_execute(stmt_set, rc);
if (!opt_silent)
fprintf(stdout, "set %i\n", i);
}
......@@ -8995,10 +9240,12 @@ static void test_multi()
rc= mysql_stmt_execute(stmt_update);
check_execute(stmt_update, rc);
if (!opt_silent)
fprintf(stdout, "update %ld\n", (long) param);
rc= mysql_stmt_execute(stmt_delete);
check_execute(stmt_delete, rc);
if (!opt_silent)
fprintf(stdout, "delete %ld\n", (long) param);
rc= mysql_stmt_execute(stmt_select1);
......@@ -9055,6 +9302,7 @@ static void test_insert_select()
{
rc= mysql_stmt_execute(stmt_insert);
check_execute(stmt_insert, rc);
if (!opt_silent)
fprintf(stdout, "insert %u\n", i);
rc= mysql_stmt_execute(stmt_select);
......@@ -9915,6 +10163,7 @@ static void test_bug3796()
mysql_stmt_bind_result(stmt, bind);
rc= mysql_stmt_fetch(stmt);
if (!opt_silent)
printf("Concat result: '%s'\n", out_buff);
check_execute(stmt, rc);
strcpy(canonical_buff, concat_arg0);
......@@ -9927,6 +10176,7 @@ static void test_bug3796()
strcpy(canonical_buff + strlen(concat_arg0), "TWO");
DIE_UNLESS(strlen(canonical_buff) == out_length &&
strncmp(out_buff, canonical_buff, out_length) == 0);
if (!opt_silent)
printf("Concat result: '%s'\n", out_buff);
rc= mysql_stmt_fetch(stmt);
......@@ -10001,12 +10251,15 @@ static void test_bug4026()
rc= mysql_stmt_fetch(stmt);
DIE_UNLESS(rc == 0);
if (!opt_silent)
{
printf("%d:%d:%d.%lu\n", time_out.hour, time_out.minute, time_out.second,
time_out.second_part);
printf("%d-%d-%d %d:%d:%d.%lu\n", datetime_out.year, datetime_out.month,
datetime_out.day, datetime_out.hour,
datetime_out.minute, datetime_out.second,
datetime_out.second_part);
}
DIE_UNLESS(memcmp(&time_in, &time_out, sizeof(time_in)) == 0);
DIE_UNLESS(memcmp(&datetime_in, &datetime_out, sizeof(datetime_in)) == 0);
mysql_stmt_close(stmt);
......@@ -10049,6 +10302,7 @@ static void test_bug4079()
rc= mysql_stmt_fetch(stmt);
DIE_UNLESS(rc != 0 && rc != MYSQL_NO_DATA);
if (!opt_silent)
printf("Got error from mysql_stmt_fetch (as expected):\n%s\n",
mysql_stmt_error(stmt));
/* buggy version of libmysql hanged up here */
......@@ -10144,6 +10398,8 @@ static void test_bug4030()
rc= mysql_stmt_fetch(stmt);
DIE_UNLESS(rc == 0);
if (!opt_silent)
{
printf("%d:%d:%d.%lu\n", time_out.hour, time_out.minute, time_out.second,
time_out.second_part);
printf("%d-%d-%d\n", date_out.year, date_out.month, date_out.day);
......@@ -10151,6 +10407,7 @@ static void test_bug4030()
datetime_out.day, datetime_out.hour,
datetime_out.minute, datetime_out.second,
datetime_out.second_part);
}
DIE_UNLESS(memcmp(&time_canonical, &time_out, sizeof(time_out)) == 0);
DIE_UNLESS(memcmp(&date_canonical, &date_out, sizeof(date_out)) == 0);
DIE_UNLESS(memcmp(&datetime_canonical, &datetime_out, sizeof(datetime_out)) == 0);
......@@ -10200,6 +10457,7 @@ static void test_bug5126()
rc= mysql_stmt_fetch(stmt);
DIE_UNLESS(rc == 0);
DIE_UNLESS(c1 == 8386608 && c2 == 1);
if (!opt_silent)
printf("%ld, %ld\n", (long) c1, (long) c2);
mysql_stmt_close(stmt);
}
......@@ -10306,6 +10564,7 @@ static void test_bug5399()
check_execute(*stmt, rc);
mysql_stmt_bind_result(*stmt, bind);
}
if (!opt_silent)
printf("%d statements prepared.\n", NUM_OF_USED_STMT);
for (stmt= stmt_list; stmt != stmt_list + NUM_OF_USED_STMT; ++stmt)
......@@ -10478,6 +10737,7 @@ static void test_bug5194()
rc= mysql_stmt_prepare(stmt, query, query_ptr - query);
if (rc && nrows * COLUMN_COUNT > uint16_max)
{
if (!opt_silent)
printf("Failed to prepare a statement with %d placeholders "
"(as expected).\n", nrows * COLUMN_COUNT);
break;
......@@ -10485,6 +10745,7 @@ static void test_bug5194()
else
check_execute(stmt, rc);
if (!opt_silent)
printf("Insert: query length= %d, row count= %d, param count= %lu\n",
strlen(query), nrows, mysql_stmt_param_count(stmt));
......@@ -10522,7 +10783,10 @@ static void test_bug5315()
rc= mysql_stmt_execute(stmt);
DIE_UNLESS(rc != 0);
if (rc)
{
if (!opt_silent)
printf("Got error (as expected):\n%s", mysql_stmt_error(stmt));
}
/* check that connection is OK */
mysql_stmt_close(stmt);
stmt= mysql_stmt_init(mysql);
......@@ -10570,8 +10834,11 @@ static void test_bug6049()
rc= mysql_stmt_fetch(stmt);
DIE_UNLESS(rc == 0);
if (!opt_silent)
{
printf("Result from query: %s\n", row[0]);
printf("Result from prepared statement: %s\n", (char*) buffer);
}
DIE_UNLESS(strcmp(row[0], (char*) buffer) == 0);
......@@ -10616,8 +10883,11 @@ static void test_bug6058()
rc= mysql_stmt_fetch(stmt);
DIE_UNLESS(rc == 0);
if (!opt_silent)
{
printf("Result from query: %s\n", row[0]);
printf("Result from prepared statement: %s\n", buffer);
}
DIE_UNLESS(strcmp(row[0], buffer) == 0);
......@@ -10656,17 +10926,17 @@ static void test_bug6046()
stmt_text= "DROP TABLE IF EXISTS t1";
rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text));
myquery(rc);
stmt_text= "CREATE TABLE a1 (a int, b int)";
stmt_text= "CREATE TABLE t1 (a int, b int)";
rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text));
myquery(rc);
stmt_text= "INSERT INTO a1 VALUES (1,1),(2,2),(3,1),(4,2)";
stmt_text= "INSERT INTO t1 VALUES (1,1),(2,2),(3,1),(4,2)";
rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text));
myquery(rc);
stmt= mysql_stmt_init(mysql);
stmt_text= "SELECT a1.a FROM a1 NATURAL JOIN a1 as X1 "
"WHERE a1.b > ? ORDER BY a1.a";
stmt_text= "SELECT t1.a FROM t1 NATURAL JOIN t1 as X1 "
"WHERE t1.b > ? ORDER BY t1.a";
rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
check_execute(stmt, rc);
......@@ -10772,13 +11042,15 @@ static void test_bug6096()
/* Print out and check the metadata */
printf(" ---------------------------------------------------------------\n");
if (!opt_silent)
{
printf(" ------------------------------------------------------------\n");
printf(" | Metadata \n");
printf(" ---------------------------------------------------------------\n");
printf(" ------------------------------------------------------------\n");
printf(" | Query | Prepared statement \n");
printf(" ---------------------------------------------------------------\n");
printf(" field name | length | max_length | length | max_length \n");
printf(" ---------------------------------------------------------------\n");
printf(" ------------------------------------------------------------\n");
printf(" field name | length | max_length | length | max_length\n");
printf(" ------------------------------------------------------------\n");
for (i= 0; i < query_field_count; ++i)
{
......@@ -10788,6 +11060,7 @@ static void test_bug6096()
DIE_UNLESS(f1->length == f2->length);
}
printf(" ---------------------------------------------------------------\n");
}
/* Bind and fetch the data */
......@@ -10842,6 +11115,8 @@ static struct my_option client_test_long_options[] =
#endif
{"port", 'P', "Port number to use for connection", (char **) &opt_port,
(char **) &opt_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"silent", 's', "Be more silent", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0,
0},
{"socket", 'S', "Socket file to use for connection", (char **) &opt_unix_socket,
(char **) &opt_unix_socket, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"testcase", 'c', "May disable some code when runs as mysql-test-run testcase.",
......@@ -10851,36 +11126,25 @@ static struct my_option client_test_long_options[] =
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
static void client_test_print_version(void)
{
fprintf(stdout, "%s Distrib %s, for %s (%s)\n\n",
my_progname, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE);
}
static void usage(void)
{
/*
* show the usage string when the user asks for this
*/
/* show the usage string when the user asks for this */
putc('\n', stdout);
puts("***********************************************************************\n");
puts(" Test for client-server protocol 4.1");
puts(" By Monty & Venu \n");
puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software, ");
puts("and you are welcome to modify and redistribute it under the GPL license\n");
puts(" Copyright (C) 1995-2003 MySQL AB ");
puts("-----------------------------------------------------------------------\n");
client_test_print_version();
fprintf(stdout, "Usage: %s [OPTIONS]\n\n", my_progname);
printf("%s Ver %s Distrib %s, for %s (%s)\n",
my_progname, VER, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE);
puts("By Monty, Venu, Kent and others\n");
printf("\
Copyright (C) 2002-2004 MySQL AB\n\
This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n\
and you are welcome to modify and redistribute it under the GPL license\n");
printf("Usage: %s [OPTIONS]\n", my_progname);
my_print_help(client_test_long_options);
print_defaults("my", client_test_load_default_groups);
my_print_variables(client_test_long_options);
puts("***********************************************************************\n");
}
static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument)
......@@ -10905,6 +11169,12 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
else
tty_password= 1;
break;
case 's':
if (argument == disabled_my_option)
opt_silent= 0;
else
opt_silent++;
break;
case '?':
case 'I': /* Info */
usage();
......@@ -10933,6 +11203,8 @@ static void get_options(int argc, char **argv)
static void print_test_output()
{
if (opt_silent < 3)
{
fprintf(stdout, "\n\n");
fprintf(stdout, "All '%d' tests were successful (in '%d' iterations)",
test_count-1, opt_count);
......@@ -10941,6 +11213,7 @@ static void print_test_output()
fprintf(stdout, " (Avg: %g SECS)", total_time/opt_count);
fprintf(stdout, "\n\n!!! SUCCESS !!!\n");
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment