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 @@ ...@@ -42,7 +42,7 @@
**********************************************************************/ **********************************************************************/
#define MTEST_VERSION "2.3" #define MTEST_VERSION "2.4"
#include <my_global.h> #include <my_global.h>
#include <mysql_embed.h> #include <mysql_embed.h>
...@@ -243,8 +243,7 @@ VAR var_reg[10]; ...@@ -243,8 +243,7 @@ VAR var_reg[10];
HASH var_hash; HASH var_hash;
my_bool disable_query_log=0, disable_result_log=0, disable_warnings=0; my_bool disable_query_log=0, disable_result_log=0, disable_warnings=0;
my_bool disable_info= 1; /* By default off */ my_bool disable_info= 1; /* By default off */
/* default for disable_abort_on_error: false = abort on unmasked error */ my_bool abort_on_error= 1;
my_bool disable_abort_on_error= 0;
struct connection cons[MAX_CONS]; struct connection cons[MAX_CONS];
struct connection* cur_con, *next_con, *cons_end; struct connection* cur_con, *next_con, *cons_end;
...@@ -370,7 +369,7 @@ const char *command_names[]= ...@@ -370,7 +369,7 @@ const char *command_names[]=
}; };
TYPELIB command_typelib= {array_elements(command_names),"", TYPELIB command_typelib= {array_elements(command_names),"",
command_names}; command_names, 0};
DYNAMIC_STRING ds_res; DYNAMIC_STRING ds_res;
static void die(const char *fmt, ...); static void die(const char *fmt, ...);
...@@ -744,7 +743,7 @@ err: ...@@ -744,7 +743,7 @@ err:
DBUG_RETURN(0); DBUG_RETURN(0);
} }
static VAR* var_obtain(char* name, int len) static VAR *var_obtain(const char* name, int len)
{ {
VAR* v; VAR* v;
if ((v = (VAR*)hash_search(&var_hash, name, len))) if ((v = (VAR*)hash_search(&var_hash, name, len)))
...@@ -754,28 +753,33 @@ static VAR* var_obtain(char* name, int len) ...@@ -754,28 +753,33 @@ static VAR* var_obtain(char* name, int len)
return v; return v;
} }
int var_set(char* var_name, char* var_name_end, char* var_val, int var_set(const char *var_name, const char *var_name_end,
char* var_val_end) const char *var_val, const char *var_val_end)
{ {
int digit; int digit;
VAR* v; 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++ != '$') if (*var_name++ != '$')
{ {
--var_name; var_name--;
*var_name_end = 0;
die("Variable name in %s does not start with '$'", var_name); die("Variable name in %s does not start with '$'", var_name);
} }
digit = *var_name - '0'; digit = *var_name - '0';
if (!(digit < 10 && digit >= 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 else
v = var_reg + digit; v = var_reg + digit;
return eval_expr(v, var_val, (const char**)&var_val_end); return eval_expr(v, var_val, (const char**)&var_val_end);
} }
int open_file(const char* name) int open_file(const char* name)
{ {
char buff[FN_REFLEN]; char buff[FN_REFLEN];
...@@ -1244,18 +1248,22 @@ int do_let(struct st_query* q) ...@@ -1244,18 +1248,22 @@ int do_let(struct st_query* q)
return var_set(var_name, var_name_end, var_val_start, q->end); 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>" */ Store an integer (typically the returncode of the last SQL)
int var_set_errno(int sql_errno ) 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]; const char *var_name= "$mysql_errno";
sprintf(var_val, "%d", sql_errno); char var_val[21];
/* On some odd systems, the return value from sprintf() isn't */ uint length= my_sprintf(var_val, (var_val, "%d", sql_errno));
/* always the length of the string, so we use strlen() */ return var_set(var_name, var_name + 12, var_val, var_val + length);
return var_set(var_name, var_name + 12, var_val, var_val + strlen(var_val));
} }
int do_rpl_probe(struct st_query* q __attribute__((unused))) int do_rpl_probe(struct st_query* q __attribute__((unused)))
{ {
DBUG_ENTER("do_rpl_probe"); DBUG_ENTER("do_rpl_probe");
...@@ -1264,12 +1272,14 @@ int do_rpl_probe(struct st_query* q __attribute__((unused))) ...@@ -1264,12 +1272,14 @@ int do_rpl_probe(struct st_query* q __attribute__((unused)))
DBUG_RETURN(0); DBUG_RETURN(0);
} }
int do_enable_rpl_parse(struct st_query* q __attribute__((unused))) int do_enable_rpl_parse(struct st_query* q __attribute__((unused)))
{ {
mysql_enable_rpl_parse(&cur_con->mysql); mysql_enable_rpl_parse(&cur_con->mysql);
return 0; return 0;
} }
int do_disable_rpl_parse(struct st_query* q __attribute__((unused))) int do_disable_rpl_parse(struct st_query* q __attribute__((unused)))
{ {
mysql_disable_rpl_parse(&cur_con->mysql); mysql_disable_rpl_parse(&cur_con->mysql);
...@@ -2013,7 +2023,7 @@ int read_query(struct st_query** q_ptr) ...@@ -2013,7 +2023,7 @@ int read_query(struct st_query** q_ptr)
memcpy((gptr) q->expected_errno, (gptr) global_expected_errno, memcpy((gptr) q->expected_errno, (gptr) global_expected_errno,
sizeof(global_expected_errno)); sizeof(global_expected_errno));
q->expected_errors= global_expected_errors; 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)); bzero((gptr) global_expected_errno, sizeof(global_expected_errno));
global_expected_errors=0; global_expected_errors=0;
if (p[0] == '-' && p[1] == '-') if (p[0] == '-' && p[1] == '-')
...@@ -2422,7 +2432,7 @@ static int run_query(MYSQL *mysql, struct st_query *q, int flags) ...@@ -2422,7 +2432,7 @@ static int run_query(MYSQL *mysql, struct st_query *q, int flags)
if (ps_protocol_enabled && disable_info && if (ps_protocol_enabled && disable_info &&
(flags & QUERY_SEND) && (flags & QUERY_REAP) && ps_match_re(q->query)) (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); return run_query_normal(mysql, q, flags);
} }
...@@ -2659,9 +2669,12 @@ end: ...@@ -2659,9 +2669,12 @@ end:
dynstr_free(&ds_tmp); dynstr_free(&ds_tmp);
if (q->type == Q_EVAL) if (q->type == Q_EVAL)
dynstr_free(&eval_query); 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)); var_set_errno(mysql_errno(mysql));
DBUG_RETURN(error); DBUG_RETURN(error);
} }
...@@ -3012,6 +3025,7 @@ end: ...@@ -3012,6 +3025,7 @@ end:
dynstr_free(&ds_tmp); dynstr_free(&ds_tmp);
if (q->type == Q_EVAL) if (q->type == Q_EVAL)
dynstr_free(&eval_query); dynstr_free(&eval_query);
var_set_errno(mysql_stmt_errno(stmt));
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
DBUG_RETURN(error); DBUG_RETURN(error);
} }
...@@ -3319,7 +3333,7 @@ static VAR* var_from_env(const char *name, const char *def_val) ...@@ -3319,7 +3333,7 @@ static VAR* var_from_env(const char *name, const char *def_val)
if (!(tmp = getenv(name))) if (!(tmp = getenv(name)))
tmp = def_val; 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); my_hash_insert(&var_hash, (byte*)v);
return v; return v;
} }
...@@ -3416,9 +3430,11 @@ int main(int argc, char **argv) ...@@ -3416,9 +3430,11 @@ int main(int argc, char **argv)
init_var_hash(&cur_con->mysql); init_var_hash(&cur_con->mysql);
/* Initialize $mysql_errno with -1, so we can */ /*
/* - distinguish it from valid values ( >= 0 ) and */ Initialize $mysql_errno with -1, so we can
/* - detect if there was never a command sent to the server */ - distinguish it from valid values ( >= 0 ) and
- detect if there was never a command sent to the server
*/
var_set_errno(-1); var_set_errno(-1);
while (!read_query(&q)) while (!read_query(&q))
...@@ -3440,8 +3456,8 @@ int main(int argc, char **argv) ...@@ -3440,8 +3456,8 @@ int main(int argc, char **argv)
case Q_DISABLE_RPL_PARSE: do_disable_rpl_parse(q); break; case Q_DISABLE_RPL_PARSE: do_disable_rpl_parse(q); break;
case Q_ENABLE_QUERY_LOG: disable_query_log=0; break; case Q_ENABLE_QUERY_LOG: disable_query_log=0; break;
case Q_DISABLE_QUERY_LOG: disable_query_log=1; 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_ENABLE_ABORT_ON_ERROR: abort_on_error=1; break;
case Q_DISABLE_ABORT_ON_ERROR: disable_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_ENABLE_RESULT_LOG: disable_result_log=0; break;
case Q_DISABLE_RESULT_LOG: disable_result_log=1; break; case Q_DISABLE_RESULT_LOG: disable_result_log=1; break;
case Q_ENABLE_WARNINGS: disable_warnings=0; break; case Q_ENABLE_WARNINGS: disable_warnings=0; break;
......
...@@ -282,13 +282,7 @@ void my_net_local_init(NET *net); ...@@ -282,13 +282,7 @@ void my_net_local_init(NET *net);
void net_end(NET *net); void net_end(NET *net);
void net_clear(NET *net); void net_clear(NET *net);
my_bool net_realloc(NET *net, unsigned long length); my_bool net_realloc(NET *net, unsigned long length);
#ifndef EMBEDDED_LIBRARY /* To be removed by HF */
my_bool net_flush(NET *net); 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 my_net_write(NET *net,const char *packet,unsigned long len);
my_bool net_write_command(NET *net,unsigned char command, my_bool net_write_command(NET *net,unsigned char command,
const char *header, unsigned long head_len, const char *header, unsigned long head_len,
......
...@@ -7,11 +7,6 @@ otto ...@@ -7,11 +7,6 @@ otto
select otto from (select 1 as otto) as t1; select otto from (select 1 as otto) as t1;
otto otto
1 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; select friedrich from (select 1 as otto) as t1;
ERROR 42S22: Unknown column 'friedrich' in 'field list' ERROR 42S22: Unknown column 'friedrich' in 'field list'
select otto from (select 1 as otto) as t1; select otto from (select 1 as otto) as t1;
...@@ -147,5 +142,3 @@ after_--enable_abort_on_error ...@@ -147,5 +142,3 @@ after_--enable_abort_on_error
1064 1064
select 3 from t1 ; select 3 from t1 ;
ERROR 42S02: Table 'test.t1' doesn't exist ERROR 42S02: Table 'test.t1' doesn't exist
select 3 from t1 ;
ERROR 42S02: Table 'test.t1' doesn't exist
--disable_result_log --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 @@ ...@@ -5,7 +5,8 @@
select 1+2/*hello*/+3; select 1+2/*hello*/+3;
select 1 /* long select 1 /* long
multi line comment */; multi line comment */;
!$1065 ; --error 1065
;
select 1 /*!32301 +1 */; select 1 /*!32301 +1 */;
select 1 /*!52301 +1 */; select 1 /*!52301 +1 */;
select 1--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; ...@@ -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); 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 # 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); --error 1120
!$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); 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 # 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 # Test of inner join
select t1.*,t2.* from t1 inner join t2 using (a); select t1.*,t2.* from t1 inner join t2 using (a);
...@@ -94,7 +97,8 @@ WHERE t1.uniq_id = 4 ...@@ -94,7 +97,8 @@ WHERE t1.uniq_id = 4
ORDER BY t2.c_amount; ORDER BY t2.c_amount;
INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes'); 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'); 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 #3rd select should show that one record is returned with null entries for the
...@@ -288,7 +292,8 @@ insert into t3 values (1); ...@@ -288,7 +292,8 @@ insert into t3 values (1);
insert into t4 values (1,1); insert into t4 values (1,1);
insert into t5 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; drop table t1,t2,t3,t4,t5;
......
...@@ -146,7 +146,8 @@ create table t1 ...@@ -146,7 +146,8 @@ create table t1
); );
INSERT INTO t1 VALUES (1, 1, 1, 1, 'a'); INSERT INTO t1 VALUES (1, 1, 1, 1, 'a');
INSERT INTO t1 VALUES (1, 1, 1, 1, 'b'); 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; drop table t1;
# #
......
...@@ -20,12 +20,10 @@ eval select $mysql_errno as "before_use_test" ; ...@@ -20,12 +20,10 @@ eval select $mysql_errno as "before_use_test" ;
select otto from (select 1 as otto) as t1; select otto from (select 1 as otto) as t1;
# expectation = response # expectation = response
!$0 select otto from (select 1 as otto) as t1;
--error 0 --error 0
select otto from (select 1 as otto) as t1; select otto from (select 1 as otto) as t1;
# expectation <> response # expectation <> response
-- // !$1054 select otto from (select 1 as otto) as t1;
-- // --error 1054 -- // --error 1054
-- // select otto from (select 1 as otto) as t1; -- // select otto from (select 1 as otto) as t1;
...@@ -38,12 +36,10 @@ select otto from (select 1 as otto) as t1; ...@@ -38,12 +36,10 @@ select otto from (select 1 as otto) as t1;
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# expectation <> response # expectation <> response
#!$0 select friedrich from (select 1 as otto) as t1;
#--error 0 #--error 0
#select friedrich from (select 1 as otto) as t1; #select friedrich from (select 1 as otto) as t1;
# expectation = response # expectation = response
!$1054 select friedrich from (select 1 as otto) as t1;
--error 1054 --error 1054
select friedrich from (select 1 as otto) as t1; select friedrich from (select 1 as otto) as t1;
...@@ -94,130 +90,130 @@ 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 # The following test cases often initialize $mysql_errno to 1064 by
# a command with wrong syntax. # 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 ; # 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; select otto from (select 1 as otto) as t1;
eval select $mysql_errno as "after_successful_stmt_errno" ; 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 ; garbage ;
eval select $mysql_errno as "after_wrong_syntax_errno" ; 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 ; garbage ;
let $my_var= 'abc' ; let $my_var= 'abc' ;
eval select $mysql_errno as "after_let_var_equal_value" ; 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 ; garbage ;
set @my_var= 'abc' ; set @my_var= 'abc' ;
eval select $mysql_errno as "after_set_var_equal_value" ; 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.) # (May be --<whatever> modifies $mysql_errno.)
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
!$1064 --error 1064
garbage ; garbage ;
--disable_warnings --disable_warnings
eval select $mysql_errno as "after_disable_warnings_command" ; 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 # stored within $mysql_errno
# (May be disabled warnings affect $mysql_errno.) # (May be disabled warnings affect $mysql_errno.)
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
drop table if exists t1 ; drop table if exists t1 ;
!$1064 --error 1064
garbage ; garbage ;
drop table if exists t1 ; drop table if exists t1 ;
eval select $mysql_errno as "after_disable_warnings" ; eval select $mysql_errno as "after_disable_warnings" ;
--enable_warnings --enable_warnings
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# 7. check if masked errors affect $mysql_errno # check if masked errors affect $mysql_errno
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
!$1064 --error 1064
garbage ; garbage ;
--error 1146 --error 1146
select 3 from t1 ; select 3 from t1 ;
eval select $mysql_errno as "after_minus_masked" ; eval select $mysql_errno as "after_minus_masked" ;
!$1064 --error 1064
garbage ; garbage ;
!$1146 --error 1146
select 3 from t1 ; select 3 from t1 ;
eval select $mysql_errno as "after_!_masked" ; 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 ; garbage ;
let $mysql_errno= -1; let $mysql_errno= -1;
eval select $mysql_errno as "after_let_errno_equal_value" ; 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 # failing prepare
!$1064 --error 1064
garbage ; garbage ;
!$1146 --error 1146
prepare stmt from "select 3 from t1" ; prepare stmt from "select 3 from t1" ;
eval select $mysql_errno as "after_failing_prepare" ; eval select $mysql_errno as "after_failing_prepare" ;
create table t1 ( f1 char(10)); create table t1 ( f1 char(10));
# successful prepare # successful prepare
!$1064 --error 1064
garbage ; garbage ;
prepare stmt from "select 3 from t1" ; prepare stmt from "select 3 from t1" ;
eval select $mysql_errno as "after_successful_prepare" ; eval select $mysql_errno as "after_successful_prepare" ;
# successful execute # successful execute
!$1064 --error 1064
garbage ; garbage ;
execute stmt; execute stmt;
eval select $mysql_errno as "after_successful_execute" ; eval select $mysql_errno as "after_successful_execute" ;
# failing execute (table dropped) # failing execute (table dropped)
drop table t1; drop table t1;
!$1064 --error 1064
garbage ; garbage ;
!$1146 --error 1146
execute stmt; execute stmt;
eval select $mysql_errno as "after_failing_execute" ; eval select $mysql_errno as "after_failing_execute" ;
# failing execute (unknown statement) # failing execute (unknown statement)
!$1064 --error 1064
garbage ; garbage ;
!$1243 --error 1243
execute __stmt_; execute __stmt_;
eval select $mysql_errno as "after_failing_execute" ; eval select $mysql_errno as "after_failing_execute" ;
# successful deallocate # successful deallocate
!$1064 --error 1064
garbage ; garbage ;
deallocate prepare stmt; deallocate prepare stmt;
eval select $mysql_errno as "after_successful_deallocate" ; eval select $mysql_errno as "after_successful_deallocate" ;
# failing deallocate ( statement handle does not exist ) # failing deallocate ( statement handle does not exist )
!$1064 --error 1064
garbage ; garbage ;
!$1243 --error 1243
deallocate prepare __stmt_; deallocate prepare __stmt_;
eval select $mysql_errno as "after_failing_deallocate" ; eval select $mysql_errno as "after_failing_deallocate" ;
...@@ -231,7 +227,7 @@ 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". # The default is "--enable_abort_on_error".
# #
# "Maskings" are # "Maskings" are
# !$<error number> and --error <error number> # --error <error number> and --error <error number>
# in the line before the failing statement. # in the line before the failing statement.
# #
# There are some additional test case for $mysql_errno # There are some additional test case for $mysql_errno
...@@ -240,58 +236,53 @@ eval select $mysql_errno as "after_failing_deallocate" ; ...@@ -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 ; garbage ;
--disable_abort_on_error --disable_abort_on_error
eval select $mysql_errno as "after_--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 ; select 3 from t1 ;
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# 3. masked failing statements # masked failing statements
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# expected error = response # expected error = response
--error 1146 --error 1146
select 3 from t1 ; select 3 from t1 ;
!$1146 --error 1146
select 3 from t1 ; select 3 from t1 ;
eval select $mysql_errno as "after_!errno_masked_error" ; eval select $mysql_errno as "after_!errno_masked_error" ;
# expected error <> response # expected error <> response
# --error 1000 # --error 1000
# select 3 from t1 ; # select 3 from t1 ;
# !$1000 # --error 1000
# select 3 from t1 ; # 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 ; garbage ;
--enable_abort_on_error --enable_abort_on_error
eval select $mysql_errno as "after_--enable_abort_on_error" ; eval select $mysql_errno as "after_--enable_abort_on_error" ;
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# 5. masked failing statements # masked failing statements
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# expected error = response # expected error = response
--error 1146 --error 1146
select 3 from t1 ; 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 # Please remove the '#' to get the abort on error
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
#--error 1064 #--error 1064
#select 3 from t1 ; #select 3 from t1 ;
# #
#!$1064
#select 3 from t1 ;
#
#select 3 from t1 ; #select 3 from t1 ;
...@@ -21,7 +21,8 @@ check table t1 changed; ...@@ -21,7 +21,8 @@ check table t1 changed;
check table t1 medium; check table t1 medium;
check table t1 extended; check table t1 extended;
show index from t1; 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;
optimize table t1; optimize table t1;
drop table t1; drop table t1;
......
...@@ -20,8 +20,10 @@ create TEMPORARY TABLE t2 engine=heap select * from 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; create TEMPORARY TABLE IF NOT EXISTS t2 (a int) engine=heap;
# This should give errors # This should give errors
!$1050 CREATE TEMPORARY TABLE t1 (a int not null, b char (10) not null); --error 1050
!$1050 ALTER TABLE t1 RENAME t2; CREATE TEMPORARY TABLE t1 (a int not null, b char (10) not null);
--error 1050
ALTER TABLE t1 RENAME t2;
select * from t2; select * from t2;
alter table t2 add primary key (a,b); alter table t2 add primary key (a,b);
......
...@@ -135,7 +135,8 @@ drop table t1,t2; ...@@ -135,7 +135,8 @@ drop table t1,t2;
create table t1 (c int); create table t1 (c int);
insert into t1 values(1),(2); insert into t1 values(1),(2);
create table t2 select * from t1; 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; create table t3 select t1.c AS c1, t2.c AS c2,1 as "const" from t1, t2;
show full columns from t3; show full columns from t3;
drop table t1,t2,t3; drop table t1,t2,t3;
......
...@@ -5026,12 +5026,12 @@ The minimum value for this variable is 4096.", ...@@ -5026,12 +5026,12 @@ The minimum value for this variable is 4096.",
"Persistent buffer for query parsing and execution", "Persistent buffer for query parsing and execution",
(gptr*) &global_system_variables.query_prealloc_size, (gptr*) &global_system_variables.query_prealloc_size,
(gptr*) &max_system_variables.query_prealloc_size, 0, GET_ULONG, (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, {"range_alloc_block_size", OPT_RANGE_ALLOC_BLOCK_SIZE,
"Allocation block size for storing ranges during optimization", "Allocation block size for storing ranges during optimization",
(gptr*) &global_system_variables.range_alloc_block_size, (gptr*) &global_system_variables.range_alloc_block_size,
(gptr*) &max_system_variables.range_alloc_block_size, 0, GET_ULONG, (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, {"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.", "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, (gptr*) &global_system_variables.read_buff_size,
......
...@@ -53,19 +53,9 @@ ...@@ -53,19 +53,9 @@
#include <errno.h> #include <errno.h>
#ifdef EMBEDDED_LIBRARY #ifdef EMBEDDED_LIBRARY
#undef MYSQL_SERVER #undef MYSQL_SERVER
#undef MYSQL_CLIENT
#ifndef MYSQL_CLIENT
#define MYSQL_CLIENT #define MYSQL_CLIENT
#endif
#undef net_flush
extern "C" {
my_bool net_flush(NET *net);
}
#endif /*EMBEDDED_LIBRARY */ #endif /*EMBEDDED_LIBRARY */
......
...@@ -470,6 +470,15 @@ void Protocol::init(THD *thd_arg) ...@@ -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. Send name and type of result to client.
......
...@@ -75,6 +75,7 @@ public: ...@@ -75,6 +75,7 @@ public:
field_count=item_list->elements; field_count=item_list->elements;
return 0; return 0;
} }
virtual bool flush();
virtual void prepare_for_resend()=0; virtual void prepare_for_resend()=0;
virtual bool store_null()=0; virtual bool store_null()=0;
......
...@@ -153,6 +153,8 @@ static bool send_prep_stmt(Prepared_statement *stmt, uint columns) ...@@ -153,6 +153,8 @@ static bool send_prep_stmt(Prepared_statement *stmt, uint columns)
{ {
NET *net= &stmt->thd->net; NET *net= &stmt->thd->net;
char buff[9]; char buff[9];
DBUG_ENTER("send_prep_stmt");
buff[0]= 0; /* OK packet indicator */ buff[0]= 0; /* OK packet indicator */
int4store(buff+1, stmt->id); int4store(buff+1, stmt->id);
int2store(buff+5, columns); int2store(buff+5, columns);
...@@ -161,12 +163,11 @@ static bool send_prep_stmt(Prepared_statement *stmt, uint columns) ...@@ -161,12 +163,11 @@ static bool send_prep_stmt(Prepared_statement *stmt, uint columns)
Send types and names of placeholders to the client Send types and names of placeholders to the client
XXX: fix this nasty upcast from List<Item_param> to List<Item> 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->param_count &&
stmt->thd->protocol_simple.send_fields((List<Item> *) stmt->thd->protocol_simple.send_fields((List<Item> *)
&stmt->lex->param_list, 0)) || &stmt->lex->param_list,
net_flush(net); 0)));
return 0;
} }
#else #else
static bool send_prep_stmt(Prepared_statement *stmt, static bool send_prep_stmt(Prepared_statement *stmt,
...@@ -1088,7 +1089,7 @@ static int mysql_test_select(Prepared_statement *stmt, ...@@ -1088,7 +1089,7 @@ static int mysql_test_select(Prepared_statement *stmt,
{ {
if (lex->describe) if (lex->describe)
{ {
if (send_prep_stmt(stmt, 0)) if (send_prep_stmt(stmt, 0) || thd->protocol->flush())
goto err_prep; goto err_prep;
} }
else else
...@@ -1106,11 +1107,8 @@ static int mysql_test_select(Prepared_statement *stmt, ...@@ -1106,11 +1107,8 @@ static int mysql_test_select(Prepared_statement *stmt,
prepared in unit->prepare call above. prepared in unit->prepare call above.
*/ */
if (send_prep_stmt(stmt, lex->result->field_count(fields)) || if (send_prep_stmt(stmt, lex->result->field_count(fields)) ||
lex->result->send_fields(fields, 0) lex->result->send_fields(fields, 0) ||
#ifndef EMBEDDED_LIBRARY thd->protocol->flush())
|| net_flush(&thd->net)
#endif
)
goto err_prep; goto err_prep;
} }
} }
...@@ -1389,7 +1387,6 @@ static int send_prepare_results(Prepared_statement *stmt, bool text_protocol) ...@@ -1389,7 +1387,6 @@ static int send_prepare_results(Prepared_statement *stmt, bool text_protocol)
enum enum_sql_command sql_command= lex->sql_command; enum enum_sql_command sql_command= lex->sql_command;
int res= 0; int res= 0;
DBUG_ENTER("send_prepare_results"); DBUG_ENTER("send_prepare_results");
DBUG_PRINT("enter",("command: %d, param_count: %ld", DBUG_PRINT("enter",("command: %d, param_count: %ld",
sql_command, stmt->param_count)); sql_command, stmt->param_count));
...@@ -1475,7 +1472,8 @@ static int send_prepare_results(Prepared_statement *stmt, bool text_protocol) ...@@ -1475,7 +1472,8 @@ static int send_prepare_results(Prepared_statement *stmt, bool text_protocol)
goto error; goto error;
} }
if (res == 0) 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: error:
if (res < 0) if (res < 0)
send_error(thd, thd->killed ? ER_SERVER_SHUTDOWN : 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) ...@@ -1081,7 +1081,7 @@ mysqld_list_fields(THD *thd, TABLE_LIST *table_list, const char *wild)
restore_record(table,default_values); // Get empty record restore_record(table,default_values); // Get empty record
if (thd->protocol->send_fields(&field_list,2)) if (thd->protocol->send_fields(&field_list,2))
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
net_flush(&thd->net); thd->protocol->flush();
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -1098,13 +1098,11 @@ mysqld_dump_create_info(THD *thd, TABLE *table, int fd) ...@@ -1098,13 +1098,11 @@ mysqld_dump_create_info(THD *thd, TABLE *table, int fd)
if (store_create_info(thd, table, packet)) if (store_create_info(thd, table, packet))
DBUG_RETURN(-1); DBUG_RETURN(-1);
//if (protocol->convert)
// protocol->convert->convert((char*) packet->ptr(), packet->length());
if (fd < 0) if (fd < 0)
{ {
if (protocol->write()) if (protocol->write())
DBUG_RETURN(-1); DBUG_RETURN(-1);
net_flush(&thd->net); protocol->flush();
} }
else else
{ {
......
This diff is collapsed.
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