# This test should work in embedded server after we fix mysqltest
-- source include/not_embedded.inc

#
# Bug #20432: mysql client interprets commands in comments
#

# if the client sees the 'use' within the comment, we haven't fixed
--exec echo "/*"          >  $MYSQLTEST_VARDIR/tmp/bug20432.sql
--exec echo "use"         >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
--exec echo "*/"          >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
--exec $MYSQL              < $MYSQLTEST_VARDIR/tmp/bug20432.sql 2>&1

# SQL can have embedded comments => workie
--exec echo "select /*"   >  $MYSQLTEST_VARDIR/tmp/bug20432.sql
--exec echo "use"         >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
--exec echo "*/ 1"        >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
--exec $MYSQL              < $MYSQLTEST_VARDIR/tmp/bug20432.sql 2>&1

# client commands on the other hand must be at BOL => error
--exec echo "/*"          >  $MYSQLTEST_VARDIR/tmp/bug20432.sql
--exec echo "xxx"         >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
--exec echo "*/ use"      >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
--error 1
--exec $MYSQL              < $MYSQLTEST_VARDIR/tmp/bug20432.sql 2>&1

# client comment recognized, but parameter missing => error
--exec echo "use"         >  $MYSQLTEST_VARDIR/tmp/bug20432.sql
--exec $MYSQL              < $MYSQLTEST_VARDIR/tmp/bug20432.sql 2>&1

#
# Bug #20328: mysql client: dumb about trailing spaces on 'help' command
#
--exec echo 'help' | $MYSQL   >  $MYSQLTEST_VARDIR/tmp/bug20328.tmp
--exec echo 'help ' | $MYSQL  >  $MYSQLTEST_VARDIR/tmp/bug20328.tmp

#
# Bug #19216: Client crashes on long SELECT
#
--exec echo "select" > $MYSQLTEST_VARDIR/tmp/b19216.tmp
# 3400 * 20 makes 68000 columns that is more than the max number that can fit 
# in a 16 bit number.
let $i= 3400;
while ($i)
{
  --exec echo "'a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a'," >> $MYSQLTEST_VARDIR/tmp/b19216.tmp
  dec $i;
}

--exec echo "'b';" >> $MYSQLTEST_VARDIR/tmp/b19216.tmp
--disable_query_log
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/b19216.tmp >/dev/null
--enable_query_log

#
# Bug#17583: mysql drops connection when stdout is not writable
#
create table t17583 (a int);
insert into t17583 (a) values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
insert into t17583 select a from t17583;
insert into t17583 select a from t17583;
insert into t17583 select a from t17583;
insert into t17583 select a from t17583;
insert into t17583 select a from t17583;
insert into t17583 select a from t17583;
insert into t17583 select a from t17583;
# Close to the minimal data needed to exercise bug.
select count(*) from t17583;
--exec echo "select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; " |$MYSQL test >&-
drop table t17583;

#
# Bug #19216: Client crashes on long SELECT
#
--exec echo "select" > $MYSQLTEST_VARDIR/tmp/b19216.tmp
# 3400 * 20 makes 68000 columns that is more than the max number that can fit 
# in a 16 bit number.
let $i= 3400;
while ($i)
{
  --exec echo "'a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a'," >> $MYSQLTEST_VARDIR/tmp/b19216.tmp
  dec $i;
}

--exec echo "'b';" >> $MYSQLTEST_VARDIR/tmp/b19216.tmp
--disable_query_log
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/b19216.tmp >/dev/null
--enable_query_log
--echo End of 4.1 tests.