Loading Docs/manual.texi +37 −4 Original line number Diff line number Diff line Loading @@ -15430,6 +15430,8 @@ mysql> select 'new*\n*line' REGEXP 'new\\*.\\*line'; -> 1 mysql> select "a" REGEXP "A", "a" REGEXP BINARY "A"; -> 1 0 mysql> select "a" REGEXP "^[a-d]"; -> 1 @end example @item Loading Loading @@ -15495,6 +15497,16 @@ Note that in some context @strong{MySQL} will not be able to use the index efficiently when you cast an indexed column to @code{BINARY}. @end table If you want to compare a blob case-insensitively you can always convert the blob to upper case before doing the comparison: @example SELECT 'A' LIKE UPPER(blob_col) FROM table_name; @end example We plan to soon introduce casting between different character sets to make string comparison even more flexible. @findex control flow functions @findex functions, control flow @node Control flow functions, Mathematical functions, Casts, Functions Loading Loading @@ -18719,6 +18731,10 @@ name of the column in the @code{ORDER BY} clause that you are sorting by. The default is ascending order; this may be specified explicitly using the @code{ASC} keyword. @item You can in the @code{WHERE} clause use any of the functions that @strong{MySQL} support. @xref{Functions}. @item The @code{HAVING} clause can refer to any column or alias named in the @code{select_expression}. It is applied last, just before items are sent to Loading Loading @@ -18815,6 +18831,13 @@ cannot already exist (among other things, this prevents database tables and files such as @file{/etc/passwd} from being destroyed). You must have the @strong{file} privilege on the server host to use this form of @code{SELECT}. @code{SELECT ... INTO OUTFILE} is mainly intended to let you very quickly dump a table on the server machine. If you want to create the resulting file on some other host than the server host you can't use @code{SELECT ... INTO OUTFILE}. In this case you should instead use some client program like @code{mysqldump --tab} or @code{mysql -e "SELECT ..." > outfile} to generate the file. @code{SELECT ... INTO OUTFILE} is the complement of @code{LOAD DATA INFILE}; the syntax for the @code{export_options} part of the statement consists of the same @code{FIELDS} and @code{LINES} clauses that are used Loading @@ -18835,19 +18858,29 @@ Additionally, @code{ASCII 0} is converted to @code{ESCAPED BY} followed by 0 The reason for the above is that you MUST escape any @code{FIELDS TERMINATED BY}, @code{ESCAPED BY}, or @code{LINES TERMINATED BY} characters to reliably be able to read the file back. @code{ASCII 0} is escaped to make it easier to view with some pagers. characters to reliably be able to read the file back. @code{ASCII 0} is escaped to make it easier to view with some pagers. As the resulting file doesn't have to conform to the SQL syntax, nothing else need be escaped. @end itemize Here follows an example of getting a file in the format used by many old programs. @example SELECT a,b,a+b INTO OUTFILE "/tmp/result.text" FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY "\n" FROM test_table; @end example @item @findex DUMPFILE If you use @code{INTO DUMPFILE} instead of @code{INTO OUTFILE}, @strong{MySQL} will only write one row into the file, without any column or line terminations and without any escaping. This is useful if you want to store a blob in a file. @end itemize @findex JOIN @findex INNER JOIN client/mysqltest.c +48 −31 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ * Monty **/ #define MTEST_VERSION "1.2" #define MTEST_VERSION "1.4" #include "global.h" #include "my_sys.h" Loading @@ -50,7 +50,7 @@ #define MIN_VAR_ALLOC 32 #define BLOCK_STACK_DEPTH 32 int record = 0, verbose = 0, silent = 0; int record = 0, verbose = 0, silent = 0, opt_sleep=0; static char *db = 0, *pass=0; const char* user = 0, *host = 0, *unix_sock = 0; int port = 0; Loading @@ -62,6 +62,7 @@ FILE* file_stack[MAX_INCLUDE_DEPTH]; FILE** cur_file; FILE** file_stack_end; uint lineno_stack[MAX_INCLUDE_DEPTH]; char TMPDIR[FN_REFLEN]; int block_stack[BLOCK_STACK_DEPTH]; int *cur_block, *block_stack_end; Loading Loading @@ -494,16 +495,19 @@ int do_let(struct query* q) int do_sleep(struct query* q) { char* p, *arg; char *p; struct timeval t; int dec_mul = 1000000; p = (char*)q->q + q->first_word_len; while(*p && isspace(*p)) p++; if (!*p) die("Missing argument in sleep\n"); arg = p; t.tv_sec = atoi(arg); t.tv_usec = 0; if (opt_sleep) t.tv_sec = opt_sleep; else { t.tv_sec = atoi(p); while(*p && *p != '.' && !isspace(*p)) p++; if (*p == '.') Loading @@ -525,7 +529,7 @@ int do_sleep(struct query* q) break; } } *p = 0; } t.tv_usec *= dec_mul; return select(0,0,0,0, &t); } Loading Loading @@ -617,6 +621,7 @@ int do_connect(struct query* q) char* con_name, *con_user,*con_pass, *con_host, *con_port_str, *con_db, *con_sock; char* p; char buff[FN_REFLEN]; p = q->q + q->first_word_len; Loading @@ -636,6 +641,7 @@ int do_connect(struct query* q) if (!mysql_init(&next_con->mysql)) die("Failed on mysql_init()"); con_sock=fn_format(buff, con_sock, TMPDIR,"",0); if (!mysql_real_connect(&next_con->mysql, con_host, con_user, con_pass, con_db, atoi(con_port_str), con_sock, 0)) die("Could not open connection '%s': %s", con_name, Loading Loading @@ -952,19 +958,21 @@ int read_query(struct query** q_ptr) struct option long_options[] = { {"verbose", no_argument, 0, 'v'}, {"version", no_argument, 0, 'V'}, {"silent", no_argument, 0, 'q'}, {"database", required_argument, 0, 'D'}, {"help", no_argument, 0, '?'}, {"host", required_argument, 0, 'h'}, {"password", optional_argument, 0, 'p'}, {"port", required_argument, 0, 'P'}, {"quiet", no_argument, 0, 'q'}, {"record", no_argument, 0, 'r'}, {"result-file", required_argument, 0, 'R'}, {"help", no_argument, 0, '?'}, {"user", required_argument, 0, 'u'}, {"password", optional_argument, 0, 'p'}, {"host", required_argument, 0, 'h'}, {"silent", no_argument, 0, 'q'}, {"sleep", required_argument, 0, 'T'}, {"socket", required_argument, 0, 'S'}, {"database", required_argument, 0, 'D'}, {"port", required_argument, 0, 'P'}, {"tmpdir", required_argument, 0, 't'}, {"user", required_argument, 0, 'u'}, {"verbose", no_argument, 0, 'v'}, {"version", no_argument, 0, 'V'}, {0, 0,0,0} }; Loading @@ -991,6 +999,8 @@ void usage() -D, --database=... Database to use.\n\ -P, --port=... Port number to use for connection.\n\ -S, --socket=... Socket file to use for connection.\n\ -t, --tmpdir=... Temporary directory where sockets are put\n\ -T, --sleep=# Sleep always this many seconds on sleep commands\n\ -r, --record Record output of test_file into result file.\n\ -R, --result-file=... Read/Store result from/in this file.\n\ -v, --verbose Write more.\n\ Loading @@ -1006,7 +1016,7 @@ int parse_args(int argc, char **argv) load_defaults("my",load_default_groups,&argc,&argv); while((c = getopt_long(argc, argv, "h:p::u:P:D:S:R:?rvVq", while((c = getopt_long(argc, argv, "h:p::u:P:D:S:R:t:T:?rvVq", long_options, &option_index)) != EOF) { switch(c) Loading Loading @@ -1048,6 +1058,12 @@ int parse_args(int argc, char **argv) case 'q': silent = 1; break; case 't': strnmov(TMPDIR,optarg,sizeof(TMPDIR)); break; case 'T': opt_sleep=atoi(optarg); break; case 'V': print_version(); exit(0); Loading Loading @@ -1255,6 +1271,7 @@ int main(int argc, char** argv) my_bool require_file=0; char save_file[FN_REFLEN]; save_file[0]=0; TMPDIR[0]=0; MY_INIT(argv[0]); memset(cons, 0, sizeof(cons)); Loading mysql-test/README +4 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,10 @@ You can create your own test cases. To create a test case: We would appreciate if the test tables were called t1, t2, t3 ... (to not conflict too much with existing tables). Your test should begin by dropping the tables you are going to create and end by dropping them again. This will ensure that one can run the test over and over again. If you are using mysqltest commands (like result file names) in your test case you should do create the result file as follows: Loading mysql-test/include/have_default_master.inc 0 → 100644 +3 −0 Original line number Diff line number Diff line -- require r/have_default_master.require connection master; show variables like "port"; mysql-test/include/master-slave.inc +4 −4 Original line number Diff line number Diff line connect (master,localhost,root,,test,0,var/tmp/mysql.sock); connect (master1,localhost,root,,test,0,var/tmp/mysql.sock); connect (slave,localhost,root,,test,0,var/tmp/mysql-slave.sock); connect (slave1,localhost,root,,test,0,var/tmp/mysql-slave.sock); connect (master,localhost,root,,test,0,mysql-master.sock); connect (master1,localhost,root,,test,0,mysql-master.sock); connect (slave,localhost,root,,test,0,mysql-slave.sock); connect (slave1,localhost,root,,test,0,mysql-slave.sock); connection slave; !slave stop; @r/slave-stopped.result show status like 'Slave_running'; Loading Loading
Docs/manual.texi +37 −4 Original line number Diff line number Diff line Loading @@ -15430,6 +15430,8 @@ mysql> select 'new*\n*line' REGEXP 'new\\*.\\*line'; -> 1 mysql> select "a" REGEXP "A", "a" REGEXP BINARY "A"; -> 1 0 mysql> select "a" REGEXP "^[a-d]"; -> 1 @end example @item Loading Loading @@ -15495,6 +15497,16 @@ Note that in some context @strong{MySQL} will not be able to use the index efficiently when you cast an indexed column to @code{BINARY}. @end table If you want to compare a blob case-insensitively you can always convert the blob to upper case before doing the comparison: @example SELECT 'A' LIKE UPPER(blob_col) FROM table_name; @end example We plan to soon introduce casting between different character sets to make string comparison even more flexible. @findex control flow functions @findex functions, control flow @node Control flow functions, Mathematical functions, Casts, Functions Loading Loading @@ -18719,6 +18731,10 @@ name of the column in the @code{ORDER BY} clause that you are sorting by. The default is ascending order; this may be specified explicitly using the @code{ASC} keyword. @item You can in the @code{WHERE} clause use any of the functions that @strong{MySQL} support. @xref{Functions}. @item The @code{HAVING} clause can refer to any column or alias named in the @code{select_expression}. It is applied last, just before items are sent to Loading Loading @@ -18815,6 +18831,13 @@ cannot already exist (among other things, this prevents database tables and files such as @file{/etc/passwd} from being destroyed). You must have the @strong{file} privilege on the server host to use this form of @code{SELECT}. @code{SELECT ... INTO OUTFILE} is mainly intended to let you very quickly dump a table on the server machine. If you want to create the resulting file on some other host than the server host you can't use @code{SELECT ... INTO OUTFILE}. In this case you should instead use some client program like @code{mysqldump --tab} or @code{mysql -e "SELECT ..." > outfile} to generate the file. @code{SELECT ... INTO OUTFILE} is the complement of @code{LOAD DATA INFILE}; the syntax for the @code{export_options} part of the statement consists of the same @code{FIELDS} and @code{LINES} clauses that are used Loading @@ -18835,19 +18858,29 @@ Additionally, @code{ASCII 0} is converted to @code{ESCAPED BY} followed by 0 The reason for the above is that you MUST escape any @code{FIELDS TERMINATED BY}, @code{ESCAPED BY}, or @code{LINES TERMINATED BY} characters to reliably be able to read the file back. @code{ASCII 0} is escaped to make it easier to view with some pagers. characters to reliably be able to read the file back. @code{ASCII 0} is escaped to make it easier to view with some pagers. As the resulting file doesn't have to conform to the SQL syntax, nothing else need be escaped. @end itemize Here follows an example of getting a file in the format used by many old programs. @example SELECT a,b,a+b INTO OUTFILE "/tmp/result.text" FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY "\n" FROM test_table; @end example @item @findex DUMPFILE If you use @code{INTO DUMPFILE} instead of @code{INTO OUTFILE}, @strong{MySQL} will only write one row into the file, without any column or line terminations and without any escaping. This is useful if you want to store a blob in a file. @end itemize @findex JOIN @findex INNER JOIN
client/mysqltest.c +48 −31 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ * Monty **/ #define MTEST_VERSION "1.2" #define MTEST_VERSION "1.4" #include "global.h" #include "my_sys.h" Loading @@ -50,7 +50,7 @@ #define MIN_VAR_ALLOC 32 #define BLOCK_STACK_DEPTH 32 int record = 0, verbose = 0, silent = 0; int record = 0, verbose = 0, silent = 0, opt_sleep=0; static char *db = 0, *pass=0; const char* user = 0, *host = 0, *unix_sock = 0; int port = 0; Loading @@ -62,6 +62,7 @@ FILE* file_stack[MAX_INCLUDE_DEPTH]; FILE** cur_file; FILE** file_stack_end; uint lineno_stack[MAX_INCLUDE_DEPTH]; char TMPDIR[FN_REFLEN]; int block_stack[BLOCK_STACK_DEPTH]; int *cur_block, *block_stack_end; Loading Loading @@ -494,16 +495,19 @@ int do_let(struct query* q) int do_sleep(struct query* q) { char* p, *arg; char *p; struct timeval t; int dec_mul = 1000000; p = (char*)q->q + q->first_word_len; while(*p && isspace(*p)) p++; if (!*p) die("Missing argument in sleep\n"); arg = p; t.tv_sec = atoi(arg); t.tv_usec = 0; if (opt_sleep) t.tv_sec = opt_sleep; else { t.tv_sec = atoi(p); while(*p && *p != '.' && !isspace(*p)) p++; if (*p == '.') Loading @@ -525,7 +529,7 @@ int do_sleep(struct query* q) break; } } *p = 0; } t.tv_usec *= dec_mul; return select(0,0,0,0, &t); } Loading Loading @@ -617,6 +621,7 @@ int do_connect(struct query* q) char* con_name, *con_user,*con_pass, *con_host, *con_port_str, *con_db, *con_sock; char* p; char buff[FN_REFLEN]; p = q->q + q->first_word_len; Loading @@ -636,6 +641,7 @@ int do_connect(struct query* q) if (!mysql_init(&next_con->mysql)) die("Failed on mysql_init()"); con_sock=fn_format(buff, con_sock, TMPDIR,"",0); if (!mysql_real_connect(&next_con->mysql, con_host, con_user, con_pass, con_db, atoi(con_port_str), con_sock, 0)) die("Could not open connection '%s': %s", con_name, Loading Loading @@ -952,19 +958,21 @@ int read_query(struct query** q_ptr) struct option long_options[] = { {"verbose", no_argument, 0, 'v'}, {"version", no_argument, 0, 'V'}, {"silent", no_argument, 0, 'q'}, {"database", required_argument, 0, 'D'}, {"help", no_argument, 0, '?'}, {"host", required_argument, 0, 'h'}, {"password", optional_argument, 0, 'p'}, {"port", required_argument, 0, 'P'}, {"quiet", no_argument, 0, 'q'}, {"record", no_argument, 0, 'r'}, {"result-file", required_argument, 0, 'R'}, {"help", no_argument, 0, '?'}, {"user", required_argument, 0, 'u'}, {"password", optional_argument, 0, 'p'}, {"host", required_argument, 0, 'h'}, {"silent", no_argument, 0, 'q'}, {"sleep", required_argument, 0, 'T'}, {"socket", required_argument, 0, 'S'}, {"database", required_argument, 0, 'D'}, {"port", required_argument, 0, 'P'}, {"tmpdir", required_argument, 0, 't'}, {"user", required_argument, 0, 'u'}, {"verbose", no_argument, 0, 'v'}, {"version", no_argument, 0, 'V'}, {0, 0,0,0} }; Loading @@ -991,6 +999,8 @@ void usage() -D, --database=... Database to use.\n\ -P, --port=... Port number to use for connection.\n\ -S, --socket=... Socket file to use for connection.\n\ -t, --tmpdir=... Temporary directory where sockets are put\n\ -T, --sleep=# Sleep always this many seconds on sleep commands\n\ -r, --record Record output of test_file into result file.\n\ -R, --result-file=... Read/Store result from/in this file.\n\ -v, --verbose Write more.\n\ Loading @@ -1006,7 +1016,7 @@ int parse_args(int argc, char **argv) load_defaults("my",load_default_groups,&argc,&argv); while((c = getopt_long(argc, argv, "h:p::u:P:D:S:R:?rvVq", while((c = getopt_long(argc, argv, "h:p::u:P:D:S:R:t:T:?rvVq", long_options, &option_index)) != EOF) { switch(c) Loading Loading @@ -1048,6 +1058,12 @@ int parse_args(int argc, char **argv) case 'q': silent = 1; break; case 't': strnmov(TMPDIR,optarg,sizeof(TMPDIR)); break; case 'T': opt_sleep=atoi(optarg); break; case 'V': print_version(); exit(0); Loading Loading @@ -1255,6 +1271,7 @@ int main(int argc, char** argv) my_bool require_file=0; char save_file[FN_REFLEN]; save_file[0]=0; TMPDIR[0]=0; MY_INIT(argv[0]); memset(cons, 0, sizeof(cons)); Loading
mysql-test/README +4 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,10 @@ You can create your own test cases. To create a test case: We would appreciate if the test tables were called t1, t2, t3 ... (to not conflict too much with existing tables). Your test should begin by dropping the tables you are going to create and end by dropping them again. This will ensure that one can run the test over and over again. If you are using mysqltest commands (like result file names) in your test case you should do create the result file as follows: Loading
mysql-test/include/have_default_master.inc 0 → 100644 +3 −0 Original line number Diff line number Diff line -- require r/have_default_master.require connection master; show variables like "port";
mysql-test/include/master-slave.inc +4 −4 Original line number Diff line number Diff line connect (master,localhost,root,,test,0,var/tmp/mysql.sock); connect (master1,localhost,root,,test,0,var/tmp/mysql.sock); connect (slave,localhost,root,,test,0,var/tmp/mysql-slave.sock); connect (slave1,localhost,root,,test,0,var/tmp/mysql-slave.sock); connect (master,localhost,root,,test,0,mysql-master.sock); connect (master1,localhost,root,,test,0,mysql-master.sock); connect (slave,localhost,root,,test,0,mysql-slave.sock); connect (slave1,localhost,root,,test,0,mysql-slave.sock); connection slave; !slave stop; @r/slave-stopped.result show status like 'Slave_running'; Loading