mysqltest.c
上传用户:romrleung
上传日期:2022-05-23
资源大小:18897k
文件大小:133k
- /* Copyright (C) 2000 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
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
- /* mysqltest test tool
- * See the manual for more information
- * TODO: document better how mysqltest works
- *
- * Written by:
- * Sasha Pachev <sasha@mysql.com>
- * Matt Wagner <matt@mysql.com>
- * Monty
- * Jani
- **/
- /**********************************************************************
- TODO:
- - Do comparison line by line, instead of doing a full comparison of
- the text file. This will save space as we don't need to keep many
- results in memory. It will also make it possible to do simple
- 'comparison' fixes like accepting the result even if a float differed
- in the last decimals.
- - Don't buffer lines from the test that you don't expect to need
- again.
- - Change 'read_line' to be faster by using the readline.cc code;
- We can do better than calling feof() for each character!
- **********************************************************************/
- #define MTEST_VERSION "2.5"
- #include <my_global.h>
- #include <mysql_embed.h>
- #include <my_sys.h>
- #include <m_string.h>
- #include <mysql.h>
- #include <mysql_version.h>
- #include <mysqld_error.h>
- #include <m_ctype.h>
- #include <my_dir.h>
- #include <errmsg.h> /* Error codes */
- #include <hash.h>
- #include <my_getopt.h>
- #include <stdarg.h>
- #include <sys/stat.h>
- #include <violite.h>
- #include "my_regex.h" /* Our own version of lib */
- #ifdef HAVE_SYS_WAIT_H
- #include <sys/wait.h>
- #endif
- #ifndef WEXITSTATUS
- # ifdef __WIN__
- # define WEXITSTATUS(stat_val) (stat_val)
- # else
- # define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
- # endif
- #endif
- #define MAX_QUERY 131072
- #define MAX_VAR_NAME 256
- #define MAX_COLUMNS 256
- #define PAD_SIZE 128
- #define MAX_CONS 128
- #define MAX_INCLUDE_DEPTH 16
- #define LAZY_GUESS_BUF_SIZE 8192
- #define INIT_Q_LINES 1024
- #define MIN_VAR_ALLOC 32
- #define BLOCK_STACK_DEPTH 32
- #define MAX_EXPECTED_ERRORS 10
- #define QUERY_SEND 1
- #define QUERY_REAP 2
- #ifndef MYSQL_MANAGER_PORT
- #define MYSQL_MANAGER_PORT 23546
- #endif
- #define MAX_SERVER_ARGS 64
- /*
- Sometimes in a test the client starts before
- the server - to solve the problem, we try again
- after some sleep if connection fails the first
- time
- */
- #define CON_RETRY_SLEEP 2
- #define MAX_CON_TRIES 5
- #define SLAVE_POLL_INTERVAL 300000 /* 0.3 of a sec */
- #define DEFAULT_DELIMITER ";"
- #define MAX_DELIMITER 16
- #define RESULT_OK 0
- #define RESULT_CONTENT_MISMATCH 1
- #define RESULT_LENGTH_MISMATCH 2
- enum {OPT_MANAGER_USER=256,OPT_MANAGER_HOST,OPT_MANAGER_PASSWD,
- OPT_MANAGER_PORT,OPT_MANAGER_WAIT_TIMEOUT, OPT_SKIP_SAFEMALLOC,
- OPT_SSL_SSL, OPT_SSL_KEY, OPT_SSL_CERT, OPT_SSL_CA, OPT_SSL_CAPATH,
- OPT_SSL_CIPHER,OPT_PS_PROTOCOL};
- /* ************************************************************************ */
- /*
- The list of error codes to --error are stored in an internal array of
- structs. This struct can hold numeric SQL error codes or SQLSTATE codes
- as strings. The element next to the last active element in the list is
- set to type ERR_EMPTY. When an SQL statement return an error we use
- this list to check if this is an expected error.
- */
-
- enum match_err_type
- {
- ERR_EMPTY= 0,
- ERR_ERRNO,
- ERR_SQLSTATE
- };
- typedef struct
- {
- enum match_err_type type;
- union
- {
- uint errnum;
- char sqlstate[SQLSTATE_LENGTH+1]; /*