The world's most popular open source database
#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>#include <hash.h>#include <my_getopt.h>#include <stdarg.h>#include <sys/stat.h>#include <violite.h>#include "my_regex.h"#include <mysqld_ername.h>#include "sslopt-vars.h"#include "sslopt-longopts.h"#include <help_start.h>#include <help_end.h>#include <sslopt-case.h>Include dependency graph for mysqltest.c:

Go to the source code of this file.
| #define BLOCK_STACK_DEPTH 32 |
| #define DEFAULT_DELIMITER ";" |
Definition at line 89 of file mysqltest.c.
| #define END_OF_LINE 258 |
| #define INIT_Q_LINES 1024 |
| #define LAST_CHAR_CODE 259 |
| #define MAX_COLUMNS 256 |
| #define MAX_CONS 128 |
| #define MAX_DELIMITER 16 |
| #define MAX_EXPECTED_ERRORS 10 |
Definition at line 82 of file mysqltest.c.
| #define MAX_INCLUDE_DEPTH 16 |
| #define MAX_QUERY (256*1024) |
Definition at line 74 of file mysqltest.c.
| #define MAX_SERVER_ARGS 64 |
Definition at line 85 of file mysqltest.c.
Referenced by get_one_option(), and read_server_arguments().
| #define MAX_VAR_NAME 256 |
| #define MIN_VAR_ALLOC 32 |
| #define MTEST_VERSION "2.6" |
| #define PARSE_REGEX_ARG |
Value:
while (p < expr_end) \ {\ char c= *p;\ if (c == '/')\ {\ if (last_c == '\\')\ {\ buf_p[-1]= '/';\ }\ else\ {\ *buf_p++ = 0;\ break;\ } \ } \ else\ *buf_p++ = c;\ \ last_c= c;\ p++;\ } \
Definition at line 2039 of file mysqltest.c.
Referenced by init_replace_regex().
| #define PC_MALLOC 256 |
| #define PS_MALLOC 512 |
| #define QUERY_REAP 2 |
Definition at line 84 of file mysqltest.c.
Referenced by main(), run_query(), and run_query_normal().
| #define QUERY_SEND 1 |
Definition at line 83 of file mysqltest.c.
Referenced by main(), run_query(), and run_query_normal().
| #define RESULT_CONTENT_MISMATCH 1 |
| #define RESULT_LENGTH_MISMATCH 2 |
| #define RESULT_OK 0 |
| #define SECURE_REG_BUF |
Value:
if (buf_len < need_buf_len)\ {\ int off= res_p - buf;\ buf= (char*)my_realloc(buf,need_buf_len,MYF(MY_WME+MY_FAE));\ res_p= buf + off;\ buf_len= need_buf_len;\ }\
Definition at line 3505 of file mysqltest.c.
Referenced by reg_replace().
| #define SET_MALLOC_HUNC 64 |
| #define SLAVE_POLL_INTERVAL 300000 |
| #define SPACE_CHAR 256 |
| #define START_OF_LINE 257 |
| #define WEXITSTATUS | ( | stat_val | ) | ((unsigned)(stat_val) >> 8) |
| #define WORD_BIT (8*sizeof(uint)) |
Definition at line 5656 of file mysqltest.c.
Referenced by get_next_bit(), internal_clear_bit(), and internal_set_bit().
| typedef struct st_found_set FOUND_SET |
| typedef struct st_pointer_array POINTER_ARRAY |
| typedef struct st_rep_set REP_SET |
| typedef struct st_rep_sets REP_SETS |
| typedef struct st_replace REPLACE |
| typedef struct st_replace_found REPLACE_STRING |
| anonymous enum |
Definition at line 96 of file mysqltest.c.
00096 {OPT_SKIP_SAFEMALLOC=256, OPT_SSL_SSL, OPT_SSL_KEY, OPT_SSL_CERT, 00097 OPT_SSL_CA, OPT_SSL_CAPATH, OPT_SSL_CIPHER, OPT_PS_PROTOCOL, 00098 OPT_SP_PROTOCOL, OPT_CURSOR_PROTOCOL, OPT_VIEW_PROTOCOL, 00099 OPT_SSL_VERIFY_SERVER_CERT, OPT_MAX_CONNECT_RETRIES, 00100 OPT_MARK_PROGRESS};
| enum block_cmd |
| enum enum_commands |
Definition at line 310 of file mysqltest.c.
00310 { 00311 Q_CONNECTION=1, Q_QUERY, 00312 Q_CONNECT, Q_SLEEP, Q_REAL_SLEEP, 00313 Q_INC, Q_DEC, 00314 Q_SOURCE, Q_DISCONNECT, 00315 Q_LET, Q_ECHO, 00316 Q_WHILE, Q_END_BLOCK, 00317 Q_SYSTEM, Q_RESULT, 00318 Q_REQUIRE, Q_SAVE_MASTER_POS, 00319 Q_SYNC_WITH_MASTER, 00320 Q_SYNC_SLAVE_WITH_MASTER, 00321 Q_ERROR, 00322 Q_SEND, Q_REAP, 00323 Q_DIRTY_CLOSE, Q_REPLACE, Q_REPLACE_COLUMN, 00324 Q_PING, Q_EVAL, 00325 Q_RPL_PROBE, Q_ENABLE_RPL_PARSE, 00326 Q_DISABLE_RPL_PARSE, Q_EVAL_RESULT, 00327 Q_ENABLE_QUERY_LOG, Q_DISABLE_QUERY_LOG, 00328 Q_ENABLE_RESULT_LOG, Q_DISABLE_RESULT_LOG, 00329 Q_WAIT_FOR_SLAVE_TO_STOP, 00330 Q_ENABLE_WARNINGS, Q_DISABLE_WARNINGS, 00331 Q_ENABLE_PS_WARNINGS, Q_DISABLE_PS_WARNINGS, 00332 Q_ENABLE_INFO, Q_DISABLE_INFO, 00333 Q_ENABLE_METADATA, Q_DISABLE_METADATA, 00334 Q_EXEC, Q_DELIMITER, 00335 Q_DISABLE_ABORT_ON_ERROR, Q_ENABLE_ABORT_ON_ERROR, 00336 Q_DISPLAY_VERTICAL_RESULTS, Q_DISPLAY_HORIZONTAL_RESULTS, 00337 Q_QUERY_VERTICAL, Q_QUERY_HORIZONTAL, 00338 Q_START_TIMER, Q_END_TIMER, 00339 Q_CHARACTER_SET, Q_DISABLE_PS_PROTOCOL, Q_ENABLE_PS_PROTOCOL, 00340 Q_DISABLE_RECONNECT, Q_ENABLE_RECONNECT, 00341 Q_IF, 00342 Q_DISABLE_PARSING, Q_ENABLE_PARSING, 00343 Q_REPLACE_REGEX, Q_DIE, 00344 00345 Q_UNKNOWN, /* Unknown command. */ 00346 Q_COMMENT, /* Comments, ignored. */ 00347 Q_COMMENT_WITH_COMMAND 00348 };
| enum enum_operator |
| enum match_err_type |
Definition at line 111 of file mysqltest.c.
00112 { 00113 ERR_EMPTY= 0, 00114 ERR_ERRNO, 00115 ERR_SQLSTATE 00116 };
| static void abort_not_supported_test | ( | const char * | fmt, | |
| ... | ||||
| ) | [static] |
Definition at line 669 of file mysqltest.c.
References args, cur_file, DBUG_ENTER, exit, test_file::file_name, file_stack, free_used_memory(), test_file::lineno, MY_CHECK_ERROR, my_end(), and silent.
Referenced by check_result(), handle_error(), and set_charset().
00670 { 00671 va_list args; 00672 test_file* err_file= cur_file; 00673 DBUG_ENTER("abort_not_supported_test"); 00674 00675 /* Print include filestack */ 00676 fprintf(stderr, "The test '%s' is not supported by this installation\n", 00677 file_stack->file_name); 00678 fprintf(stderr, "Detected in file %s at line %d\n", 00679 err_file->file_name, err_file->lineno); 00680 while (err_file != file_stack) 00681 { 00682 err_file--; 00683 fprintf(stderr, "included from %s at line %d\n", 00684 err_file->file_name, err_file->lineno); 00685 } 00686 00687 /* Print error message */ 00688 va_start(args, fmt); 00689 if (fmt) 00690 { 00691 fprintf(stderr, "reason: "); 00692 vfprintf(stderr, fmt, args); 00693 fprintf(stderr, "\n"); 00694 fflush(stderr); 00695 } 00696 va_end(args); 00697 00698 /* Clean up and exit */ 00699 free_used_memory(); 00700 my_end(MY_CHECK_ERROR); 00701 00702 if (!silent) 00703 printf("skipped\n"); 00704 00705 exit(62); 00706 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void append_field | ( | DYNAMIC_STRING * | ds, | |
| uint | col_idx, | |||
| MYSQL_FIELD * | field, | |||
| const char * | val, | |||
| ulonglong | len, | |||
| bool | is_null | |||
| ) | [static] |
Definition at line 3842 of file mysqltest.c.
References st_mysql_field::decimals, display_result_vertically, dynstr_append(), dynstr_append_mem(), max_replace_column, memmove, MYSQL_TYPE_DOUBLE, MYSQL_TYPE_FLOAT, st_mysql_field::name, replace_column, replace_dynstr_append_mem(), start(), strchr(), strlen(), and st_mysql_field::type.
Referenced by append_result(), and append_stmt_result().
03844 { 03845 if (col_idx < max_replace_column && replace_column[col_idx]) 03846 { 03847 val= replace_column[col_idx]; 03848 len= strlen(val); 03849 } 03850 else if (is_null) 03851 { 03852 val= "NULL"; 03853 len= 4; 03854 } 03855 #ifdef __WIN__ 03856 else if ((field->type == MYSQL_TYPE_DOUBLE || 03857 field->type == MYSQL_TYPE_FLOAT ) && 03858 field->decimals >= 31) 03859 { 03860 /* Convert 1.2e+018 to 1.2e+18 and 1.2e-018 to 1.2e-18 */ 03861 char *start= strchr(val, 'e'); 03862 if (start && strlen(start) >= 5 && 03863 (start[1] == '-' || start[1] == '+') && start[2] == '0') 03864 { 03865 start+=2; /* Now points at first '0' */ 03866 /* Move all chars after the first '0' one step left */ 03867 memmove(start, start + 1, strlen(start)); 03868 len--; 03869 } 03870 } 03871 #endif 03872 03873 if (!display_result_vertically) 03874 { 03875 if (col_idx) 03876 dynstr_append_mem(ds, "\t", 1); 03877 replace_dynstr_append_mem(ds, val, (int)len); 03878 } 03879 else 03880 { 03881 dynstr_append(ds, field->name); 03882 dynstr_append_mem(ds, "\t", 1); 03883 replace_dynstr_append_mem(ds, val, (int)len); 03884 dynstr_append_mem(ds, "\n", 1); 03885 } 03886 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void append_info | ( | DYNAMIC_STRING * | ds, | |
| ulonglong | affected_rows, | |||
| const char * | info | |||
| ) | [static] |
Definition at line 4045 of file mysqltest.c.
References buf, dynstr_append(), dynstr_append_mem(), and llstr().
Referenced by run_query_normal(), and run_query_stmt().
04047 { 04048 char buf[40], buff2[21]; 04049 sprintf(buf,"affected rows: %s\n", llstr(affected_rows, buff2)); 04050 dynstr_append(ds, buf); 04051 if (info) 04052 { 04053 dynstr_append(ds, "info: "); 04054 dynstr_append(ds, info); 04055 dynstr_append_mem(ds, "\n", 1); 04056 } 04057 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void append_metadata | ( | DYNAMIC_STRING * | ds, | |
| MYSQL_FIELD * | field, | |||
| uint | num_fields | |||
| ) | [static] |
Definition at line 3985 of file mysqltest.c.
References st_mysql_field::catalog, st_mysql_field::catalog_length, st_mysql_field::charsetnr, st_mysql_field::db, st_mysql_field::db_length, st_mysql_field::decimals, dynstr_append(), dynstr_append_mem(), st_mysql_field::flags, int10_to_str(), IS_NOT_NULL, st_mysql_field::length, longlong10_to_str, st_mysql_field::max_length, st_mysql_field::name, st_mysql_field::name_length, st_mysql_field::org_name, st_mysql_field::org_name_length, st_mysql_field::org_table, st_mysql_field::org_table_length, st_mysql_field::table, st_mysql_field::table_length, and st_mysql_field::type.
Referenced by run_query_normal(), and run_query_stmt().
03988 { 03989 MYSQL_FIELD *field_end; 03990 dynstr_append(ds,"Catalog\tDatabase\tTable\tTable_alias\tColumn\t" 03991 "Column_alias\tType\tLength\tMax length\tIs_null\t" 03992 "Flags\tDecimals\tCharsetnr\n"); 03993 03994 for (field_end= field+num_fields ; 03995 field < field_end ; 03996 field++) 03997 { 03998 char buff[22]; 03999 dynstr_append_mem(ds, field->catalog, 04000 field->catalog_length); 04001 dynstr_append_mem(ds, "\t", 1); 04002 dynstr_append_mem(ds, field->db, field->db_length); 04003 dynstr_append_mem(ds, "\t", 1); 04004 dynstr_append_mem(ds, field->org_table, 04005 field->org_table_length); 04006 dynstr_append_mem(ds, "\t", 1); 04007 dynstr_append_mem(ds, field->table, 04008 field->table_length); 04009 dynstr_append_mem(ds, "\t", 1); 04010 dynstr_append_mem(ds, field->org_name, 04011 field->org_name_length); 04012 dynstr_append_mem(ds, "\t", 1); 04013 dynstr_append_mem(ds, field->name, field->name_length); 04014 dynstr_append_mem(ds, "\t", 1); 04015 int10_to_str((int) field->type, buff, 10); 04016 dynstr_append(ds, buff); 04017 dynstr_append_mem(ds, "\t", 1); 04018 longlong10_to_str((unsigned int) field->length, buff, 10); 04019 dynstr_append(ds, buff); 04020 dynstr_append_mem(ds, "\t", 1); 04021 longlong10_to_str((unsigned int) field->max_length, buff, 10); 04022 dynstr_append(ds, buff); 04023 dynstr_append_mem(ds, "\t", 1); 04024 dynstr_append_mem(ds, (char*) (IS_NOT_NULL(field->flags) ? 04025 "N" : "Y"), 1); 04026 dynstr_append_mem(ds, "\t", 1); 04027 04028 int10_to_str((int) field->flags, buff, 10); 04029 dynstr_append(ds, buff); 04030 dynstr_append_mem(ds, "\t", 1); 04031 int10_to_str((int) field->decimals, buff, 10); 04032 dynstr_append(ds, buff); 04033 dynstr_append_mem(ds, "\t", 1); 04034 int10_to_str((int) field->charsetnr, buff, 10); 04035 dynstr_append(ds, buff); 04036 dynstr_append_mem(ds, "\n", 1); 04037 } 04038 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void append_result | ( | DYNAMIC_STRING * | ds, | |
| MYSQL_RES * | res | |||
| ) | [static] |
Definition at line 3894 of file mysqltest.c.
References append_field(), display_result_vertically, dynstr_append_mem(), free_replace_column(), lengths, mysql_fetch_fields(), mysql_fetch_lengths(), mysql_fetch_row(), and mysql_num_fields().
Referenced by append_warnings(), and run_query_normal().
03895 { 03896 MYSQL_ROW row; 03897 uint num_fields= mysql_num_fields(res); 03898 MYSQL_FIELD *fields= mysql_fetch_fields(res); 03899 ulong *lengths; 03900 03901 while ((row = mysql_fetch_row(res))) 03902 { 03903 uint i; 03904 lengths = mysql_fetch_lengths(res); 03905 for (i = 0; i < num_fields; i++) 03906 append_field(ds, i, &fields[i], 03907 (const char*)row[i], lengths[i], !row[i]); 03908 if (!display_result_vertically) 03909 dynstr_append_mem(ds, "\n", 1); 03910 } 03911 free_replace_column(); 03912 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void append_stmt_result | ( | DYNAMIC_STRING * | ds, | |
| MYSQL_STMT * | stmt, | |||
| MYSQL_FIELD * | fields, | |||
| uint | num_fields | |||
| ) | [static] |
Definition at line 3920 of file mysqltest.c.
References append_field(), buffer, st_mysql_bind::buffer, st_mysql_bind::buffer_length, st_mysql_bind::buffer_type, DBUG_PRINT, die(), display_result_vertically, dynstr_append_mem(), free_replace_column(), st_mysql_bind::is_null, st_mysql_bind::length, MY_FAE, my_free, my_malloc(), MY_WME, MY_ZEROFILL, MYF, MYSQL_NO_DATA, mysql_stmt_bind_result(), mysql_stmt_errno(), mysql_stmt_error(), mysql_stmt_fetch(), and MYSQL_TYPE_STRING.
Referenced by run_query_stmt().
03922 { 03923 MYSQL_BIND *bind; 03924 my_bool *is_null; 03925 ulong *length; 03926 uint i; 03927 03928 /* Allocate array with bind structs, lengths and NULL flags */ 03929 bind= (MYSQL_BIND*) my_malloc(num_fields * sizeof(MYSQL_BIND), 03930 MYF(MY_WME | MY_FAE | MY_ZEROFILL)); 03931 length= (ulong*) my_malloc(num_fields * sizeof(ulong), 03932 MYF(MY_WME | MY_FAE)); 03933 is_null= (my_bool*) my_malloc(num_fields * sizeof(my_bool), 03934 MYF(MY_WME | MY_FAE)); 03935 03936 /* Allocate data for the result of each field */ 03937 for (i= 0; i < num_fields; i++) 03938 { 03939 uint max_length= fields[i].max_length + 1; 03940 bind[i].buffer_type= MYSQL_TYPE_STRING; 03941 bind[i].buffer= (char *)my_malloc(max_length, MYF(MY_WME | MY_FAE)); 03942 bind[i].buffer_length= max_length; 03943 bind[i].is_null= &is_null[i]; 03944 bind[i].length= &length[i]; 03945 03946 DBUG_PRINT("bind", ("col[%d]: buffer_type: %d, buffer_length: %d", 03947 i, bind[i].buffer_type, bind[i].buffer_length)); 03948 } 03949 03950 if (mysql_stmt_bind_result(stmt, bind)) 03951 die("mysql_stmt_bind_result failed: %d: %s", 03952 mysql_stmt_errno(stmt), mysql_stmt_error(stmt)); 03953 03954 while (mysql_stmt_fetch(stmt) == 0) 03955 { 03956 for (i= 0; i < num_fields; i++) 03957 append_field(ds, i, &fields[i], (const char *) bind[i].buffer, 03958 *bind[i].length, *bind[i].is_null); 03959 if (!display_result_vertically) 03960 dynstr_append_mem(ds, "\n", 1); 03961 } 03962 03963 if (mysql_stmt_fetch(stmt) != MYSQL_NO_DATA) 03964 die("fetch didn't end with MYSQL_NO_DATA from statement: %d %s", 03965 mysql_stmt_errno(stmt), mysql_stmt_error(stmt)); 03966 03967 free_replace_column(); 03968 03969 for (i= 0; i < num_fields; i++) 03970 { 03971 /* Free data for output */ 03972 my_free((gptr)bind[i].buffer, MYF(MY_WME | MY_FAE)); 03973 } 03974 /* Free array with bind structs, lengths and NULL flags */ 03975 my_free((gptr)bind , MYF(MY_WME | MY_FAE)); 03976 my_free((gptr)length , MYF(MY_WME | MY_FAE)); 03977 my_free((gptr)is_null , MYF(MY_WME | MY_FAE)); 03978 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void append_table_headings | ( | DYNAMIC_STRING * | ds, | |
| MYSQL_FIELD * | field, | |||
| uint | num_fields | |||
| ) | [static] |
Definition at line 4064 of file mysqltest.c.
References dynstr_append_mem(), name, and replace_dynstr_append().
Referenced by run_query_normal(), and run_query_stmt().
04067 { 04068 uint col_idx; 04069 for (col_idx= 0; col_idx < num_fields; col_idx++) 04070 { 04071 if (col_idx) 04072 dynstr_append_mem(ds, "\t", 1); 04073 replace_dynstr_append(ds, field[col_idx].name); 04074 } 04075 dynstr_append_mem(ds, "\n", 1); 04076 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static int append_warnings | ( | DYNAMIC_STRING * | ds, | |
| MYSQL * | mysql | |||
| ) | [static] |
Definition at line 4085 of file mysqltest.c.
References append_result(), count, DBUG_ASSERT, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, die(), mysql, mysql_error(), mysql_free_result(), mysql_more_results(), mysql_real_query(), mysql_store_result(), mysql_warning_count(), and st_dynamic_string::str.
Referenced by run_query(), run_query_normal(), and run_query_stmt().
04086 { 04087 uint count; 04088 MYSQL_RES *warn_res; 04089 DBUG_ENTER("append_warnings"); 04090 04091 if (!(count= mysql_warning_count(mysql))) 04092 DBUG_RETURN(0); 04093 04094 /* 04095 If one day we will support execution of multi-statements 04096 through PS API we should not issue SHOW WARNINGS until 04097 we have not read all results... 04098 */ 04099 DBUG_ASSERT(!mysql_more_results(mysql)); 04100 04101 if (mysql_real_query(mysql, "SHOW WARNINGS", 13)) 04102 die("Error running query \"SHOW WARNINGS\": %s", mysql_error(mysql)); 04103 04104 if (!(warn_res= mysql_store_result(mysql))) 04105 die("Warning count is %u but didn't get any warnings", 04106 count); 04107 04108 append_result(ds, warn_res); 04109 mysql_free_result(warn_res); 04110 04111 DBUG_PRINT("warnings", ("%s", ds->str)); 04112 04113 DBUG_RETURN(count); 04114 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int check_eol_junk | ( | const char * | eol | ) |
Definition at line 994 of file mysqltest.c.
References charset_info, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, delimiter, delimiter_length, die(), my_isspace, and p.
Referenced by main(), and read_query().
00995 { 00996 const char *p= eol; 00997 DBUG_ENTER("check_eol_junk"); 00998 DBUG_PRINT("enter", ("eol: %s", eol)); 00999 /* Remove all spacing chars except new line */ 01000 while (*p && my_isspace(charset_info, *p) && (*p != '\n')) 01001 p++; 01002 01003 /* Check for extra delimiter */ 01004 if (*p && !strncmp(p, delimiter, delimiter_length)) 01005 die("Extra delimiter \"%s\" found", delimiter); 01006 01007 /* Allow trailing # comment */ 01008 if (*p && *p != '#') 01009 { 01010 if (*p == '\n') 01011 die("Missing delimiter"); 01012 die("End of line junk detected: \"%s\"", p); 01013 } 01014 DBUG_RETURN(0); 01015 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void check_regerr | ( | my_regex_t * | r, | |
| int | err | |||
| ) | [static] |
Definition at line 3490 of file mysqltest.c.
References die(), and my_regerror().
Referenced by reg_replace().
03491 { 03492 char err_buf[1024]; 03493 03494 if (err) 03495 { 03496 my_regerror(err,r,err_buf,sizeof(err_buf)); 03497 die("Regex error: %s\n", err_buf); 03498 } 03499 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void check_result | ( | DYNAMIC_STRING * | ds, | |
| const char * | fname, | |||
| my_bool | require_option | |||
| ) | [static] |
Definition at line 817 of file mysqltest.c.
References abort_not_supported_test(), DBUG_ENTER, DBUG_VOID_RETURN, die(), dump_result_to_reject_file(), dyn_string_cmp(), fn_format(), FN_REFLEN, st_dynamic_string::length, MY_REPLACE_DIR, MY_REPLACE_EXT, RESULT_CONTENT_MISMATCH, RESULT_LENGTH_MISMATCH, RESULT_OK, and st_dynamic_string::str.
00819 { 00820 int res= dyn_string_cmp(ds, fname); 00821 DBUG_ENTER("check_result"); 00822 00823 if (res && require_option) 00824 { 00825 char reason[FN_REFLEN]; 00826 fn_format(reason, fname, "", "", MY_REPLACE_EXT | MY_REPLACE_DIR); 00827 abort_not_supported_test("Test requires: '%s'", reason); 00828 } 00829 switch (res) { 00830 case RESULT_OK: 00831 break; /* ok */ 00832 case RESULT_LENGTH_MISMATCH: 00833 dump_result_to_reject_file(fname, ds->str, ds->length); 00834 die("Result length mismatch"); 00835 break; 00836 case RESULT_CONTENT_MISMATCH: 00837 dump_result_to_reject_file(fname, ds->str, ds->length); 00838 die("Result content mismatch"); 00839 break; 00840 default: /* impossible */ 00841 die("Unknown error code from dyn_string_cmp()"); 00842 } 00843 00844 DBUG_VOID_RETURN; 00845 }
Here is the call graph for this function:

| int close_connection | ( | struct st_query * | ) |
Definition at line 2349 of file mysqltest.c.
References charset_info, cons, DBUG_ENTER, DBUG_PRINT, die(), st_query::first_argument, st_query::last_argument, my_isspace, connection::mysql, connection::name, name, st_mysql::net, next_con, p, Q_DIRTY_CLOSE, strcmp(), st_query::type, st_net::vio, and vio_delete.
Referenced by close_connections(), create_new_thread(), dispatch_command(), handle_bootstrap(), handle_one_connection(), and main().
02350 { 02351 char *p= q->first_argument, *name; 02352 struct connection *con; 02353 DBUG_ENTER("close_connection"); 02354 DBUG_PRINT("enter",("name: '%s'",p)); 02355 02356 if (!*p) 02357 die("Missing connection name in disconnect"); 02358 name= p; 02359 while (*p && !my_isspace(charset_info,*p)) 02360 p++; 02361 02362 if (*p) 02363 *p++= 0; 02364 q->last_argument= p; 02365 for (con= cons; con < next_con; con++) 02366 { 02367 if (!strcmp(con->name, name)) 02368 { 02369 #ifndef EMBEDDED_LIBRARY 02370 if (q->type == Q_DIRTY_CLOSE) 02371 { 02372 if (con->mysql.net.vio) 02373 { 02374 vio_delete(con->mysql.net.vio); 02375 con->mysql.net.vio = 0; 02376 } 02377 } 02378 #endif 02379 mysql_close(&con->mysql); 02380 if (con->util_mysql) 02381 mysql_close(con->util_mysql); 02382 con->util_mysql= 0; 02383 my_free(con->name, MYF(0)); 02384 /* 02385 When the connection is closed set name to "closed_connection" 02386 to make it possible to reuse the connection name. 02387 The connection slot will not be reused 02388 */ 02389 if (!(con->name = my_strdup("closed_connection", MYF(MY_WME)))) 02390 die("Out of memory"); 02391 DBUG_RETURN(0); 02392 } 02393 } 02394 die("connection '%s' not found in connection pool", name); 02395 DBUG_RETURN(1); /* Never reached */ 02396 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void close_cons | ( | ) | [static] |
Definition at line 563 of file mysqltest.c.
References cons, DBUG_ENTER, DBUG_VOID_RETURN, MY_ALLOW_ZERO_PTR, my_free, MYF, connection::mysql, mysql_close(), mysql_stmt_close(), connection::name, next_con, connection::stmt, and connection::util_mysql.
Referenced by free_used_memory().
00564 { 00565 DBUG_ENTER("close_cons"); 00566 for (--next_con; next_con >= cons; --next_con) 00567 { 00568 if (next_con->stmt) 00569 mysql_stmt_close(next_con->stmt); 00570 next_con->stmt= 0; 00571 mysql_close(&next_con->mysql); 00572 if (next_con->util_mysql) 00573 mysql_close(next_con->util_mysql); 00574 my_free(next_con->name, MYF(MY_ALLOW_ZERO_PTR)); 00575 } 00576 DBUG_VOID_RETURN; 00577 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void close_files | ( | ) | [static] |
Definition at line 580 of file mysqltest.c.
References cur_file, DBUG_ENTER, DBUG_PRINT, DBUG_VOID_RETURN, test_file::file, test_file::file_name, file_stack, MY_ALLOW_ZERO_PTR, my_fclose(), my_free, and MYF.
Referenced by free_used_memory().
00581 { 00582 DBUG_ENTER("close_files"); 00583 for (; cur_file >= file_stack; cur_file--) 00584 { 00585 DBUG_PRINT("info", ("file_name: %s", cur_file->file_name)); 00586 if (cur_file->file && cur_file->file != stdin) 00587 my_fclose(cur_file->file, MYF(0)); 00588 my_free((gptr)cur_file->file_name, MYF(MY_ALLOW_ZERO_PTR)); 00589 cur_file->file_name= 0; 00590 } 00591 DBUG_VOID_RETURN; 00592 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 6186 of file mysqltest.c.
References bcmp, st_rep_set::bits, and st_rep_set::size_of_bits.
Referenced by find_set().
06187 { 06188 return bcmp((byte*) set1->bits,(byte*) set2->bits, 06189 sizeof(uint) * set1->size_of_bits); 06190 }
Here is the caller graph for this function:

| int connect_n_handle_errors | ( | struct st_query * | q, | |
| MYSQL * | con, | |||
| const char * | host, | |||
| const char * | user, | |||
| const char * | pass, | |||
| const char * | db, | |||
| int | port, | |||
| const char * | sock, | |||
| int * | create_conn | |||
| ) |
Definition at line 2518 of file mysqltest.c.
References CLIENT_MULTI_STATEMENTS, delimiter, delimiter_length, disable_query_log, ds_res, dynstr_append_mem(), err, error, free_replace(), free_replace_regex(), handle_error(), handle_no_error(), int10_to_str(), mysql_errno(), mysql_error(), MYSQL_OPT_RECONNECT, mysql_options(), mysql_real_connect(), mysql_sqlstate(), reconnect(), replace_dynstr_append(), and replace_dynstr_append_mem().
Referenced by do_connect().
02522 { 02523 DYNAMIC_STRING *ds; 02524 my_bool reconnect= 1; 02525 int error= 0; 02526 02527 ds= &ds_res; 02528 02529 if (!disable_query_log) 02530 { 02531 /* 02532 It is nice to have connect() statement logged in result file 02533 in this case. 02534 QQ: Should we do this only if we are expecting an error ? 02535 */ 02536 char port_buff[22]; /* This should be enough for any int */ 02537 char *port_end; 02538 dynstr_append_mem(ds, "connect(", 8); 02539 replace_dynstr_append(ds, host); 02540 dynstr_append_mem(ds, ",", 1); 02541 replace_dynstr_append(ds, user); 02542 dynstr_append_mem(ds, ",", 1); 02543 replace_dynstr_append(ds, pass); 02544 dynstr_append_mem(ds, ",", 1); 02545 if (db) 02546 replace_dynstr_append(ds, db); 02547 dynstr_append_mem(ds, ",", 1); 02548 port_end= int10_to_str(port, port_buff, 10); 02549 replace_dynstr_append_mem(ds, port_buff, port_end - port_buff); 02550 dynstr_append_mem(ds, ",", 1); 02551 if (sock) 02552 replace_dynstr_append(ds, sock); 02553 dynstr_append_mem(ds, ")", 1); 02554 dynstr_append_mem(ds, delimiter, delimiter_length); 02555 dynstr_append_mem(ds, "\n", 1); 02556 } 02557 if (!mysql_real_connect(con, host, user, pass, db, port, sock ? sock: 0, 02558 CLIENT_MULTI_STATEMENTS)) 02559 { 02560 handle_error("connect", q, mysql_errno(con), mysql_error(con), 02561 mysql_sqlstate(con), ds); 02562 *create_conn= 0; 02563 goto err; 02564 } 02565 02566 handle_no_error(q); 02567 02568 /* 02569 TODO: change this to 0 in future versions, but the 'kill' test relies on 02570 existing behavior 02571 */ 02572 mysql_options(con, MYSQL_OPT_RECONNECT, (char *)&reconnect); 02573 02574 err: 02575 free_replace(); 02576 free_replace_regex(); 02577 return error; 02578 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 6180 of file mysqltest.c.
References from, memcpy, and to.
Referenced by Dbtup::commit_operation(), Dbtup::do_tup_abortreq(), Dbtup::handle_size_change_after_update(), and init_replace().
06181 { 06182 memcpy((byte*) to->bits,(byte*) from->bits, 06183 (size_t) (sizeof(uint) * to->size_of_bits)); 06184 }
Here is the caller graph for this function:

| static void die | ( | const char * | fmt, | |
| ... | ||||
| ) | [static] |
Definition at line 633 of file mysqltest.c.
References args, cur_file, DBUG_ENTER, ds_res, dump_result_to_log_file(), exit, test_file::file_name, file_stack, free_used_memory(), st_dynamic_string::length, MY_CHECK_ERROR, my_end(), result_file, silent, start_lineno, and st_dynamic_string::str.
00634 { 00635 va_list args; 00636 DBUG_ENTER("die"); 00637 00638 /* Print the error message */ 00639 va_start(args, fmt); 00640 if (fmt) 00641 { 00642 fprintf(stderr, "mysqltest: "); 00643 if (cur_file && cur_file != file_stack) 00644 fprintf(stderr, "In included file \"%s\": ", 00645 cur_file->file_name); 00646 if (start_lineno > 0) 00647 fprintf(stderr, "At line %u: ", start_lineno); 00648 vfprintf(stderr, fmt, args); 00649 fprintf(stderr, "\n"); 00650 fflush(stderr); 00651 } 00652 va_end(args); 00653 00654 /* Dump the result that has been accumulated so far to .log file */ 00655 if (result_file && ds_res.length) 00656 dump_result_to_log_file(result_file, ds_res.str, ds_res.length); 00657 00658 /* Clean up and exit */ 00659 free_used_memory(); 00660 my_end(MY_CHECK_ERROR); 00661 00662 if (!silent) 00663 printf("not ok\n"); 00664 00665 exit(1); 00666 }
Here is the call graph for this function:

Definition at line 2807 of file mysqltest.c.
References block_stack_end, charset_info, BLOCK::cmd, cmd_while, cur_block, PARSER::current_line, DBUG_ENTER, DBUG_PRINT, DBUG_VOID_RETURN, die(), eval_expr(), FALSE, st_query::first_argument, VAR::int_val, BLOCK::line, my_isspace, BLOCK::ok, p, parser, strchr(), strrchr(), TRUE, var_free(), and var_init().
Referenced by main().
02808 { 02809 char *p= q->first_argument; 02810 const char *expr_start, *expr_end; 02811 VAR v; 02812 const char *cmd_name= (cmd == cmd_while ? "while" : "if"); 02813 my_bool not_expr= FALSE; 02814 DBUG_ENTER("do_block"); 02815 DBUG_PRINT("enter", ("%s", cmd_name)); 02816 02817 /* Check stack overflow */ 02818 if (cur_block == block_stack_end) 02819 die("Nesting too deeply"); 02820 02821 /* Set way to find outer block again, increase line counter */ 02822 cur_block->line= parser.current_line++; 02823 02824 /* If this block is ignored */ 02825 if (!cur_block->ok) 02826 { 02827 /* Inner block should be ignored too */ 02828 cur_block++; 02829 cur_block->cmd= cmd; 02830 cur_block->ok= FALSE; 02831 DBUG_VOID_RETURN; 02832 } 02833 02834 /* Parse and evaluate test expression */ 02835 expr_start= strchr(p, '('); 02836 if (!expr_start++) 02837 die("missing '(' in %s", cmd_name); 02838 02839 /* Check for !<expr> */ 02840 if (*expr_start == '!') 02841 { 02842 not_expr= TRUE; 02843 expr_start++; /* Step past the '!' */ 02844 } 02845 /* Find ending ')' */ 02846 expr_end= strrchr(expr_start, ')'); 02847 if (!expr_end) 02848 die("missing ')' in %s", cmd_name); 02849 p= (char*)expr_end+1; 02850 02851 while (*p && my_isspace(charset_info, *p)) 02852 p++; 02853 if (*p == '{') 02854 die("Missing newline between %s and '{'", cmd_name); 02855 if (*p) 02856 die("Missing '{' after %s. Found \"%s\"", cmd_name, p); 02857 02858 var_init(&v,0,0,0,0); 02859 eval_expr(&v, expr_start, &expr_end); 02860 02861 /* Define inner block */ 02862 cur_block++; 02863 cur_block->cmd= cmd; 02864 cur_block->ok= (v.int_val ? TRUE : FALSE); 02865 02866 if (not_expr) 02867 cur_block->ok = !cur_block->ok; 02868 02869 DBUG_PRINT("info", ("OK: %d", cur_block->ok)); 02870 02871 var_free(&v); 02872 DBUG_VOID_RETURN; 02873 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int do_connect | ( | struct st_query * | q | ) |
Definition at line 2605 of file mysqltest.c.
References st_query::abort_on_error, atoi(), charset_info, charset_name, connect_n_handle_errors(), cons_end, cur_con, db, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, die(), error, find_connection_by_name(), st_query::first_argument, fn_format(), FN_LIBCHAR, FN_REFLEN, VAR::int_val, st_query::last_argument, memcpy, my_free, my_isspace, my_malloc(), my_strdup(), MY_WME, MYF, connection::mysql, mysql_errno(), mysql_error(), mysql_init(), MYSQL_OPT_COMPRESS, MYSQL_OPT_LOCAL_INFILE, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, mysql_options(), MYSQL_SET_CHARSET_NAME, mysql_ssl_set(), connection::name, next_con, NullS, opt_compress, p, port, safe_connect(), safe_get_param(), VAR::str_val, VAR::str_val_len, strcmp(), TMPDIR, unix_sock, and var_get().
Referenced by main().
02606 { 02607 char *con_name, *con_user,*con_pass, *con_host, *con_port_str, 02608 *con_db, *con_sock, *con_options; 02609 char *con_buf, *p; 02610 char buff[FN_REFLEN]; 02611 int con_port; 02612 bool con_ssl= 0; 02613 bool con_compress= 0; 02614 int free_con_sock= 0; 02615 int error= 0; 02616 int create_conn= 1; 02617 VAR *var_port, *var_sock; 02618 02619 DBUG_ENTER("do_connect"); 02620 DBUG_PRINT("enter",("connect: %s", q->first_argument)); 02621 02622 /* Make a copy of query before parsing, safe_get_param will modify */ 02623 if (!(con_buf= my_strdup(q->first_argument, MYF(MY_WME)))) 02624 die("Could not allocate con_buf"); 02625 p= con_buf; 02626 02627 if (*p != '(') 02628 die("Syntax error in connect - expected '(' found '%c'", *p); 02629 p++; 02630 p= safe_get_param(p, &con_name, "Missing connection name"); 02631 p= safe_get_param(p, &con_host, "Missing connection host"); 02632 p= safe_get_param(p, &con_user, "Missing connection user"); 02633 p= safe_get_param(p, &con_pass, "Missing connection password"); 02634 p= safe_get_param(p, &con_db, "Missing connection db"); 02635 02636 /* Port */ 02637 p= safe_get_param(p, &con_port_str, 0); 02638 if (*con_port_str) 02639 { 02640 if (*con_port_str == '$') 02641 { 02642 if (!(var_port= var_get(con_port_str, 0, 0, 0))) 02643 die("Unknown variable '%s'", con_port_str+1); 02644 con_port= var_port->int_val; 02645 } 02646 else 02647 { 02648 con_port= atoi(con_port_str); 02649 if (con_port == 0) 02650 die("Illegal argument for port: '%s'", con_port_str); 02651 } 02652 } 02653 else 02654 { 02655 con_port= port; 02656 } 02657 02658 /* Sock */ 02659 p= safe_get_param(p, &con_sock, 0); 02660 if (*con_sock) 02661 { 02662 if (*con_sock == '$') 02663 { 02664 if (!(var_sock= var_get(con_sock, 0, 0, 0))) 02665 die("Unknown variable '%s'", con_sock+1); 02666 if (!(con_sock= (char*)my_malloc(var_sock->str_val_len+1, MYF(0)))) 02667 die("Out of memory"); 02668 free_con_sock= 1; 02669 memcpy(con_sock, var_sock->str_val, var_sock->str_val_len); 02670 con_sock[var_sock->str_val_len]= 0; 02671 } 02672 } 02673 else 02674 { 02675 con_sock= (char*) unix_sock; 02676 } 02677 02678 /* Options */ 02679 p= safe_get_param(p, &con_options, 0); 02680 while (*con_options) 02681 { 02682 char* str= con_options; 02683 while (*str && !my_isspace(charset_info, *str)) 02684 str++; 02685 *str++= 0; 02686 if (!strcmp(con_options, "SSL")) 02687 con_ssl= 1; 02688 else if (!strcmp(con_options, "COMPRESS")) 02689 con_compress= 1; 02690 else 02691 die("Illegal option to connect: %s", con_options); 02692 con_options= str; 02693 } 02694 /* Note: 'p' is pointing into the copy 'con_buf' */ 02695 q->last_argument= q->first_argument + (p - con_buf); 02696 02697 if (next_con == cons_end) 02698 die("Connection limit exhausted - increase MAX_CONS in mysqltest.c"); 02699 02700 if (find_connection_by_name(con_name)) 02701 die("Connection %s already exists", con_name); 02702 02703 if (!mysql_init(&next_con->mysql)) 02704 die("Failed on mysql_init()"); 02705 if (opt_compress || con_compress) 02706 mysql_options(&next_con->mysql, MYSQL_OPT_COMPRESS, NullS); 02707 mysql_options(&next_con->mysql, MYSQL_OPT_LOCAL_INFILE, 0); 02708 mysql_options(&next_con->mysql, MYSQL_SET_CHARSET_NAME, charset_name); 02709 02710 #ifdef HAVE_OPENSSL 02711 if (opt_use_ssl || con_ssl) 02712 { 02713 /* Turn on ssl_verify_server_cert only if host is "localhost" */ 02714 opt_ssl_verify_server_cert= !strcmp(con_host, "localhost"); 02715 02716 mysql_ssl_set(&next_con->mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca, 02717 opt_ssl_capath, opt_ssl_cipher); 02718 mysql_options(&next_con->mysql, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, 02719 &opt_ssl_verify_server_cert); 02720 } 02721 #endif 02722 if (con_sock && !free_con_sock && *con_sock && *con_sock != FN_LIBCHAR) 02723 con_sock=fn_format(buff, con_sock, TMPDIR, "", 0); 02724 if (!con_db[0]) 02725 con_db= db; 02726 /* Special database to allow one to connect without a database name */ 02727 if (con_db && !strcmp(con_db,"*NO-ONE*")) 02728 con_db= 0; 02729 if (q->abort_on_error) 02730 { 02731 if (safe_connect(&next_con->mysql, con_host, con_user, con_pass, 02732 con_db, con_port, con_sock ? con_sock: 0)) 02733 die("Could not open connection '%s': %d %s", con_name, 02734 mysql_errno(&next_con->mysql), mysql_error(&next_con->mysql)); 02735 } 02736 else 02737 error= connect_n_handle_errors(q, &next_con->mysql, con_host, con_user, 02738 con_pass, con_db, con_port, con_sock, 02739 &create_conn); 02740 02741 if (create_conn) 02742 { 02743 if (!(next_con->name= my_strdup(con_name, MYF(MY_WME)))) 02744 die(NullS); 02745 cur_con= next_con++; 02746 } 02747 if (free_con_sock) 02748 my_free(con_sock, MYF(MY_WME)); 02749 my_free(con_buf, MYF(MY_WME)); 02750 DBUG_RETURN(error); 02751 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1794 of file mysqltest.c.
References cur_con, connection::mysql, and mysql_disable_rpl_parse().
Referenced by main().
01795 { 01796 mysql_disable_rpl_parse(&cur_con->mysql); 01797 return 0; 01798 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int do_done | ( | struct st_query * | q | ) |
Definition at line 2754 of file mysqltest.c.
References block_stack, BLOCK::cmd, cmd_while, cur_block, PARSER::current_line, die(), BLOCK::line, BLOCK::ok, parser, and st_query::query.
Referenced by main().
02755 { 02756 /* Check if empty block stack */ 02757 if (cur_block == block_stack) 02758 { 02759 if (*q->query != '}') 02760 die("Stray 'end' command - end of block before beginning"); 02761 die("Stray '}' - end of block before beginning"); 02762 } 02763 02764 /* Test if inner block has been executed */ 02765 if (cur_block->ok && cur_block->cmd == cmd_while) 02766 { 02767 /* Pop block from stack, re-execute outer block */ 02768 cur_block--; 02769 parser.current_line = cur_block->line; 02770 } 02771 else 02772 { 02773 /* Pop block from stack, goto next line */ 02774 cur_block--; 02775 parser.current_line++; 02776 } 02777 return 0; 02778 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int do_echo | ( | struct st_query * | command | ) |
Definition at line 1512 of file mysqltest.c.
References do_eval(), ds_res, dynstr_append_mem(), dynstr_free(), st_query::end, FALSE, st_query::first_argument, init_dynamic_string(), st_query::last_argument, st_dynamic_string::length, and st_dynamic_string::str.
Referenced by main().
01513 { 01514 DYNAMIC_STRING *ds, ds_echo; 01515 01516 ds= &ds_res; 01517 01518 init_dynamic_string(&ds_echo, "", 256, 256); 01519 do_eval(&ds_echo, command->first_argument, FALSE); 01520 dynstr_append_mem(ds, ds_echo.str, ds_echo.length); 01521 dynstr_append_mem(ds, "\n", 1); 01522 dynstr_free(&ds_echo); 01523 command->last_argument= command->end; 01524 return(0); 01525 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1787 of file mysqltest.c.
References cur_con, connection::mysql, and mysql_enable_rpl_parse().
Referenced by main().
01788 { 01789 mysql_enable_rpl_parse(&cur_con->mysql); 01790 return 0; 01791 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void do_eval | ( | DYNAMIC_STRING * | query_eval, | |
| const char * | query, | |||
| my_bool | pass_through_escape_chars | |||
| ) | [static] |
Definition at line 508 of file mysqltest.c.
References DBUG_ENTER, DBUG_VOID_RETURN, die(), dynstr_append_mem(), escaped, p, VAR::str_val, VAR::str_val_len, and var_get().
Referenced by do_echo(), do_exec(), do_system(), dyn_string_cmp(), and run_query().
00510 { 00511 const char *p; 00512 register char c, next_c; 00513 register int escaped = 0; 00514 VAR* v; 00515 DBUG_ENTER("do_eval"); 00516 00517 for (p= query; (c = *p); ++p) 00518 { 00519 switch(c) { 00520 case '$': 00521 if (escaped) 00522 { 00523 escaped = 0; 00524 dynstr_append_mem(query_eval, p, 1); 00525 } 00526 else 00527 { 00528 if (!(v = var_get(p, &p, 0, 0))) 00529 die("Bad variable in eval"); 00530 dynstr_append_mem(query_eval, v->str_val, v->str_val_len); 00531 } 00532 break; 00533 case '\\': 00534 next_c= *(p+1); 00535 if (escaped) 00536 { 00537 escaped = 0; 00538 dynstr_append_mem(query_eval, p, 1); 00539 } 00540 else if (next_c == '\\' || next_c == '$') 00541 { 00542 /* Set escaped only if next char is \ or $ */ 00543 escaped = 1; 00544 00545 if (pass_through_escape_chars) 00546 { 00547 /* The escape char should be added to the output string. */ 00548 dynstr_append_mem(query_eval, p, 1); 00549 } 00550 } 00551 else 00552 dynstr_append_mem(query_eval, p, 1); 00553 break; 00554 default: 00555 dynstr_append_mem(query_eval, p, 1); 00556 break; 00557 } 00558 } 00559 DBUG_VOID_RETURN; 00560 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void do_exec | ( | struct st_query * | query | ) | [static] |
Definition at line 1133 of file mysqltest.c.
References buf, charset_info, DBUG_ENTER, DBUG_PRINT, die(), disable_result_log, do_eval(), ds_res, ERR_ERRNO, error, init_dynamic_string(), my_isspace, my_popen(), ok(), pclose, query, replace_dynstr_append(), status, st_dynamic_string::str, strlen(), TRUE, and WEXITSTATUS.
Referenced by main().
01134 { 01135 int error; 01136 char buf[1024]; 01137 FILE *res_file; 01138 char *cmd= query->first_argument; 01139 DYNAMIC_STRING ds_cmd; 01140 DBUG_ENTER("do_exec"); 01141 DBUG_PRINT("enter", ("cmd: '%s'", cmd)); 01142 01143 while (*cmd && my_isspace(charset_info, *cmd)) 01144 cmd++; 01145 if (!*cmd) 01146 die("Missing argument in exec"); 01147 query->last_argument= query->end; 01148 01149 init_dynamic_string(&ds_cmd, 0, strlen(cmd)+256, 256); 01150 /* Eval the command, thus replacing all environment variables */ 01151 do_eval(&ds_cmd, cmd, TRUE); 01152 cmd= ds_cmd.str; 01153 01154 DBUG_PRINT("info", ("Executing '%s' as '%s'", 01155 query->first_argument, cmd)); 01156 01157 if (!(res_file= my_popen(&ds_cmd, "r")) && query->abort_on_error) 01158 die("popen(\"%s\", \"r\") failed", query->first_argument); 01159 01160 while (fgets(buf, sizeof(buf), res_file)) 01161 { 01162 if (disable_result_log) 01163 { 01164 buf[strlen(buf)-1]=0; 01165 DBUG_PRINT("exec_result",("%s", buf)); 01166 } 01167 else 01168 { 01169 replace_dynstr_append(&ds_res, buf); 01170 } 01171 } 01172 error= pclose(res_file); 01173 if (error > 0) 01174 { 01175 uint status= WEXITSTATUS(error), i; 01176 my_bool ok= 0; 01177 01178 if (query->abort_on_error) 01179 die("command \"%s\" failed", query->first_argument); 01180 01181 DBUG_PRINT("info", 01182 ("error: %d, status: %d", error, status)); 01183 for (i= 0; i < query->expected_errors; i++) 01184 { 01185 DBUG_PRINT("info", ("expected error: %d", 01186 query->expected_errno[i].code.errnum)); 01187 if ((query->expected_errno[i].type == ERR_ERRNO) && 01188 (query->expected_errno[i].code.errnum == status)) 01189 { 01190 ok= 1; 01191 DBUG_PRINT("info", ("command \"%s\" failed with expected error: %d", 01192 query->first_argument, status)); 01193 } 01194 } 01195 if (!ok) 01196 die("command \"%s\" failed with wrong error: %d", 01197 query->first_argument, status); 01198 } 01199 else if (query->expected_errno[0].type == ERR_ERRNO && 01200 query->expected_errno[0].code.errnum != 0) 01201 { 01202 /* Error code we wanted was != 0, i.e. not an expected success */ 01203 die("command \"%s\" succeeded - should have failed with errno %d...", 01204 query->first_argument, query->expected_errno[0].code.errnum); 01205 } 01206 01207 free_replace(); 01208 DBUG_VOID_RETURN; 01209 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int do_let | ( | struct st_query * | query | ) |
Definition at line 1733 of file mysqltest.c.
References charset_info, die(), my_isspace, p, query, and var_set().
Referenced by main().
01734 { 01735 char *p= query->first_argument; 01736 char *var_name, *var_name_end, *var_val_start; 01737 01738 /* Find <var_name> */ 01739 if (!*p) 01740 die("Missing arguments to let"); 01741 var_name= p; 01742 while (*p && (*p != '=') && !my_isspace(charset_info,*p)) 01743 p++; 01744 var_name_end= p; 01745 if (var_name == var_name_end || 01746 (var_name+1 == var_name_end && *var_name == '$')) 01747 die("Missing variable name in let"); 01748 while (my_isspace(charset_info,*p)) 01749 p++; 01750 if (*p++ != '=') 01751 die("Missing assignment operator in let"); 01752 01753 /* Find start of <var_val> */ 01754 while (*p && my_isspace(charset_info,*p)) 01755 p++; 01756 var_val_start= p; 01757 query->last_argument= query->end; 01758 /* Assign var_val to var_name */ 01759 return var_set(var_name, var_name_end, var_val_start, query->end); 01760 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int do_modify_var | ( | struct st_query * | query, | |
| enum enum_operator | operator | |||
| ) |
Definition at line 1391 of file mysqltest.c.
References die(), DO_DEC, VAR::int_dirty, VAR::int_val, p, query, and var_get().
Referenced by main().
01393 { 01394 const char *p= query->first_argument; 01395 VAR* v; 01396 if (!*p) 01397 die("Missing argument to %.*s", query->first_word_len, query->query); 01398 if (*p != '$') 01399 die("The argument to %.*s must be a variable (start with $)", 01400 query->first_word_len, query->query); 01401 v= var_get(p, &p, 1, 0); 01402 switch (operator) { 01403 case DO_DEC: 01404 v->int_val--; 01405 break; 01406 case DO_INC: 01407 v->int_val++; 01408 break; 01409 default: 01410 die("Invalid operator to do_modify_var"); 01411 break; 01412 } 01413 v->int_dirty= 1; 01414 query->last_argument= (char*)++p; 01415 return 0; 01416 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1778 of file mysqltest.c.
References cur_con, DBUG_ENTER, DBUG_RETURN, die(), connection::mysql, mysql_error(), and mysql_rpl_probe.
Referenced by main().
01779 { 01780 DBUG_ENTER("do_rpl_probe"); 01781 if (mysql_rpl_probe(&cur_con->mysql)) 01782 die("Failed in mysql_rpl_probe(): '%s'", mysql_error(&cur_con->mysql)); 01783 DBUG_RETURN(0); 01784 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int do_save_master_pos | ( | ) |
Definition at line 1595 of file mysqltest.c.
References count, cur_con, die(), MASTER_POS::file, have_ndbcluster, master_pos, connection::mysql, mysql, mysql_disable_rpl_parse(), mysql_enable_rpl_parse(), mysql_errno(), mysql_error(), mysql_fetch_row(), mysql_free_result(), mysql_query(), mysql_rpl_parse_enabled(), mysql_store_result(), MASTER_POS::pos, sleep, start_lineno, status, strcmp(), strnmov(), strtoul(), and strtoull.
Referenced by main().
01596 { 01597 MYSQL_RES* res; 01598 MYSQL_ROW row; 01599 MYSQL* mysql = &cur_con->mysql; 01600 const char *query; 01601 int rpl_parse; 01602 01603 rpl_parse = mysql_rpl_parse_enabled(mysql); 01604 mysql_disable_rpl_parse(mysql); 01605 01606 #ifdef HAVE_NDB_BINLOG 01607 /* 01608 Wait for ndb binlog to be up-to-date with all changes 01609 done on the local mysql server 01610 */ 01611 { 01612 ulong have_ndbcluster; 01613 if (mysql_query(mysql, query= "show variables like 'have_ndbcluster'")) 01614 die("At line %u: failed in %s: %d: %s", start_lineno, query, 01615 mysql_errno(mysql), mysql_error(mysql)); 01616 if (!(res= mysql_store_result(mysql))) 01617 die("line %u: mysql_store_result() retuned NULL for '%s'", start_lineno, 01618 query); 01619 if (!(row= mysql_fetch_row(res))) 01620 die("line %u: empty result in %s", start_lineno, query); 01621 01622 have_ndbcluster= strcmp("YES", row[1]) == 0; 01623 mysql_free_result(res); 01624 01625 if (have_ndbcluster) 01626 { 01627 ulonglong epoch=0, tmp_epoch= 0; 01628 int count= 0; 01629 int do_continue= 1; 01630 while (do_continue) 01631 { 01632 const char binlog[]= "binlog"; 01633 const char latest_trans_epoch[]= 01634 "latest_trans_epoch="; 01635 const char latest_handled_binlog_epoch[]= 01636 "latest_handled_binlog_epoch="; 01637 if (count) 01638 sleep(1); 01639 if (mysql_query(mysql, query= "show engine ndb status")) 01640 die("At line %u: failed in '%s': %d: %s", start_lineno, query, 01641 mysql_errno(mysql), mysql_error(mysql)); 01642 if (!(res= mysql_store_result(mysql))) 01643 die("line %u: mysql_store_result() retuned NULL for '%s'", 01644 start_lineno, query); 01645 while ((row= mysql_fetch_row(res))) 01646 { 01647 if (strcmp(row[1], binlog) == 0) 01648 { 01649 const char *status= row[2]; 01650 /* latest_trans_epoch */ 01651 if (count == 0) 01652 { 01653 while (*status && strncmp(status, latest_trans_epoch, 01654 sizeof(latest_trans_epoch)-1)) 01655 status++; 01656 if (*status) 01657 { 01658 status+= sizeof(latest_trans_epoch)-1; 01659 epoch= strtoull(status, (char**) 0, 10); 01660 } 01661 else 01662 die("line %u: result does not contain '%s' in '%s'", 01663 start_lineno, latest_trans_epoch, query); 01664 } 01665 /* latest_applied_binlog_epoch */ 01666 while (*status && strncmp(status, latest_handled_binlog_epoch, 01667 sizeof(latest_handled_binlog_epoch)-1)) 01668 status++; 01669 if (*status) 01670 { 01671 status+= sizeof(latest_handled_binlog_epoch)-1; 01672 tmp_epoch= strtoull(status, (char**) 0, 10); 01673 } 01674 else 01675 die("line %u: result does not contain '%s' in '%s'", 01676 start_lineno, latest_handled_binlog_epoch, query); 01677 break; 01678 } 01679 } 01680 if (!row) 01681 die("line %u: result does not contain '%s' in '%s'", 01682 start_lineno, binlog, query); 01683 count++; 01684 if (tmp_epoch >= epoch) 01685 do_continue= 0; 01686 else if (count > 30) 01687 { 01688 break; 01689 } 01690 mysql_free_result(res); 01691 } 01692 } 01693 } 01694 #endif 01695 if (mysql_query(mysql, query= "show master status")) 01696 die("failed in show master status: %d: %s", 01697 mysql_errno(mysql), mysql_error(mysql)); 01698 01699 if (!(res = mysql_store_result(mysql))) 01700 die("mysql_store_result() retuned NULL for '%s'", query); 01701 if (!(row = mysql_fetch_row(res))) 01702 die("empty result in show master status"); 01703 strnmov(master_pos.file, row[0], sizeof(master_pos.file)-1); 01704 master_pos.pos = strtoul(row[1], (char**) 0, 10); 01705 mysql_free_result(res); 01706 01707 if (rpl_parse) 01708 mysql_enable_rpl_parse(mysql); 01709 01710 return 0; 01711 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1823 of file mysqltest.c.
References charset_info, DBUG_PRINT, die(), error, my_isdigit, my_isspace, my_sleep(), my_strtod(), opt_sleep, p, and query.
Referenced by main().
01824 { 01825 int error= 0; 01826 char *p= query->first_argument; 01827 char *sleep_start, *sleep_end= query->end; 01828 double sleep_val; 01829 01830 while (my_isspace(charset_info, *p)) 01831 p++; 01832 if (!*p) 01833 die("Missing argument to %.*s", query->first_word_len, query->query); 01834 sleep_start= p; 01835 /* Check that arg starts with a digit, not handled by my_strtod */ 01836 if (!my_isdigit(charset_info, *sleep_start)) 01837 die("Invalid argument to %.*s \"%s\"", query->first_word_len, query->query, 01838 query->first_argument); 01839 sleep_val= my_strtod(sleep_start, &sleep_end, &error); 01840 if (error) 01841 die("Invalid argument to %.*s \"%s\"", query->first_word_len, query->query, 01842 query->first_argument); 01843 01844 /* Fixed sleep time selected by --sleep option */ 01845 if (opt_sleep >= 0 && !real_sleep) 01846 sleep_val= opt_sleep; 01847 01848 DBUG_PRINT("info", ("sleep_val: %f", sleep_val)); 01849 if (sleep_val) 01850 my_sleep((ulong) (sleep_val * 1000000L)); 01851 query->last_argument= sleep_end; 01852 return 0; 01853 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int do_source | ( | struct st_query * | query | ) |
Definition at line 1062 of file mysqltest.c.
References charset_info, PARSER::current_line, die(), my_isspace, name, open_file(), p, parser, query, and PARSER::read_lines.
Referenced by main().
01063 { 01064 char *p= query->first_argument, *name; 01065 if (!*p) 01066 die("Missing file name in source"); 01067 name= p; 01068 while (*p && !my_isspace(charset_info,*p)) 01069 p++; 01070 if (*p) 01071 *p++= 0; 01072 query->last_argument= p; 01073 /* 01074 If this file has already been sourced, don't source it again. 01075 It's already available in the q_lines cache. 01076 */ 01077 if (parser.current_line < (parser.read_lines - 1)) 01078 return 0; 01079 return open_file(name); 01080 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int do_sync_with_master | ( | struct st_query * | query | ) |
Definition at line 1574 of file mysqltest.c.
References charset_info, die(), do_sync_with_master2(), my_isdigit, my_isspace, offset, p, and query.
Referenced by main().
01575 { 01576 long offset= 0; 01577 char *p= query->first_argument; 01578 const char *offset_start= p; 01579 if (*offset_start) 01580 { 01581 for (; my_isdigit(charset_info, *p); p++) 01582 offset = offset * 10 + *p - '0'; 01583 01584 if(*p && !my_isspace(charset_info, *p)) 01585 die("Invalid integer argument \"%s\"", offset_start); 01586 query->last_argument= p; 01587 } 01588 return do_sync_with_master2(offset); 01589 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int do_sync_with_master2 | ( | long | offset | ) |
Definition at line 1528 of file mysqltest.c.
References cur_con, die(), MASTER_POS::file, FN_REFLEN, master_pos, connection::mysql, mysql, mysql_disable_rpl_parse(), mysql_enable_rpl_parse(), mysql_errno(), mysql_error(), mysql_fetch_row(), mysql_free_result(), mysql_query(), mysql_rpl_parse_enabled(), mysql_store_result(), MASTER_POS::pos, and sleep.
Referenced by do_sync_with_master(), and main().
01529 { 01530 MYSQL_RES* res; 01531 MYSQL_ROW row; 01532 MYSQL* mysql= &cur_con->mysql; 01533 char query_buf[FN_REFLEN+128]; 01534 int tries= 0; 01535 int rpl_parse; 01536 01537 if (!master_pos.file[0]) 01538 die("Calling 'sync_with_master' without calling 'save_master_pos'"); 01539 rpl_parse= mysql_rpl_parse_enabled(mysql); 01540 mysql_disable_rpl_parse(mysql); 01541 01542 sprintf(query_buf, "select master_pos_wait('%s', %ld)", master_pos.file, 01543 master_pos.pos + offset); 01544 01545 wait_for_position: 01546 01547 if (mysql_query(mysql, query_buf)) 01548 die("failed in %s: %d: %s", query_buf, mysql_errno(mysql), 01549 mysql_error(mysql)); 01550 01551 if (!(res= mysql_store_result(mysql))) 01552 die("mysql_store_result() returned NULL for '%s'", query_buf); 01553 if (!(row= mysql_fetch_row(res))) 01554 die("empty result in %s", query_buf); 01555 if (!row[0]) 01556 { 01557 /* 01558 It may be that the slave SQL thread has not started yet, though START 01559 SLAVE has been issued ? 01560 */ 01561 if (tries++ == 30) 01562 die("could not sync with master ('%s' returned NULL)", query_buf); 01563 sleep(1); /* So at most we will wait 30 seconds and make 31 tries */ 01564 mysql_free_result(res); 01565 goto wait_for_position; 01566 } 01567 mysql_free_result(res); 01568 if (rpl_parse) 01569 mysql_enable_rpl_parse(mysql); 01570 01571 return 0; 01572 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void do_system | ( | struct st_query * | command | ) |
Definition at line 1456 of file mysqltest.c.
References st_query::abort_on_error, DBUG_ENTER, DBUG_PRINT, DBUG_VOID_RETURN, die(), do_eval(), ds_res, dynstr_append(), dynstr_free(), st_query::end, st_query::first_argument, init_dynamic_string(), st_query::last_argument, my_system(), replace_dynstr_append(), st_dynamic_string::str, strlen(), and TRUE.
Referenced by main().
01457 { 01458 DYNAMIC_STRING ds_cmd; 01459 DBUG_ENTER("do_system"); 01460 01461 if (strlen(command->first_argument) == 0) 01462 die("Missing arguments to system, nothing to do!"); 01463 01464 init_dynamic_string(&ds_cmd, 0, strlen(command->first_argument) + 64, 256); 01465 01466 /* Eval the system command, thus replacing all environment variables */ 01467 do_eval(&ds_cmd, command->first_argument, TRUE); 01468 01469 DBUG_PRINT("info", ("running system command '%s' as '%s'", 01470 command->first_argument, ds_cmd.str)); 01471 if (my_system(&ds_cmd)) 01472 { 01473 if (command->abort_on_error) 01474 die("system command '%s' failed", command->first_argument); 01475 01476 /* If ! abort_on_error, log message and continue */ 01477 dynstr_append(&ds_res, "system command '"); 01478 replace_dynstr_append(&ds_res, command->first_argument); 01479 dynstr_append(&ds_res, "' failed\n"); 01480 } 01481 01482 command->last_argument= command->end; 01483 dynstr_free(&ds_cmd); 01484 DBUG_VOID_RETURN; 01485 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int do_wait_for_slave_to_stop | ( | struct st_query *q | __attribute__((unused)) | ) |
Definition at line 1019 of file mysqltest.c.
References cur_con, die(), LINT_INIT, my_sleep(), connection::mysql, mysql, mysql_error(), mysql_fetch_row(), mysql_free_result(), mysql_query(), mysql_store_result(), SLAVE_POLL_INTERVAL, and strcmp().
Referenced by main().
01020 { 01021 MYSQL* mysql = &cur_con->mysql; 01022 for (;;) 01023 { 01024 MYSQL_RES *res; 01025 MYSQL_ROW row; 01026 int done; 01027 LINT_INIT(res); 01028 01029 if (mysql_query(mysql,"show status like 'Slave_running'") || 01030 !(res=mysql_store_result(mysql))) 01031 die("Query failed while probing slave for stop: %s", 01032 mysql_error(mysql)); 01033 if (!(row=mysql_fetch_row(res)) || !row[1]) 01034 { 01035 mysql_free_result(res); 01036 die("Strange result from query while probing slave for stop"); 01037 } 01038 done = !strcmp(row[1],"OFF"); 01039 mysql_free_result(res); 01040 if (done) 01041 break; 01042 my_sleep(SLAVE_POLL_INTERVAL); 01043 } 01044 return 0; 01045 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void dump_progress | ( | const char * | record_file | ) |
Definition at line 3482 of file mysqltest.c.
References ds_progress, fn_format(), FN_REFLEN, st_dynamic_string::length, MY_REPLACE_EXT, st_dynamic_string::str, and str_to_file().
Referenced by main().
03483 { 03484 char log_file[FN_REFLEN]; 03485 str_to_file(fn_format(log_file, record_file, "", ".progress", 03486 MY_REPLACE_EXT), 03487 ds_progress.str, ds_progress.length); 03488 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void dump_result_to_log_file | ( | const char * | record_file, | |
| char * | buf, | |||
| int | size | |||
| ) |
Definition at line 3474 of file mysqltest.c.
References fn_format(), FN_REFLEN, MY_REPLACE_EXT, and str_to_file().
Referenced by die().
03475 { 03476 char log_file[FN_REFLEN]; 03477 str_to_file(fn_format(log_file, record_file, "", ".log", 03478 MY_REPLACE_EXT), 03479 buf, size); 03480 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void dump_result_to_reject_file | ( | const char * | record_file, | |
| char * | buf, | |||
| int | size | |||
| ) |
Definition at line 3466 of file mysqltest.c.
References fn_format(), FN_REFLEN, MY_REPLACE_EXT, and str_to_file().
Referenced by check_result().
03467 { 03468 char reject_file[FN_REFLEN]; 03469 str_to_file(fn_format(reject_file, record_file, "", ".reject", 03470 MY_REPLACE_EXT), 03471 buf, size); 03472 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static int dyn_string_cmp | ( | DYNAMIC_STRING * | ds, | |
| const char * | fname | |||
| ) | [static] |
Definition at line 734 of file mysqltest.c.
References DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, die(), do_eval(), dynstr_free(), err, eval_result, FALSE, fn_format(), FN_REFLEN, init_dynamic_string(), st_dynamic_string::length, memcmp(), my_close(), my_free, my_malloc(), MY_NABP, my_open(), my_read, MY_REPLACE_EXT, my_stat(), MY_STAT, MY_UNPACK_FILENAME, MY_WME, MYF, NullS, opt_basedir, RESULT_CONTENT_MISMATCH, RESULT_LENGTH_MISMATCH, RESULT_OK, st_dynamic_string::str, str_to_file(), strxmov(), and test_if_hard_path().
Referenced by check_result().
00735 { 00736 MY_STAT stat_info; 00737 char *tmp, *res_ptr; 00738 char eval_file[FN_REFLEN]; 00739 int res; 00740 uint res_len; 00741 int fd; 00742 DYNAMIC_STRING res_ds; 00743 DBUG_ENTER("dyn_string_cmp"); 00744 00745 if (!test_if_hard_path(fname)) 00746 { 00747 strxmov(eval_file, opt_basedir, fname, NullS); 00748 fn_format(eval_file, eval_file, "", "", MY_UNPACK_FILENAME); 00749 } 00750 else 00751 fn_format(eval_file, fname, "", "", MY_UNPACK_FILENAME); 00752 00753 if (!my_stat(eval_file, &stat_info, MYF(MY_WME))) 00754 die(NullS); 00755 if (!eval_result && (uint) stat_info.st_size != ds->length) 00756 { 00757 DBUG_PRINT("info",("Size differs: result size: %u file size: %u", 00758 ds->length, stat_info.st_size)); 00759 DBUG_PRINT("info",("result: '%s'", ds->str)); 00760 DBUG_RETURN(RESULT_LENGTH_MISMATCH); 00761 } 00762 if (!(tmp = (char*) my_malloc(stat_info.st_size + 1, MYF(MY_WME)))) 00763 die(NullS); 00764 00765 if ((fd = my_open(eval_file, O_RDONLY, MYF(MY_WME))) < 0) 00766 die(NullS); 00767 if (my_read(fd, (byte*)tmp, stat_info.st_size, MYF(MY_WME|MY_NABP))) 00768 die(NullS); 00769 tmp[stat_info.st_size] = 0; 00770 init_dynamic_string(&res_ds, "", 0, 65536); 00771 if (eval_result) 00772 { 00773 do_eval(&res_ds, tmp, FALSE); 00774 res_ptr = res_ds.str; 00775 if ((res_len = res_ds.length) != ds->length) 00776 { 00777 res= RESULT_LENGTH_MISMATCH; 00778 goto err; 00779 } 00780 } 00781 else 00782 { 00783 res_ptr = tmp; 00784 res_len = stat_info.st_size; 00785 } 00786 00787 res= (memcmp(res_ptr, ds->str, res_len)) ? 00788 RESULT_CONTENT_MISMATCH : RESULT_OK; 00789 00790 err: 00791 if (res && eval_result) 00792 str_to_file(fn_format(eval_file, fname, "", ".eval", 00793 MY_REPLACE_EXT), 00794 res_ptr, res_len); 00795 00796 my_free((gptr) tmp, MYF(0)); 00797 my_close(fd, MYF(MY_WME)); 00798 dynstr_free(&res_ds); 00799 00800 DBUG_RETURN(res); 00801 }
Here is the call graph for this function:

Here is the caller graph for this function:

| my_bool end_of_query | ( | int | c | ) |
Definition at line 2899 of file mysqltest.c.
References cur_file, delimiter, delimiter_length, test_file::file, MAX_DELIMITER, my_getc(), and my_ungetc().
Referenced by read_line().
02900 { 02901 uint i; 02902 char tmp[MAX_DELIMITER]; 02903 02904 if (c != *delimiter) 02905 return 0; 02906 02907 for (i= 1; i < delimiter_length && 02908 (c= my_getc(cur_file->file)) == *(delimiter + i); 02909 i++) 02910 tmp[i]= c; 02911 02912 if (i == delimiter_length) 02913 return 1; /* Found delimiter */ 02914 02915 /* didn't find delimiter, push back things that we read */ 02916 my_ungetc(c); 02917 while (i > 1) 02918 my_ungetc(tmp[--i]); 02919 return 0; 02920 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int eval_expr | ( | VAR * | v, | |
| const char * | p, | |||
| const char ** | p_end | |||
| ) |
Definition at line 1329 of file mysqltest.c.
References VAR::alloced_len, atoi(), die(), VAR::int_dirty, VAR::int_val, memcpy, MIN_VAR_ALLOC, my_malloc(), my_realloc(), MY_WME, MYF, VAR::str_val, VAR::str_val_len, strlen(), var_copy(), var_get(), and var_query_set().
Referenced by do_block(), var_query_set(), and var_set().
01330 { 01331 VAR* vp; 01332 if (*p == '$') 01333 { 01334 if ((vp = var_get(p,p_end,0,0))) 01335 { 01336 var_copy(v, vp); 01337 return 0; 01338 } 01339 } 01340 else if (*p == '`') 01341 { 01342 return var_query_set(v, p, p_end); 01343 } 01344 else 01345 { 01346 int new_val_len = (p_end && *p_end) ? 01347 (int) (*p_end - p) : (int) strlen(p); 01348 if (new_val_len + 1 >= v->alloced_len) 01349 { 01350 v->alloced_len = (new_val_len < MIN_VAR_ALLOC - 1) ? 01351 MIN_VAR_ALLOC : new_val_len + 1; 01352 if (!(v->str_val = 01353 v->str_val ? my_realloc(v->str_val, v->alloced_len+1, 01354 MYF(MY_WME)) : 01355 my_malloc(v->alloced_len+1, MYF(MY_WME)))) 01356 die("Out of memory"); 01357 } 01358 v->str_val_len = new_val_len; 01359 memcpy(v->str_val, p, new_val_len); 01360 v->str_val[new_val_len] = 0; 01361 v->int_val=atoi(p); 01362 v->int_dirty=0; 01363 return 0; 01364 } 01365 01366 die("Invalid expr: %s", p); 01367 return 1; 01368 }
Here is the call graph for this function:

Here is the caller graph for this function:

| struct connection* find_connection_by_name | ( | const char * | name | ) |
Definition at line 2306 of file mysqltest.c.
References cons, connection::name, next_con, and strcmp().
Referenced by do_connect(), and select_connection_name().
02307 { 02308 struct connection *con; 02309 for (con= cons; con < next_con; con++) 02310 { 02311 if (!strcmp(con->name, name)) 02312 { 02313 return con; 02314 } 02315 } 02316 return 0; /* Connection not found */ 02317 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 6241 of file mysqltest.c.
References st_found_set::found_offset, and st_found_set::table_offset.
Referenced by init_replace().
06242 { 06243 int i; 06244 for (i=0 ; (uint) i < found_sets ; i++) 06245 if (found_set[i].table_offset == table_offset && 06246 found_set[i].found_offset == found_offset) 06247 return -i-2; 06248 found_set[i].table_offset=table_offset; 06249 found_set[i].found_offset=found_offset; 06250 found_sets++; 06251 return -i-2; /* return new postion */ 06252 }
Here is the caller graph for this function:

Definition at line 6220 of file mysqltest.c.
References cmp_bits(), st_rep_sets::count, find(), free_last_set(), and st_rep_sets::set.
06221 { 06222 uint i; 06223 for (i=0 ; i < sets->count-1 ; i++) 06224 { 06225 if (!cmp_bits(sets->set+i,find)) 06226 { 06227 free_last_set(sets); 06228 return i; 06229 } 06230 } 06231 return i; /* return new postion */ 06232 }
Here is the call graph for this function:

| static void free_last_set | ( | REP_SETS * | sets | ) | [static] |
Definition at line 6145 of file mysqltest.c.
References st_rep_sets::count, and st_rep_sets::extra.
Referenced by find_set(), and init_replace().
Here is the caller graph for this function:

| void free_pointer_array | ( | POINTER_ARRAY * | pa | ) |
Definition at line 5733 of file mysqltest.c.
References st_typelib::count, my_free, MYF, st_pointer_array::str, st_typelib::type_names, and st_pointer_array::typelib.
Referenced by get_replace(), and main().
05734 { 05735 if (pa->typelib.count) 05736 { 05737 pa->typelib.count=0; 05738 my_free((gptr) pa->typelib.type_names,MYF(0)); 05739 pa->typelib.type_names=0; 05740 my_free((gptr) pa->str,MYF(0)); 05741 } 05742 } /* free_pointer_array */
Here is the caller graph for this function:

| static void free_re | ( | void | ) | [static] |
Definition at line 4929 of file mysqltest.c.
References my_regex_end(), my_regfree(), ps_re, sp_re, and view_re.
Referenced by free_used_memory().
04930 { 04931 my_regfree(&ps_re); 04932 my_regfree(&sp_re); 04933 my_regfree(&view_re); 04934 my_regex_end(); 04935 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void free_replace | ( | ) |
Definition at line 2295 of file mysqltest.c.
References DBUG_ENTER, DBUG_VOID_RETURN, glob_replace, my_free, and MYF.
Referenced by connect_n_handle_errors(), free_used_memory(), get_replace(), run_query_normal(), and run_query_stmt().
02296 { 02297 DBUG_ENTER("free_replace"); 02298 if (glob_replace) 02299 { 02300 my_free((char*) glob_replace,MYF(0)); 02301 glob_replace=0; 02302 } 02303 DBUG_VOID_RETURN; 02304 }
Here is the caller graph for this function:

| static void free_replace_column | ( | ) | [static] |
Definition at line 6340 of file mysqltest.c.
References max_replace_column, my_free, and replace_column.
Referenced by append_result(), append_stmt_result(), free_used_memory(), and get_replace_column().
06341 { 06342 uint i; 06343 for (i=0 ; i < max_replace_column ; i++) 06344 { 06345 if (replace_column[i]) 06346 { 06347 my_free(replace_column[i], 0); 06348 replace_column[i]= 0; 06349 } 06350 } 06351 max_replace_column= 0; 06352 }
Here is the caller graph for this function:

| static void free_replace_regex | ( | ) | [static] |
Definition at line 2283 of file mysqltest.c.
References st_replace_regex::even_buf, glob_replace_regex, MY_ALLOW_ZERO_PTR, my_free, MYF, and st_replace_regex::odd_buf.
Referenced by connect_n_handle_errors(), get_replace_regex(), run_query_normal(), and run_query_stmt().
02284 { 02285 if (glob_replace_regex) 02286 { 02287 my_free(glob_replace_regex->even_buf,MYF(MY_ALLOW_ZERO_PTR)); 02288 my_free(glob_replace_regex->odd_buf,MYF(MY_ALLOW_ZERO_PTR)); 02289 my_free((char*) glob_replace_regex,MYF(0)); 02290 glob_replace_regex=0; 02291 } 02292 }
Here is the caller graph for this function:

| static void free_sets | ( | REP_SETS * | sets | ) | [static] |
Definition at line 6152 of file mysqltest.c.
References st_rep_sets::bit_buffer, my_free, MYF, and st_rep_sets::set_buffer.
Referenced by init_replace().
06153 { 06154 my_free((gptr)sets->set_buffer,MYF(0)); 06155 my_free((gptr)sets->bit_buffer,MYF(0)); 06156 return; 06157 }
Here is the caller graph for this function:

| static void free_used_memory | ( | ) | [static] |
Definition at line 595 of file mysqltest.c.
References close_cons(), close_files(), DBUG_ENTER, DBUG_VOID_RETURN, default_argv, delete_dynamic(), ds_progress, ds_res, dynamic_element, dynstr_free(), st_dynamic_array::elements, embedded_server_arg_count, embedded_server_args, free_defaults(), free_re(), free_replace(), free_replace_column(), hash_free(), MY_ALLOW_ZERO_PTR, my_free, MY_WME, MYF, mysql_server_end(), pass, q_lines, var_hash, and var_reg.
Referenced by abort_not_supported_test(), die(), and main().
00596 { 00597 uint i; 00598 DBUG_ENTER("free_used_memory"); 00599 00600 close_cons(); 00601 close_files(); 00602 hash_free(&var_hash); 00603 00604 for (i=0 ; i < q_lines.elements ; i++) 00605 { 00606 struct st_query **q= dynamic_element(&q_lines, i, struct st_query**); 00607 my_free((gptr) (*q)->query_buf,MYF(MY_ALLOW_ZERO_PTR)); 00608 my_free((gptr) (*q),MYF(0)); 00609 } 00610 for (i=0; i < 10; i++) 00611 { 00612 if (var_reg[i].alloced_len) 00613 my_free(var_reg[i].str_val, MYF(MY_WME)); 00614 } 00615 while (embedded_server_arg_count > 1) 00616 my_free(embedded_server_args[--embedded_server_arg_count],MYF(0)); 00617 delete_dynamic(&q_lines); 00618 dynstr_free(&ds_res); 00619 dynstr_free(&ds_progress); 00620 free_replace(); 00621 free_replace_column(); 00622 my_free(pass,MYF(MY_ALLOW_ZERO_PTR)); 00623 free_defaults(default_argv); 00624 mysql_server_end(); 00625 free_re(); 00626 #ifdef __WIN__ 00627 free_tmp_sh_file(); 00628 free_win_path_patterns(); 00629 #endif 00630 DBUG_VOID_RETURN; 00631 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1888 of file mysqltest.c.
References charset_info, count, DBUG_ENTER, die(), e, ERR_ERRNO, ERR_SQLSTATE, st_query::first_argument, global_error, my_isalnum, p, st_query::query, SQLSTATE_LENGTH, start(), str2int(), strlen(), and to.
Referenced by main().
01889 { 01890 char *p= q->first_argument; 01891 uint count= 0; 01892 01893 DBUG_ENTER("get_errcodes"); 01894 01895 if (!*p) 01896 die("Missing argument in %s", q->query); 01897 01898 do 01899 { 01900 if (*p == 'S') 01901 { 01902 /* SQLSTATE string */ 01903 char *end= ++p + SQLSTATE_LENGTH; 01904 char *to_ptr= to[count].code.sqlstate; 01905 01906 for (; my_isalnum(charset_info, *p) && p != end; p++) 01907 *to_ptr++= *p; 01908 *to_ptr= 0; 01909 01910 to[count].type= ERR_SQLSTATE; 01911 } 01912 else if (*p == 'E') 01913 { 01914 /* SQL error as string */ 01915 st_error *e= global_error; 01916 char *start= p++; 01917 01918 for (; *p == '_' || my_isalnum(charset_info, *p); p++) 01919 ; 01920 for (; e->name; e++) 01921 { 01922 /* 01923 If we get a match, we need to check the length of the name we 01924 matched against in case it was longer than what we are checking 01925 (as in ER_WRONG_VALUE vs. ER_WRONG_VALUE_COUNT). 01926 */ 01927 if (!strncmp(start, e->name, (int) (p - start)) && 01928 (uint) strlen(e->name) == (uint) (p - start)) 01929 { 01930 to[count].code.errnum= (uint) e->code; 01931 to[count].type= ERR_ERRNO; 01932 break; 01933 } 01934 } 01935 if (!e->name) 01936 die("Unknown SQL error '%s'", start); 01937 } 01938 else 01939 { 01940 long val; 01941 01942 if (!(p= str2int(p,10,(long) INT_MIN, (long) INT_MAX, &val))) 01943 die("Invalid argument in %s", q->query); 01944 to[count].code.errnum= (uint) val; 01945 to[count].type= ERR_ERRNO; 01946 } 01947 count++; 01948 } while (*(p++) == ','); 01949 q->last_argument= (p - 1); 01950 to[count].type= ERR_EMPTY; /* End of data */ 01951 DBUG_RETURN(count); 01952 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void get_file_name | ( | char * | filename, | |
| struct st_query * | q | |||
| ) | [static] |
Definition at line 1855 of file mysqltest.c.
References charset_info, die(), st_query::first_argument, FN_REFLEN, st_query::last_argument, my_isspace, name, p, and strmake().
Referenced by main().
01856 { 01857 char *p= q->first_argument, *name; 01858 if (!*p) 01859 die("Missing file name argument"); 01860 name= p; 01861 while (*p && !my_isspace(charset_info,*p)) 01862 p++; 01863 if (*p) 01864 *p++= 0; 01865 q->last_argument= p; 01866 strmake(filename, name, FN_REFLEN); 01867 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 6195 of file mysqltest.c.
References st_rep_set::bits, pos(), st_rep_set::size_of_bits, start(), and WORD_BIT.
Referenced by init_replace().
06196 { 06197 uint pos,*start,*end,bits; 06198 06199 start=set->bits+ ((lastpos+1) / WORD_BIT); 06200 end=set->bits + set->size_of_bits; 06201 bits=start[0] & ~((1 << ((lastpos+1) % WORD_BIT)) -1); 06202 06203 while (! bits && ++start < end) 06204 bits=start[0]; 06205 if (!bits) 06206 return 0; 06207 pos=(uint) (start-set->bits)*WORD_BIT; 06208 while (! (bits & 1)) 06209 { 06210 bits>>=1; 06211 pos++; 06212 } 06213 return pos; 06214 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static my_bool get_one_option | ( | int | optid, | |
| const struct my_option *opt | __attribute__((unused)), | |||
| char * | argument | |||
| ) | [static] |
Definition at line 3324 of file mysqltest.c.
References cur_file, DBUG_ASSERT, DBUG_PUSH, die(), embedded_server_arg_count, embedded_server_args, errno, exit, test_file::file, FILE_BINARY, test_file::file_name, file_stack, fn_format(), FN_REFLEN, test_file::lineno, MAX_SERVER_ARGS, MY_ALLOW_ZERO_PTR, MY_FAE, my_fopen(), my_free, my_strdup(), MY_UNPACK_FILENAME, MYF, NullS, opt_basedir, OPT_SKIP_SAFEMALLOC, pass, print_version(), read_server_arguments(), sf_malloc_quick, strnmov(), strxmov(), test_if_hard_path(), timer_file, TMPDIR, tty_password, and usage().
03326 { 03327 switch(optid) { 03328 case '#': 03329 #ifndef DBUG_OFF 03330 DBUG_PUSH(argument ? argument : "d:t:S:i:O,/tmp/mysqltest.trace"); 03331 #endif 03332 break; 03333 case 'r': 03334 record = 1; 03335 break; 03336 case 'x': 03337 { 03338 char buff[FN_REFLEN]; 03339 if (!test_if_hard_path(argument)) 03340 { 03341 strxmov(buff, opt_basedir, argument, NullS); 03342 argument= buff; 03343 } 03344 fn_format(buff, argument, "", "", MY_UNPACK_FILENAME); 03345 DBUG_ASSERT(cur_file == file_stack && cur_file->file == 0); 03346 if (!(cur_file->file= 03347 my_fopen(buff, O_RDONLY | FILE_BINARY, MYF(0)))) 03348 die("Could not open %s: errno = %d", buff, errno); 03349 cur_file->file_name= my_strdup(buff, MYF(MY_FAE)); 03350 cur_file->lineno= 1; 03351 break; 03352 } 03353 case 'm': 03354 { 03355 static char buff[FN_REFLEN]; 03356 if (!test_if_hard_path(argument)) 03357 { 03358 strxmov(buff, opt_basedir, argument, NullS); 03359 argument= buff; 03360 } 03361 fn_format(buff, argument, "", "", MY_UNPACK_FILENAME); 03362 timer_file= buff; 03363 unlink(timer_file); /* Ignore error, may not exist */ 03364 break; 03365 } 03366 case 'p': 03367 if (argument) 03368 { 03369 my_free(pass, MYF(MY_ALLOW_ZERO_PTR)); 03370 pass= my_strdup(argument, MYF(MY_FAE)); 03371 while (*argument) *argument++= 'x'; /* Destroy argument */ 03372 tty_password= 0; 03373 } 03374 else 03375 tty_password= 1; 03376 break; 03377 #include <sslopt-case.h> 03378 case 't': 03379 strnmov(TMPDIR, argument, sizeof(TMPDIR)); 03380 break; 03381 case 'A': 03382 if (!embedded_server_arg_count) 03383 { 03384 embedded_server_arg_count=1; 03385 embedded_server_args[0]= (char*) ""; 03386 } 03387 if (embedded_server_arg_count == MAX_SERVER_ARGS-1 || 03388 !(embedded_server_args[embedded_server_arg_count++]= 03389 my_strdup(argument, MYF(MY_FAE)))) 03390 { 03391 die("Can't use server argument"); 03392 } 03393 break; 03394 case 'F': 03395 if (read_server_arguments(argument)) 03396 die(NullS); 03397 break; 03398 case OPT_SKIP_SAFEMALLOC: 03399 #ifdef SAFEMALLOC 03400 sf_malloc_quick=1; 03401 #endif 03402 break; 03403 case 'V': 03404 print_version(); 03405 exit(0); 03406 case '?': 03407 usage(); 03408 exit(1); 03409 } 03410 return 0; 03411 }
Here is the call graph for this function:

| void get_query_type | ( | struct st_query * | q | ) |
Definition at line 4939 of file mysqltest.c.
References command_typelib, DBUG_ENTER, DBUG_VOID_RETURN, die(), find_type(), st_query::first_word_len, parsing_disabled, Q_COMMENT, Q_COMMENT_WITH_COMMAND, Q_DISABLE_PARSING, Q_ENABLE_PARSING, Q_END_BLOCK, Q_QUERY, st_query::query, and st_query::type.
Referenced by main().
04940 { 04941 char save; 04942 uint type; 04943 DBUG_ENTER("get_query_type"); 04944 04945 if (!parsing_disabled && *q->query == '}') 04946 { 04947 q->type = Q_END_BLOCK; 04948 DBUG_VOID_RETURN; 04949 } 04950 if (q->type != Q_COMMENT_WITH_COMMAND) 04951 q->type= parsing_disabled ? Q_COMMENT : Q_QUERY; 04952 04953 save=q->query[q->first_word_len]; 04954 q->query[q->first_word_len]=0; 04955 type=find_type(q->query, &command_typelib, 1+2); 04956 q->query[q->first_word_len]=save; 04957 if (type > 0) 04958 { 04959 q->type=(enum enum_commands) type; /* Found command */ 04960 /* 04961 If queries are disabled, only recognize 04962 --enable_parsing and --disable_parsing 04963 */ 04964 if (parsing_disabled && q->type != Q_ENABLE_PARSING && 04965 q->type != Q_DISABLE_PARSING) 04966 q->type= Q_COMMENT; 04967 } 04968 else if (q->type == Q_COMMENT_WITH_COMMAND && 04969 q->first_word_len && 04970 q->query[q->first_word_len-1] == ';') 04971 { 04972 /* 04973 Detect comment with command using extra delimiter 04974 Ex --disable_query_log; 04975 ^ Extra delimiter causing the command 04976 to be skipped 04977 */ 04978 save= q->query[q->first_word_len-1]; 04979 q->query[q->first_word_len-1]= 0; 04980 type= find_type(q->query, &command_typelib, 1+2); 04981 q->query[q->first_word_len-1]= save; 04982 if (type > 0) 04983 die("Extra delimiter \";\" found"); 04984 } 04985 DBUG_VOID_RETURN; 04986 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void get_replace | ( | struct st_query * | q | ) | [static] |
Definition at line 2241 of file mysqltest.c.
References bzero, charset_info, DBUG_ENTER, DBUG_VOID_RETURN, die(), st_query::end, st_query::first_argument, free_pointer_array(), free_replace(), from, get_string(), glob_replace, init_replace(), insert_pointer_name(), st_query::last_argument, MY_FAE, my_free, my_isspace, my_malloc(), MY_WME, MYF, pos(), st_query::query, start(), strlen(), and to.
Referenced by main().
02242 { 02243 uint i; 02244 char *from= q->first_argument; 02245 char *buff,*start; 02246 char word_end_chars[256],*pos; 02247 POINTER_ARRAY to_array,from_array; 02248 DBUG_ENTER("get_replace"); 02249 02250 free_replace(); 02251 02252 bzero((char*) &to_array,sizeof(to_array)); 02253 bzero((char*) &from_array,sizeof(from_array)); 02254 if (!*from) 02255 die("Missing argument in %s", q->query); 02256 start=buff=my_malloc(strlen(from)+1,MYF(MY_WME | MY_FAE)); 02257 while (*from) 02258 { 02259 char *to=buff; 02260 to=get_string(&buff, &from, q); 02261 if (!*from) 02262 die("Wrong number of arguments to replace_result in '%s'", q->query); 02263 insert_pointer_name(&from_array,to); 02264 to=get_string(&buff, &from, q); 02265 insert_pointer_name(&to_array,to); 02266 } 02267 for (i=1,pos=word_end_chars ; i < 256 ; i++) 02268 if (my_isspace(charset_info,i)) 02269 *pos++= i; 02270 *pos=0; /* End pointer */ 02271 if (!(glob_replace=init_replace((char**) from_array.typelib.type_names, 02272 (char**) to_array.typelib.type_names, 02273 (uint) from_array.typelib.count, 02274 word_end_chars))) 02275 die("Can't initialize replace from '%s'", q->query); 02276 free_pointer_array(&from_array); 02277 free_pointer_array(&to_array); 02278 my_free(start, MYF(0)); 02279 q->last_argument= q->end; 02280 DBUG_VOID_RETURN; 02281 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void get_replace_column | ( | struct st_query * | q | ) | [static] |
Definition at line 6362 of file mysqltest.c.
References atoi(), DBUG_ENTER, die(), st_query::end, st_query::first_argument, free_replace_column(), from, get_string(), st_query::last_argument, MAX_COLUMNS, max_replace_column, MY_ALLOW_ZERO_PTR, MY_FAE, my_free, my_malloc(), my_strdup(), MY_WME, MYF, st_query::query, replace_column, set_if_bigger, start(), strlen(), and to.
Referenced by main().
06363 { 06364 char *from=q->first_argument; 06365 char *buff,*start; 06366 DBUG_ENTER("get_replace_columns"); 06367 06368 free_replace_column(); 06369 if (!*from) 06370 die("Missing argument in %s", q->query); 06371 06372 /* Allocate a buffer for results */ 06373 start=buff=my_malloc(strlen(from)+1,MYF(MY_WME | MY_FAE)); 06374 while (*from) 06375 { 06376 char *to; 06377 uint column_number; 06378 06379 to= get_string(&buff, &from, q); 06380 if (!(column_number= atoi(to)) || column_number > MAX_COLUMNS) 06381 die("Wrong column number to replace_column in '%s'", q->query); 06382 if (!*from) 06383 die("Wrong number of arguments to replace_column in '%s'", q->query); 06384 to= get_string(&buff, &from, q); 06385 my_free(replace_column[column_number-1], MY_ALLOW_ZERO_PTR); 06386 replace_column[column_number-1]= my_strdup(to, MYF(MY_WME | MY_FAE)); 06387 set_if_bigger(max_replace_column, column_number); 06388 } 06389 my_free(start, MYF(0)); 06390 q->last_argument= q->end; 06391 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void get_replace_regex | ( | struct st_query * | q | ) | [static] |
Definition at line 2223 of file mysqltest.c.
References die(), st_query::end, st_query::first_argument, free_replace_regex(), glob_replace_regex, init_replace_regex(), and st_query::last_argument.
Referenced by main().
02224 { 02225 char *expr= q->first_argument; 02226 free_replace_regex(); 02227 if (!(glob_replace_regex=init_replace_regex(expr))) 02228 die("Could not init replace_regex"); 02229 q->last_argument= q->end; 02230 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static char* get_string | ( | char ** | to_ptr, | |
| char ** | from_ptr, | |||
| struct st_query * | q | |||
| ) | [static] |
Definition at line 1962 of file mysqltest.c.
References charset_info, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, die(), from, my_isspace, st_query::query, reg1, start(), VAR::str_val, to, and var_get().
Referenced by get_replace(), and get_replace_column().
01964 { 01965 reg1 char c,sep; 01966 char *to= *to_ptr, *from= *from_ptr, *start=to; 01967 DBUG_ENTER("get_string"); 01968 01969 /* Find separator */ 01970 if (*from == '"' || *from == '\'') 01971 sep= *from++; 01972 else 01973 sep=' '; /* Separated with space */ 01974 01975 for ( ; (c=*from) ; from++) 01976 { 01977 if (c == '\\' && from[1]) 01978 { /* Escaped character */ 01979 /* We can't translate \0 -> ASCII 0 as replace can't handle ASCII 0 */ 01980 switch (*++from) { 01981 case 'n': 01982 *to++= '\n'; 01983 break; 01984 case 't': 01985 *to++= '\t'; 01986 break; 01987 case 'r': 01988 *to++ = '\r'; 01989 break; 01990 case 'b': 01991 *to++ = '\b'; 01992 break; 01993 case 'Z': /* ^Z must be escaped on Win32 */ 01994 *to++='\032'; 01995 break; 01996 default: 01997 *to++ = *from; 01998 break; 01999 } 02000 } 02001 else if (c == sep) 02002 { 02003 if (c == ' ' || c != *++from) 02004 break; /* Found end of string */ 02005 *to++=c; /* Copy duplicated separator */ 02006 } 02007 else 02008 *to++=c; 02009 } 02010 if (*from != ' ' && *from) 02011 die("Wrong string argument in %s", q->query); 02012 02013 while (my_isspace(charset_info,*from)) /* Point to next string */ 02014 from++; 02015 02016 *to =0; /* End of string marker */ 02017 *to_ptr= to+1; /* Store pointer to end */ 02018 *from_ptr= from; 02019 02020 /* Check if this was a variable */ 02021 if (*start == '$') 02022 { 02023 const char *end= to; 02024 VAR *var=var_get(start, &end, 0, 1); 02025 if (var && to == (char*) end+1) 02026 { 02027 DBUG_PRINT("info",("var: '%s' -> '%s'", start, var->str_val)); 02028 DBUG_RETURN(var->str_val); /* return found variable value */ 02029 } 02030 } 02031 DBUG_RETURN(start); 02032 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void handle_error | ( | const char * | query, | |
| struct st_query * | q, | |||
| unsigned int | err_errno, | |||
| const char * | err_error, | |||
| const char * | err_sqlstate, | |||
| DYNAMIC_STRING * | ds | |||
| ) | [static] |
Definition at line 4279 of file mysqltest.c.
References abort_not_supported_test(), st_query::abort_on_error, match_err::code, CR_SERVER_GONE_ERROR, CR_SERVER_LOST, DBUG_ENTER, DBUG_VOID_RETURN, die(), disable_result_log, dynstr_append(), dynstr_append_mem(), ERR_ERRNO, ERR_SQLSTATE, match_err::errnum, st_query::expected_errno, st_query::expected_errors, replace_dynstr_append(), st_query::require_file, match_err::sqlstate, strcmp(), and match_err::type.
Referenced by connect_n_handle_errors(), reportShutdown(), run_query_normal(), and run_query_stmt().
04282 { 04283 uint i; 04284 04285 DBUG_ENTER("handle_error"); 04286 04287 if (q->require_file) 04288 { 04289 /* 04290 The query after a "--require" failed. This is fine as long the server 04291 returned a valid reponse. Don't allow 2013 or 2006 to trigger an 04292 abort_not_supported_test 04293 */ 04294 if (err_errno == CR_SERVER_LOST || 04295 err_errno == CR_SERVER_GONE_ERROR) 04296 die("require query '%s' failed: %d: %s", query, err_errno, err_error); 04297 04298 /* Abort the run of this test, pass the failed query as reason */ 04299 abort_not_supported_test("Query '%s' failed, required functionality not supported", query); 04300 } 04301 04302 if (q->abort_on_error) 04303 die("query '%s' failed: %d: %s", query, err_errno, err_error); 04304 04305 for (i= 0 ; (uint) i < q->expected_errors ; i++) 04306 { 04307 if (((q->expected_errno[i].type == ERR_ERRNO) && 04308 (q->expected_errno[i].code.errnum == err_errno)) || 04309 ((q->expected_errno[i].type == ERR_SQLSTATE) && 04310 (strcmp(q->expected_errno[i].code.sqlstate, err_sqlstate) == 0))) 04311 { 04312 if (!disable_result_log) 04313 { 04314 if (q->expected_errors == 1) 04315 { 04316 /* Only log error if there is one possible error */ 04317 dynstr_append_mem(ds, "ERROR ", 6); 04318 replace_dynstr_append(ds, err_sqlstate); 04319 dynstr_append_mem(ds, ": ", 2); 04320 replace_dynstr_append(ds, err_error); 04321 dynstr_append_mem(ds,"\n",1); 04322 } 04323 /* Don't log error if we may not get an error */ 04324 else if (q->expected_errno[0].type == ERR_SQLSTATE || 04325 (q->expected_errno[0].type == ERR_ERRNO && 04326 q->expected_errno[0].code.errnum != 0)) 04327 dynstr_append(ds,"Got one of the listed errors\n"); 04328 } 04329 /* OK */ 04330 DBUG_VOID_RETURN; 04331 } 04332 } 04333 04334 DBUG_PRINT("info",("i: %d expected_errors: %d", i, q->expected_errors)); 04335 04336 if (!disable_result_log) 04337 { 04338 dynstr_append_mem(ds, "ERROR ",6); 04339 replace_dynstr_append(ds, err_sqlstate); 04340 dynstr_append_mem(ds, ": ", 2); 04341 replace_dynstr_append(ds, err_error); 04342 dynstr_append_mem(ds, "\n", 1); 04343 } 04344 04345 if (i) 04346 { 04347 if (q->expected_errno[0].type == ERR_ERRNO) 04348 die("query '%s' failed with wrong errno %d: '%s', instead of %d...", 04349 q->query, err_errno, err_error, q->expected_errno[0].code.errnum); 04350 else 04351 die("query '%s' failed with wrong sqlstate %s: '%s', instead of %s...", 04352 q->query, err_sqlstate, err_error, 04353 q->expected_errno[0].code.sqlstate); 04354 } 04355 04356 DBUG_VOID_RETURN; 04357 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void handle_no_error | ( | struct st_query * | q | ) | [static] |
Definition at line 4371 of file mysqltest.c.
References match_err::code, DBUG_ENTER, DBUG_VOID_RETURN, die(), ERR_ERRNO, ERR_SQLSTATE, match_err::errnum, st_query::expected_errno, st_query::query, match_err::sqlstate, strcmp(), and match_err::type.
Referenced by connect_n_handle_errors(), run_query_normal(), and run_query_stmt().
04372 { 04373 DBUG_ENTER("handle_no_error"); 04374 04375 if (q->expected_errno[0].type == ERR_ERRNO && 04376 q->expected_errno[0].code.errnum != 0) 04377 { 04378 /* Error code we wanted was != 0, i.e. not an expected success */ 04379 die("query '%s' succeeded - should have failed with errno %d...", 04380 q->query, q->expected_errno[0].code.errnum); 04381 } 04382 else if (q->expected_errno[0].type == ERR_SQLSTATE && 04383 strcmp(q->expected_errno[0].code.sqlstate,"00000") != 0) 04384 { 04385 /* SQLSTATE we wanted was != "00000", i.e. not an expected success */ 04386 die("query '%s' succeeded - should have failed with sqlstate %s...", 04387 q->query, q->expected_errno[0].code.sqlstate); 04388 } 04389 04390 DBUG_VOID_RETURN; 04391 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void init_parser | ( | ) |
Definition at line 727 of file mysqltest.c.
References PARSER::current_line, memset, parser, PARSER::read_lines, and var_reg.
00728 { 00729 parser.current_line= parser.read_lines= 0; 00730 memset(&var_reg, 0, sizeof(var_reg)); 00731 }
| static void init_re | ( | void | ) | [static] |
Definition at line 4872 of file mysqltest.c.
References init_re_comp(), ps_re, sp_re, and view_re.
Referenced by main().
04873 { 04874 /* 04875 Filter for queries that can be run using the 04876 MySQL Prepared Statements C API 04877 */ 04878 const char *ps_re_str = 04879 "^(" 04880 "[[:space:]]*REPLACE[[:space:]]|" 04881 "[[:space:]]*INSERT[[:space:]]|" 04882 "[[:space:]]*UPDATE[[:space:]]|" 04883 "[[:space:]]*DELETE[[:space:]]|" 04884 "[[:space:]]*SELECT[[:space:]]|" 04885 "[[:space:]]*CREATE[[:space:]]+TABLE[[:space:]]|" 04886 "[[:space:]]*DO[[:space:]]|" 04887 "[[:space:]]*SET[[:space:]]+OPTION[[:space:]]|" 04888 "[[:space:]]*DELETE[[:space:]]+MULTI[[:space:]]|" 04889 "[[:space:]]*UPDATE[[:space:]]+MULTI[[:space:]]|" 04890 "[[:space:]]*INSERT[[:space:]]+SELECT[[:space:]])"; 04891 04892 /* 04893 Filter for queries that can be run using the 04894 Stored procedures 04895 */ 04896 const char *sp_re_str =ps_re_str; 04897 04898 /* 04899 Filter for queries that can be run as views 04900 */ 04901 const char *view_re_str = 04902 "^(" 04903 "[[:space:]]*SELECT[[:space:]])"; 04904 04905 init_re_comp(&ps_re, ps_re_str); 04906 init_re_comp(&sp_re, sp_re_str); 04907 init_re_comp(&view_re, view_re_str); 04908 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void init_re_comp | ( | my_regex_t * | re, | |
| const char * | str | |||
| ) | [static] |
Definition at line 4859 of file mysqltest.c.
References die(), err, my_charset_latin1, my_regcomp(), my_regerror(), re_eprint(), REG_EXTENDED, REG_ICASE, and REG_NOSUB.
Referenced by init_re().
04860 { 04861 int err= my_regcomp(re, str, (REG_EXTENDED | REG_ICASE | REG_NOSUB), 04862 &my_charset_latin1); 04863 if (err) 04864 { 04865 char erbuf[100]; 04866 int len= my_regerror(err, re, erbuf, sizeof(erbuf)); 04867 die("error %s, %d/%d `%s'\n", 04868 re_eprint(err), len, (int)sizeof(erbuf), erbuf); 04869 } 04870 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static REPLACE * init_replace | ( | my_string * | from, | |
| my_string * | to, | |||
| uint | count, | |||
| my_string | word_end_chars | |||
| ) |
Definition at line 5802 of file mysqltest.c.
References bzero, st_follow::chr, copy_bits(), st_rep_sets::count, DBUG_ENTER, DBUG_RETURN, END_OF_LINE, errno, find_found(), find_set(), st_rep_set::found_len, st_rep_set::found_offset, free_last_set(), free_sets(), get_next_bit(), init_sets(), internal_clear_bit(), internal_set_bit(), LAST_CHAR_CODE, st_follow::len, make_new_set(), make_sets_invisible(), ME_BELL, my_free, my_malloc(), my_message(), MY_WME, MYF, st_rep_set::next, or_bits(), pos(), replace, replace_len(), st_rep_sets::set, SPACE_CHAR, START_OF_LINE, states, strlen(), st_follow::table_offset, st_rep_set::table_offset, and VOID.
Referenced by get_replace(), and main().
05804 { 05805 uint i,j,states,set_nr,len,result_len,max_length,found_end,bits_set,bit_nr; 05806 int used_sets,chr,default_state; 05807 char used_chars[LAST_CHAR_CODE],is_word_end[256]; 05808 my_string pos,to_pos,*to_array; 05809 REP_SETS sets; 05810 REP_SET *set,*start_states,*word_states,*new_set; 05811 FOLLOWS *follow,*follow_ptr; 05812 REPLACE *replace; 05813 FOUND_SET *found_set; 05814 REPLACE_STRING *rep_str; 05815 DBUG_ENTER("init_replace"); 05816 05817 /* Count number of states */ 05818 for (i=result_len=max_length=0 , states=2 ; i < count ; i++) 05819 { 05820 len=replace_len(from[i]); 05821 if (!len) 05822 { 05823 errno=EINVAL; 05824 my_message(0,"No to-string for last from-string",MYF(ME_BELL)); 05825 DBUG_RETURN(0); 05826 } 05827 states+=len+1; 05828 result_len+=(uint) strlen(to[i])+1; 05829 if (len > max_length) 05830 max_length=len; 05831 } 05832 bzero((char*) is_word_end,sizeof(is_word_end)); 05833 for (i=0 ; word_end_chars[i] ; i++) 05834 is_word_end[(uchar) word_end_chars[i]]=1; 05835 05836 if (init_sets(&sets,states)) 05837 DBUG_RETURN(0); 05838 found_sets=0; 05839 if (!(found_set= (FOUND_SET*) my_malloc(sizeof(FOUND_SET)*max_length*count, 05840 MYF(MY_WME)))) 05841 { 05842 free_sets(&sets); 05843 DBUG_RETURN(0); 05844 } 05845 VOID(make_new_set(&sets)); /* Set starting set */ 05846 make_sets_invisible(&sets); /* Hide previus sets */ 05847 used_sets=-1; 05848 word_states=make_new_set(&sets); /* Start of new word */ 05849 start_states=make_new_set(&sets); /* This is first state */ 05850 if (!(follow=(FOLLOWS*) my_malloc((states+2)*sizeof(FOLLOWS),MYF(MY_WME)))) 05851 { 05852 free_sets(&sets); 05853 my_free((gptr) found_set,MYF(0)); 05854 DBUG_RETURN(0); 05855 } 05856 05857 /* Init follow_ptr[] */ 05858 for (i=0, states=1, follow_ptr=follow+1 ; i < count ; i++) 05859 { 05860 if (from[i][0] == '\\' && from[i][1] == '^') 05861 { 05862 internal_set_bit(start_states,states+1); 05863 if (!from[i][2]) 05864 { 05865 start_states->table_offset=i; 05866 start_states->found_offset=1; 05867 } 05868 } 05869 else if (from[i][0] == '\\' && from[i][1] == '$') 05870 { 05871 internal_set_bit(start_states,states); 05872 internal_set_bit(word_states,states); 05873 if (!from[i][2] && start_states->table_offset == (uint) ~0) 05874 { 05875 start_states->table_offset=i; 05876 start_states->found_offset=0; 05877 } 05878 } 05879 else 05880 { 05881 internal_set_bit(word_states,states); 05882 if (from[i][0] == '\\' && (from[i][1] == 'b' && from[i][2])) 05883 internal_set_bit(start_states,states+1); 05884 else 05885 internal_set_bit(start_states,states); 05886 } 05887 for (pos=from[i], len=0; *pos ; pos++) 05888 { 05889 if (*pos == '\\' && *(pos+1)) 05890 { 05891 pos++; 05892 switch (*pos) { 05893 case 'b': 05894 follow_ptr->chr = SPACE_CHAR; 05895 break; 05896 case '^': 05897 follow_ptr->chr = START_OF_LINE; 05898 break; 05899 case '$': 05900 follow_ptr->chr = END_OF_LINE; 05901 break; 05902 case 'r': 05903 follow_ptr->chr = '\r'; 05904 break; 05905 case 't': 05906 follow_ptr->chr = '\t'; 05907 break; 05908 case 'v': 05909 follow_ptr->chr = '\v'; 05910 break; 05911 default: 05912 follow_ptr->chr = (uchar) *pos; 05913 break; 05914 } 05915 } 05916 else 05917 follow_ptr->chr= (uchar) *pos; 05918 follow_ptr->table_offset=i; 05919 follow_ptr->len= ++len; 05920 follow_ptr++; 05921 } 05922 follow_ptr->chr=0; 05923 follow_ptr->table_offset=i; 05924 follow_ptr->len=len; 05925 follow_ptr++; 05926 states+=(uint) len+1; 05927 } 05928 05929 05930 for (set_nr=0,pos=0 ; set_nr < sets.count ; set_nr++) 05931 { 05932 set=sets.set+set_nr; 05933 default_state= 0; /* Start from beginning */ 05934 05935 /* If end of found-string not found or start-set with current set */ 05936 05937 for (i= (uint) ~0; (i=get_next_bit(set,i)) ;) 05938 { 05939 if (!follow[i].chr) 05940 { 05941 if (! default_state) 05942 default_state= find_found(found_set,set->table_offset, 05943 set->found_offset+1); 05944 } 05945 } 05946 copy_bits(sets.set+used_sets,set); /* Save set for changes */ 05947 if (!default_state) 05948 or_bits(sets.set+used_sets,sets.set); /* Can restart from start */ 05949 05950 /* Find all chars that follows current sets */ 05951 bzero((char*) used_chars,sizeof(used_chars)); 05952 for (i= (uint) ~0; (i=get_next_bit(sets.set+used_sets,i)) ;) 05953 { 05954 used_chars[follow[i].chr]=1; 05955 if ((follow[i].chr == SPACE_CHAR && !follow[i+1].chr && 05956 follow[i].len > 1) || follow[i].chr == END_OF_LINE) 05957 used_chars[0]=1; 05958 } 05959 05960 /* Mark word_chars used if \b is in state */ 05961 if (used_chars[SPACE_CHAR]) 05962 for (pos= word_end_chars ; *pos ; pos++) 05963 used_chars[(int) (uchar) *pos] = 1; 05964 05965 /* Handle other used characters */ 05966 for (chr= 0 ; chr < 256 ; chr++) 05967 { 05968 if (! used_chars[chr]) 05969 set->next[chr]= chr ? default_state : -1; 05970 else 05971 { 05972 new_set=make_new_set(&sets); 05973 set=sets.set+set_nr; /* if realloc */ 05974 new_set->table_offset=set->table_offset; 05975 new_set->found_len=set->found_len; 05976 new_set->found_offset=set->found_offset+1; 05977 found_end=0; 05978 05979 for (i= (uint) ~0 ; (i=get_next_bit(sets.set+used_sets,i)) ; ) 05980 { 05981 if (!follow[i].chr || follow[i].chr == chr || 05982 (follow[i].chr == SPACE_CHAR && 05983 (is_word_end[chr] || 05984 (!chr && follow[i].len > 1 && ! follow[i+1].chr))) || 05985 (follow[i].chr == END_OF_LINE && ! chr)) 05986 { 05987 if ((! chr || (follow[i].chr && !follow[i+1].chr)) && 05988 follow[i].len > found_end) 05989 found_end=follow[i].len; 05990 if (chr && follow[i].chr) 05991 internal_set_bit(new_set,i+1); /* To next set */ 05992 else 05993 internal_set_bit(new_set,i); 05994 } 05995 } 05996 if (found_end) 05997 { 05998 new_set->found_len=0; /* Set for testing if first */ 05999 bits_set=0; 06000 for (i= (uint) ~0; (i=get_next_bit(new_set,i)) ;) 06001 { 06002 if ((follow[i].chr == SPACE_CHAR || 06003 follow[i].chr == END_OF_LINE) && ! chr) 06004 bit_nr=i+1; 06005 else 06006 bit_nr=i; 06007 if (follow[bit_nr-1].len < found_end || 06008 (new_set->found_len && 06009 (chr == 0 || !follow[bit_nr].chr))) 06010 internal_clear_bit(new_set,i); 06011 else 06012 { 06013 if (chr == 0 || !follow[bit_nr].chr) 06014 { /* best match */ 06015 new_set->table_offset=follow[bit_nr].table_offset; 06016 if (chr || (follow[i].chr == SPACE_CHAR || 06017 follow[i].chr == END_OF_LINE)) 06018 new_set->found_offset=found_end; /* New match */ 06019 new_set->found_len=found_end; 06020 } 06021 bits_set++; 06022 } 06023 } 06024 if (bits_set == 1) 06025 { 06026 set->next[chr] = find_found(found_set, 06027 new_set->table_offset, 06028 new_set->found_offset); 06029 free_last_set(&sets); 06030 } 06031 else 06032 set->next[chr] = find_set(&sets,new_set); 06033 } 06034 else 06035 set->next[chr] = find_set(&sets,new_set); 06036 } 06037 } 06038 } 06039 06040 /* Alloc replace structure for the replace-state-machine */ 06041 06042 if ((replace=(REPLACE*) my_malloc(sizeof(REPLACE)*(sets.count)+ 06043 sizeof(REPLACE_STRING)*(found_sets+1)+ 06044 sizeof(my_string)*count+result_len, 06045 MYF(MY_WME | MY_ZEROFILL)))) 06046 { 06047 rep_str=(REPLACE_STRING*) (replace+sets.count); 06048 to_array=(my_string*) (rep_str+found_sets+1); 06049 to_pos=(my_string) (to_array+count); 06050 for (i=0 ; i < count ; i++) 06051 { 06052 to_array[i]=to_pos; 06053 to_pos=strmov(to_pos,to[i])+1; 06054 } 06055 rep_str[0].found=1; 06056 rep_str[0].replace_string=0; 06057 for (i=1 ; i <= found_sets ; i++) 06058 { 06059 pos=from[found_set[i-1].table_offset]; 06060 rep_str[i].found= !bcmp(pos,"\\^",3) ? 2 : 1; 06061 rep_str[i].replace_string=to_array[found_set[i-1].table_offset]; 06062 rep_str[i].to_offset=found_set[i-1].found_offset-start_at_word(pos); 06063 rep_str[i].from_offset=found_set[i-1].found_offset-replace_len(pos)+ 06064 end_of_word(pos); 06065 } 06066 for (i=0 ; i < sets.count ; i++) 06067 { 06068 for (j=0 ; j < 256 ; j++) 06069 if (sets.set[i].next[j] >= 0) 06070 replace[i].next[j]=replace+sets.set[i].next[j]; 06071 else 06072 replace[i].next[j]=(REPLACE*) (rep_str+(-sets.set[i].next[j]-1)); 06073 } 06074 } 06075 my_free((gptr) follow,MYF(0)); 06076 free_sets(&sets); 06077 my_free((gptr) found_set,MYF(0)); 06078 DBUG_PRINT("exit",("Replace table has %d states",sets.count)); 06079 DBUG_RETURN(replace); 06080 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static struct st_replace_regex* init_replace_regex | ( | char * | expr | ) | [static] |
Definition at line 2069 of file mysqltest.c.
References buf, bzero, die(), err, insert_dynamic(), MY_FAE, my_free, my_init_dynamic_array, my_malloc(), MY_WME, MYF, p, PARSE_REGEX_ARG, reg(), and strlen().
Referenced by get_replace_regex().
02070 { 02071 struct st_replace_regex* res; 02072 char* buf,*expr_end; 02073 char* p; 02074 char* buf_p; 02075 uint expr_len= strlen(expr); 02076 char last_c = 0; 02077 struct st_regex reg; 02078 02079 /* my_malloc() will die on fail with MY_FAE */ 02080 res=(struct st_replace_regex*)my_malloc( 02081 sizeof(*res)+expr_len ,MYF(MY_FAE+MY_WME)); 02082 my_init_dynamic_array(&res->regex_arr,sizeof(struct st_regex),128,128); 02083 02084 buf= (char*)res + sizeof(*res); 02085 expr_end= expr + expr_len; 02086 p= expr; 02087 buf_p= buf; 02088 02089 /* for each regexp substitution statement */ 02090 while (p < expr_end) 02091 { 02092 bzero(®,sizeof(reg)); 02093 /* find the start of the statement */ 02094 while (p < expr_end) 02095 { 02096 if (*p == '/') 02097 break; 02098 p++; 02099 } 02100 02101 if (p == expr_end || ++p == expr_end) 02102 { 02103 if (res->regex_arr.elements) 02104 break; 02105 else 02106 goto err; 02107 } 02108 /* we found the start */ 02109 reg.pattern= buf_p; 02110 02111 /* Find first argument -- pattern string to be removed */ 02112 PARSE_REGEX_ARG 02113 02114 if (p == expr_end || ++p == expr_end) 02115 goto err; 02116 02117 /* buf_p now points to the replacement pattern terminated with \0 */ 02118 reg.replace= buf_p; 02119 02120 /* Find second argument -- replace string to replace pattern */ 02121 PARSE_REGEX_ARG 02122 02123 if (p == expr_end) 02124 goto err; 02125 02126 /* skip the ending '/' in the statement */ 02127 p++; 02128 02129 /* Check if we should do matching case insensitive */ 02130 if (p < expr_end && *p == 'i') 02131 reg.icase= 1; 02132 02133 /* done parsing the statement, now place it in regex_arr */ 02134 if (insert_dynamic(&res->regex_arr,(gptr) ®)) 02135 die("Out of memory"); 02136 } 02137 res->odd_buf_len= res->even_buf_len= 8192; 02138 res->even_buf= (char*)my_malloc(res->even_buf_len,MYF(MY_WME+MY_FAE)); 02139 res->odd_buf= (char*)my_malloc(res->odd_buf_len,MYF(MY_WME+MY_FAE)); 02140 res->buf= res->even_buf; 02141 02142 return res; 02143 02144 err: 02145 my_free((gptr)res,0); 02146 die("Error parsing replace_regex \"%s\"", expr); 02147 return 0; 02148 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 6083 of file mysqltest.c.
References bzero, my_free, my_malloc(), MY_WME, MYF, and SET_MALLOC_HUNC.
Referenced by init_replace().
06084 { 06085 bzero((char*) sets,sizeof(*sets)); 06086 sets->size_of_bits=((states+7)/8); 06087 if (!(sets->set_buffer=(REP_SET*) my_malloc(sizeof(REP_SET)*SET_MALLOC_HUNC, 06088 MYF(MY_WME)))) 06089 return 1; 06090 if (!(sets->bit_buffer=(uint*) my_malloc(sizeof(uint)*sets->size_of_bits* 06091 SET_MALLOC_HUNC,MYF(MY_WME)))) 06092 { 06093 my_free((gptr) sets->set,MYF(0)); 06094 return 1; 06095 } 06096 return 0; 06097 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void init_var_hash | ( | MYSQL * | mysql | ) | [static] |
Definition at line 5054 of file mysqltest.c.
References charset_info, db, DBUG_ENTER, DBUG_VOID_RETURN, die(), get_var_key(), hash_init, my_hash_insert(), MYF, mysql, mysql_get_server_info(), opt_big_test, var_free(), var_hash, and var_init().
05055 { 05056 VAR *v; 05057 DBUG_ENTER("init_var_hash"); 05058 if (hash_init(&var_hash, charset_info, 05059 1024, 0, 0, get_var_key, var_free, MYF(0))) 05060 die("Variable hash initialization failed"); 05061 my_hash_insert(&var_hash, (byte*) var_init(0,"BIG_TEST", 0, 05062 (opt_big_test) ? "1" : "0", 0)); 05063 v= var_init(0,"MAX_TABLES", 0, (sizeof(ulong) == 4) ? "31" : "62",0); 05064 my_hash_insert(&var_hash, (byte*) v); 05065 v= var_init(0,"SERVER_VERSION", 0, mysql_get_server_info(mysql), 0); 05066 my_hash_insert(&var_hash, (byte*) v); v= var_init(0,"DB", 2, db, 0); 05067 my_hash_insert(&var_hash, (byte*) v); 05068 DBUG_VOID_RETURN; 05069 }
Here is the call graph for this function:

| static void init_var_hash | ( | ) | [static] |
| static int insert_pointer_name | ( | reg1 POINTER_ARRAY * | pa, | |
| my_string | name | |||
| ) | [static] |
Definition at line 5660 of file mysqltest.c.
References ADD_TO_PTR, DBUG_ENTER, DBUG_RETURN, MALLOC_OVERHEAD, memcpy, my_free, my_malloc(), my_realloc(), MY_WME, MYF, PC_MALLOC, PS_MALLOC, PTR_BYTE_DIFF, and strlen().
Referenced by get_replace(), and get_replace_strings().
05661 { 05662 uint i,length,old_count; 05663 byte *new_pos; 05664 const char **new_array; 05665 DBUG_ENTER("insert_pointer_name"); 05666 05667 if (! pa->typelib.count) 05668 { 05669 if (!(pa->typelib.type_names=(const char **) 05670 my_malloc(((PC_MALLOC-MALLOC_OVERHEAD)/ 05671 (sizeof(my_string)+sizeof(*pa->flag))* 05672 (sizeof(my_string)+sizeof(*pa->flag))),MYF(MY_WME)))) 05673 DBUG_RETURN(-1); 05674 if (!(pa->str= (byte*) my_malloc((uint) (PS_MALLOC-MALLOC_OVERHEAD), 05675 MYF(MY_WME)))) 05676 { 05677 my_free((gptr) pa->typelib.type_names,MYF(0)); 05678 DBUG_RETURN (-1); 05679 } 05680 pa->max_count=(PC_MALLOC-MALLOC_OVERHEAD)/(sizeof(byte*)+ 05681 sizeof(*pa->flag)); 05682 pa->flag= (int7*) (pa->typelib.type_names+pa->max_count); 05683 pa->length=0; 05684 pa->max_length=PS_MALLOC-MALLOC_OVERHEAD; 05685 pa->array_allocs=1; 05686 } 05687 length=(uint) strlen(name)+1; 05688 if (pa->length+length >= pa->max_length) 05689 { 05690 if (!(new_pos= (byte*) my_realloc((gptr) pa->str, 05691 (uint) (pa->max_length+PS_MALLOC), 05692 MYF(MY_WME)))) 05693 DBUG_RETURN(1); 05694 if (new_pos != pa->str) 05695 { 05696 my_ptrdiff_t diff=PTR_BYTE_DIFF(new_pos,pa->str); 05697 for (i=0 ; i < pa->typelib.count ; i++) 05698 pa->typelib.type_names[i]= ADD_TO_PTR(pa->typelib.type_names[i],diff, 05699 char*); 05700 pa->str=new_pos; 05701 } 05702 pa->max_length+=PS_MALLOC; 05703 } 05704 if (pa->typelib.count >= pa->max_count-1) 05705 { 05706 int len; 05707 pa->array_allocs++; 05708 len=(PC_MALLOC*pa->array_allocs - MALLOC_OVERHEAD); 05709 if (!(new_array=(const char **) my_realloc((gptr) pa->typelib.type_names, 05710 (uint) len/ 05711 (sizeof(byte*)+sizeof(*pa->flag))* 05712 (sizeof(byte*)+sizeof(*pa->flag)), 05713 MYF(MY_WME)))) 05714 DBUG_RETURN(1); 05715 pa->typelib.type_names=new_array; 05716 old_count=pa->max_count; 05717 pa->max_count=len/(sizeof(byte*) + sizeof(*pa->flag)); 05718 pa->flag= (int7*) (pa->typelib.type_names+pa->max_count); 05719 memcpy((byte*) pa->flag,(my_string) (pa->typelib.type_names+old_count), 05720 old_count*sizeof(*pa->flag)); 05721 } 05722 pa->flag[pa->typelib.count]=0; /* Reset flag */ 05723 pa->typelib.type_names[pa->typelib.count++]= pa->str+pa->length; 05724 pa->typelib.type_names[pa->typelib.count]= NullS; /* Put end-mark */ 05725 VOID(strmov(pa->str+pa->length,name)); 05726 pa->length+=length; 05727 DBUG_RETURN(0); 05728 } /* insert_pointer_name */
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 6165 of file mysqltest.c.
References st_rep_set::bits, and WORD_BIT.
Referenced by init_replace().
Here is the caller graph for this function:

Definition at line 6159 of file mysqltest.c.
References st_rep_set::bits, and WORD_BIT.
Referenced by init_replace().
Here is the caller graph for this function:

| int main | ( | int | argc, | |
| char ** | argv | |||
| ) |
Definition at line 5112 of file mysqltest.c.
References abort_on_error, block_stack, BLOCK_STACK_DEPTH, block_stack_end, bzero, charset_name, check_eol_junk(), check_result(), close_connection(), BLOCK::cmd, cmd_if, cmd_none, cmd_while, cons, cons_end, cur_block, cur_con, cur_file, PARSER::current_line, cursor_protocol, cursor_protocol_enabled, db, DBUG_PRINT, delimiter, delimiter_length, die(), disable_info, disable_ps_warnings, disable_query_log, disable_result_log, disable_warnings, display_metadata, display_result_vertically, do_block(), do_connect(), DO_DEC, do_disable_rpl_parse(), do_done(), do_echo(), do_enable_rpl_parse(), do_exec(), do_let(), do_modify_var(), do_rpl_probe(), do_save_master_pos(), do_sleep(), do_source(), do_sync_with_master(), do_sync_with_master2(), do_system(), do_wait_for_slave_to_stop(), ds_progress, ds_res, dump_progress(), dynstr_free(), embedded_server_arg_count, embedded_server_args, embedded_server_groups, eval_result, exit, FALSE, test_file::file, test_file::file_name, file_stack, file_stack_end, flags, FN_REFLEN, free_used_memory(), get_errcodes(), get_file_name(), get_query_type(), get_replace(), get_replace_column(), get_replace_regex(), global_expected_errno, global_expected_errors, got_end_timer, host, init_dynamic_string(), INIT_Q_LINES, init_re(), init_var_hash(), st_dynamic_string::length, test_file::lineno, mark_progress(), master_pos, MAX_CONS, MAX_INCLUDE_DEPTH, memset, MY_CHECK_ERROR, my_end(), MY_INIT, my_init_dynamic_array, my_stat(), MY_STAT, my_strdup(), MY_WME, MYF, connection::mysql, mysql_errno(), mysql_error(), mysql_init(), MYSQL_OPT_COMPRESS, MYSQL_OPT_LOCAL_INFILE, MYSQL_OPT_RECONNECT, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, mysql_options(), mysql_ping(), mysql_server_init, MYSQL_SET_CHARSET_NAME, mysql_ssl_set(), connection::name, next_con, NullS, BLOCK::ok, open_file(), opt_compress, opt_include, opt_mark_progress, parse_args(), parser, parsing_disabled, pass, port, ps_protocol, ps_protocol_enabled, Q_CHARACTER_SET, Q_COMMENT, Q_COMMENT_WITH_COMMAND, Q_CONNECT, Q_CONNECTION, Q_DEC, Q_DELIMITER, Q_DIE, Q_DIRTY_CLOSE, Q_DISABLE_ABORT_ON_ERROR, Q_DISABLE_INFO, Q_DISABLE_METADATA, Q_DISABLE_PARSING, Q_DISABLE_PS_PROTOCOL, Q_DISABLE_PS_WARNINGS, Q_DISABLE_QUERY_LOG, Q_DISABLE_RECONNECT, Q_DISABLE_RESULT_LOG, Q_DISABLE_RPL_PARSE, Q_DISABLE_WARNINGS, Q_DISCONNECT, Q_DISPLAY_HORIZONTAL_RESULTS, Q_DISPLAY_VERTICAL_RESULTS, Q_ECHO, Q_ENABLE_ABORT_ON_ERROR, Q_ENABLE_INFO, Q_ENABLE_METADATA, Q_ENABLE_PARSING, Q_ENABLE_PS_PROTOCOL, Q_ENABLE_PS_WARNINGS, Q_ENABLE_QUERY_LOG, Q_ENABLE_RECONNECT, Q_ENABLE_RESULT_LOG, Q_ENABLE_RPL_PARSE, Q_ENABLE_WARNINGS, Q_END_BLOCK, Q_END_TIMER, Q_ERROR, Q_EVAL, Q_EVAL_RESULT, Q_EXEC, Q_IF, Q_INC, Q_LET, q_lines, Q_PING, Q_QUERY, Q_QUERY_HORIZONTAL, Q_QUERY_VERTICAL, Q_REAL_SLEEP, Q_REAP, Q_REPLACE, Q_REPLACE_COLUMN, Q_REPLACE_REGEX, Q_REQUIRE, Q_RESULT, Q_RPL_PROBE, Q_SAVE_MASTER_POS, Q_SEND, Q_SLEEP, Q_SOURCE, Q_START_TIMER, Q_SYNC_SLAVE_WITH_MASTER, Q_SYNC_WITH_MASTER, Q_SYSTEM, Q_UNKNOWN, Q_WAIT_FOR_SLAVE_TO_STOP, Q_WHILE, QUERY_REAP, QUERY_SEND, read_query(), reconnect(), st_query::require_file, result_file, run_query(), safe_connect(), select_connection(), select_connection_name(), set_charset(), silent, sp_protocol, sp_protocol_enabled, start_lineno, st_dynamic_string::str, str_to_file(), strlen(), strmake(), strmov(), timer_now(), timer_output(), timer_start, TMPDIR, TRUE, st_query::type, unix_sock, user, var_set_errno(), view_protocol, and view_protocol_enabled.
05113 { 05114 struct st_query *q; 05115 my_bool require_file=0, q_send_flag=0, 05116 query_executed= 0; 05117 char save_file[FN_REFLEN]; 05118 MY_STAT res_info; 05119 MY_INIT(argv[0]); 05120 05121 /* Use all time until exit if no explicit 'start_timer' */ 05122 timer_start= timer_now(); 05123 05124 save_file[0]=0; 05125 TMPDIR[0]=0; 05126 05127 /* Init cons */ 05128 memset(cons, 0, sizeof(cons)); 05129 cons_end = cons + MAX_CONS; 05130 next_con = cons + 1; 05131 cur_con = cons; 05132 05133 /* Init file stack */ 05134 memset(file_stack, 0, sizeof(file_stack)); 05135 file_stack_end= file_stack + MAX_INCLUDE_DEPTH - 1; 05136 cur_file= file_stack; 05137 05138 /* Init block stack */ 05139 memset(block_stack, 0, sizeof(block_stack)); 05140 block_stack_end= block_stack + BLOCK_STACK_DEPTH - 1; 05141 cur_block= block_stack; 05142 cur_block->ok= TRUE; /* Outer block should always be executed */ 05143 cur_block->cmd= cmd_none; 05144 05145 my_init_dynamic_array(&q_lines, sizeof(struct st_query*), INIT_Q_LINES, 05146 INIT_Q_LINES); 05147 05148 memset(&master_pos, 0, sizeof(master_pos)); 05149 05150 init_dynamic_string(&ds_res, "", 0, 65536); 05151 init_dynamic_string(&ds_progress, "", 0, 2048); 05152 parse_args(argc, argv); 05153 05154 DBUG_PRINT("info",("result_file: '%s'", result_file ? result_file : "")); 05155 if (mysql_server_init(embedded_server_arg_count, 05156 embedded_server_args, 05157 (char**) embedded_server_groups)) 05158 die("Can't initialize MySQL server"); 05159 if (cur_file == file_stack && cur_file->file == 0) 05160 { 05161 cur_file->file= stdin; 05162 cur_file->file_name= my_strdup("<stdin>", MYF(MY_WME)); 05163 cur_file->lineno= 1; 05164 } 05165 init_re(); 05166 ps_protocol_enabled= ps_protocol; 05167 sp_protocol_enabled= sp_protocol; 05168 view_protocol_enabled= view_protocol; 05169 cursor_protocol_enabled= cursor_protocol; 05170 /* Cursor protcol implies ps protocol */ 05171 if (cursor_protocol_enabled) 05172 ps_protocol_enabled= 1; 05173 05174 if (!( mysql_init(&cur_con->mysql))) 05175 die("Failed in mysql_init()"); 05176 if (opt_compress) 05177 mysql_options(&cur_con->mysql,MYSQL_OPT_COMPRESS,NullS); 05178 mysql_options(&cur_con->mysql, MYSQL_OPT_LOCAL_INFILE, 0); 05179 mysql_options(&cur_con->mysql, MYSQL_SET_CHARSET_NAME, charset_name); 05180 05181 #ifdef HAVE_OPENSSL 05182 opt_ssl_verify_server_cert= TRUE; /* Always on in mysqltest */ 05183 if (opt_use_ssl) 05184 { 05185 mysql_ssl_set(&cur_con->mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca, 05186 opt_ssl_capath, opt_ssl_cipher); 05187 mysql_options(&cur_con->mysql, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, 05188 &opt_ssl_verify_server_cert); 05189 } 05190 #endif 05191 05192 if (!(cur_con->name = my_strdup("default", MYF(MY_WME)))) 05193 die("Out of memory"); 05194 05195 if (safe_connect(&cur_con->mysql, host, user, pass, db, port, unix_sock)) 05196 die("Could not open connection '%s': %d %s", cur_con->name, 05197 mysql_errno(&cur_con->mysql), mysql_error(&cur_con->mysql)); 05198 05199 init_var_hash(&cur_con->mysql); 05200 05201 #ifdef __WIN__ 05202 init_tmp_sh_file(); 05203 init_win_path_patterns(); 05204 #endif 05205 05206 /* 05207 Initialize $mysql_errno with -1, so we can 05208 - distinguish it from valid values ( >= 0 ) and 05209 - detect if there was never a command sent to the server 05210 */ 05211 var_set_errno(-1); 05212 05213 if (opt_include) 05214 { 05215 open_file(opt_include); 05216 } 05217 05218 while (!read_query(&q)) 05219 { 05220 int current_line_inc = 1, processed = 0; 05221 if (q->type == Q_UNKNOWN || q->type == Q_COMMENT_WITH_COMMAND) 05222 get_query_type(q); 05223 if (cur_block->ok) 05224 { 05225 q->last_argument= q->first_argument; 05226 processed = 1; 05227 switch (q->type) { 05228 case Q_CONNECT: 05229 do_connect(q); 05230 break; 05231 case Q_CONNECTION: select_connection(q); break; 05232 case Q_DISCONNECT: 05233 case Q_DIRTY_CLOSE: 05234 close_connection(q); break; 05235 case Q_RPL_PROBE: do_rpl_probe(q); break; 05236 case Q_ENABLE_RPL_PARSE: do_enable_rpl_parse(q); break; 05237 case Q_DISABLE_RPL_PARSE: do_disable_rpl_parse(q); break; 05238 case Q_ENABLE_QUERY_LOG: disable_query_log=0; break; 05239 case Q_DISABLE_QUERY_LOG: disable_query_log=1; break; 05240 case Q_ENABLE_ABORT_ON_ERROR: abort_on_error=1; break; 05241 case Q_DISABLE_ABORT_ON_ERROR: abort_on_error=0; break; 05242 case Q_ENABLE_RESULT_LOG: disable_result_log=0; break; 05243 case Q_DISABLE_RESULT_LOG: disable_result_log=1; break; 05244 case Q_ENABLE_WARNINGS: disable_warnings=0; break; 05245 case Q_DISABLE_WARNINGS: disable_warnings=1; break; 05246 case Q_ENABLE_PS_WARNINGS: disable_ps_warnings=0; break; 05247 case Q_DISABLE_PS_WARNINGS: disable_ps_warnings=1; break; 05248 case Q_ENABLE_INFO: disable_info=0; break; 05249 case Q_DISABLE_INFO: disable_info=1; break; 05250 case Q_ENABLE_METADATA: display_metadata=1; break; 05251 case Q_DISABLE_METADATA: display_metadata=0; break; 05252 case Q_SOURCE: do_source(q); break; 05253 case Q_SLEEP: do_sleep(q, 0); break; 05254 case Q_REAL_SLEEP: do_sleep(q, 1); break; 05255 case Q_WAIT_FOR_SLAVE_TO_STOP: do_wait_for_slave_to_stop(q); break; 05256 case Q_INC: do_modify_var(q, DO_INC); break; 05257 case Q_DEC: do_modify_var(q, DO_DEC); break; 05258 case Q_ECHO: do_echo(q); query_executed= 1; break; 05259 case Q_SYSTEM: do_system(q); break; 05260 case Q_DELIMITER: 05261 strmake(delimiter, q->first_argument, sizeof(delimiter) - 1); 05262 delimiter_length= strlen(delimiter); 05263 q->last_argument= q->first_argument+delimiter_length; 05264 break; 05265 case Q_DISPLAY_VERTICAL_RESULTS: 05266 display_result_vertically= TRUE; 05267 break; 05268 case Q_DISPLAY_HORIZONTAL_RESULTS: 05269 display_result_vertically= FALSE; 05270 break; 05271 case Q_LET: do_let(q); break; 05272 case Q_EVAL_RESULT: 05273 eval_result = 1; break; 05274 case Q_EVAL: 05275 if (q->query == q->query_buf) 05276 { 05277 q->query= q->first_argument; 05278 q->first_word_len= 0; 05279 } 05280 /* fall through */ 05281 case Q_QUERY_VERTICAL: 05282 case Q_QUERY_HORIZONTAL: 05283 { 05284 my_bool old_display_result_vertically= display_result_vertically; 05285 /* fix up query pointer if this is first iteration for this line */ 05286 if (q->query == q->query_buf) 05287 q->query += q->first_word_len + 1; 05288 display_result_vertically= (q->type==Q_QUERY_VERTICAL); 05289 if (save_file[0]) 05290 { 05291 strmov(q->record_file,save_file); 05292 q->require_file=require_file; 05293 save_file[0]=0; 05294 } 05295 run_query(&cur_con->mysql, q, QUERY_REAP|QUERY_SEND); 05296 display_result_vertically= old_display_result_vertically; 05297 q->last_argument= q->end; 05298 query_executed= 1; 05299 break; 05300 } 05301 case Q_QUERY: 05302 case Q_REAP: 05303 { 05304 /* 05305 We read the result always regardless of the mode for both full 05306 query and read-result only (reap) 05307 */ 05308 int flags = QUERY_REAP; 05309 if (q->type != Q_REAP) /* for a full query, enable the send stage */ 05310 flags |= QUERY_SEND; 05311 if (q_send_flag) 05312 { 05313 flags= QUERY_SEND; 05314 q_send_flag=0; 05315 } 05316 if (save_file[0]) 05317 { 05318 strmov(q->record_file,save_file); 05319 q->require_file=require_file; 05320 save_file[0]=0; 05321 } 05322 /* 05323 To force something being sent as a query to the mysqld one can 05324 use the prefix "query". Remove "query" from string before executing 05325 */ 05326 if (strncmp(q->query, "query ", 6) == 0) 05327 { 05328 q->query= q->first_argument; 05329 } 05330 run_query(&cur_con->mysql, q, flags); 05331 query_executed= 1; 05332 q->last_argument= q->end; 05333 break; 05334 } 05335 case Q_SEND: 05336 if (!q->query[q->first_word_len]) 05337 { 05338 /* This happens when we use 'send' on its own line */ 05339 q_send_flag=1; 05340 break; 05341 } 05342 /* fix up query pointer if this is first iteration for this line */ 05343 if (q->query == q->query_buf) 05344 q->query += q->first_word_len; 05345 /* 05346 run_query() can execute a query partially, depending on the flags. 05347 QUERY_SEND flag without QUERY_REAP tells it to just send the 05348 query and read the result some time later when reap instruction 05349 is given on this connection. 05350 */ 05351 run_query(&cur_con->mysql, q, QUERY_SEND); 05352 query_executed= 1; 05353 q->last_argument= q->end; 05354 break; 05355 case Q_RESULT: 05356 get_file_name(save_file,q); 05357 require_file=0; 05358 break; 05359 case Q_ERROR: 05360 global_expected_errors=get_errcodes(global_expected_errno,q); 05361 break; 05362 case Q_REQUIRE: 05363 get_file_name(save_file,q); 05364 require_file=1; 05365 break; 05366 case Q_REPLACE: 05367 get_replace(q); 05368 break; 05369 case Q_REPLACE_REGEX: 05370 get_replace_regex(q); 05371 break; 05372 05373 case Q_REPLACE_COLUMN: 05374 get_replace_column(q); 05375 break; 05376 case Q_SAVE_MASTER_POS: do_save_master_pos(); break; 05377 case Q_SYNC_WITH_MASTER: do_sync_with_master(q); break; 05378 case Q_SYNC_SLAVE_WITH_MASTER: 05379 { 05380 do_save_master_pos(); 05381 if (*q->first_argument) 05382 select_connection(q); 05383 else 05384 select_connection_name("slave"); 05385 do_sync_with_master2(0); 05386 break; 05387 } 05388 case Q_COMMENT: /* Ignore row */ 05389 case Q_COMMENT_WITH_COMMAND: 05390 q->last_argument= q->end; 05391 break; 05392 case Q_PING: 05393 (void) mysql_ping(&cur_con->mysql); 05394 break; 05395 case Q_EXEC: 05396 do_exec(q); 05397 query_executed= 1; 05398 break; 05399 case Q_START_TIMER: 05400 /* Overwrite possible earlier start of timer */ 05401 timer_start= timer_now(); 05402 break; 05403 case Q_END_TIMER: 05404 /* End timer before ending mysqltest */ 05405 timer_output(); 05406 got_end_timer= TRUE; 05407 break; 05408 case Q_CHARACTER_SET: 05409 set_charset(q); 05410 break; 05411 case Q_DISABLE_PS_PROTOCOL: 05412 ps_protocol_enabled= 0; 05413 break; 05414 case Q_ENABLE_PS_PROTOCOL: 05415 ps_protocol_enabled= ps_protocol; 05416 break; 05417 case Q_DISABLE_RECONNECT: 05418 { 05419 my_bool reconnect= 0; 05420 mysql_options(&cur_con->mysql, MYSQL_OPT_RECONNECT, (char *)&reconnect); 05421 break; 05422 } 05423 case Q_ENABLE_RECONNECT: 05424 { 05425 my_bool reconnect= 1; 05426 mysql_options(&cur_con->mysql, MYSQL_OPT_RECONNECT, (char *)&reconnect); 05427 break; 05428 } 05429 case Q_DISABLE_PARSING: 05430 parsing_disabled++; 05431 break; 05432 case Q_ENABLE_PARSING: 05433 /* 05434 Ensure we don't get parsing_disabled < 0 as this would accidentally 05435 disable code we don't want to have disabled 05436 */ 05437 if (parsing_disabled > 0) 05438 parsing_disabled--; 05439 break; 05440 05441 case Q_DIE: 05442 die("%s", q->first_argument); 05443 break; 05444 05445 default: 05446 processed= 0; 05447 break; 05448 } 05449 } 05450 05451 if (!processed) 05452 { 05453 current_line_inc= 0; 05454 switch (q->type) { 05455 case Q_WHILE: do_block(cmd_while, q); break; 05456 case Q_IF: do_block(cmd_if, q); break; 05457 case Q_END_BLOCK: do_done(q); break; 05458 default: current_line_inc = 1; break; 05459 } 05460 } 05461 else 05462 check_eol_junk(q->last_argument); 05463 05464 if (q->type != Q_ERROR) 05465 { 05466 /* 05467 As soon as any non "error" command has been executed, 05468 the array with expected errors should be cleared 05469 */ 05470 global_expected_errors= 0; 05471 bzero((gptr) global_expected_errno, sizeof(global_expected_errno)); 05472 } 05473 05474 parser.current_line += current_line_inc; 05475 if ( opt_mark_progress ) 05476 mark_progress(q, parser.current_line); 05477 } 05478 05479 start_lineno= 0; 05480 05481 /* 05482 The whole test has been executed _sucessfully_. 05483 Time to compare result or save it to record file. 05484 The entire output from test is now kept in ds_res. 05485 */ 05486 if (ds_res.length) 05487 { 05488 if (result_file) 05489 { 05490 if (record) 05491 { 05492 /* Dump the output from test to result file */ 05493 str_to_file(result_file, ds_res.str, ds_res.length); 05494 } 05495 else 05496 { 05497 /* Check that the output from test is equal to result file 05498 - detect missing result file 05499 - detect zero size result file 05500 */ 05501 check_result(&ds_res, result_file, 0); 05502 } 05503 } 05504 else 05505 { 05506 /* No result_file specified to compare with, print to stdout */ 05507 printf("%s", ds_res.str); 05508 } 05509 } 05510 else 05511 { 05512 die("The test didn't produce any output"); 05513 } 05514 05515 if (!query_executed && result_file && my_stat(result_file, &res_info, 0)) 05516 { 05517 /* 05518 my_stat() successful on result file. Check if we have not run a 05519 single query, but we do have a result file that contains data. 05520 Note that we don't care, if my_stat() fails. For example, for a 05521 non-existing or non-readable file, we assume it's fine to have 05522 no query output from the test file, e.g. regarded as no error. 05523 */ 05524 die("No queries executed but result file found!"); 05525 } 05526 05527 if ( opt_mark_progress ) 05528 dump_progress(result_file); 05529 dynstr_free(&ds_progress); 05530 05531 dynstr_free(&ds_res); 05532 05533 if (!got_end_timer) 05534 timer_output(); /* No end_timer cmd, end it */ 05535 free_used_memory(); 05536 my_end(MY_CHECK_ERROR); 05537 05538 /* Yes, if we got this far the test has suceeded! Sakila smiles */ 05539 if (!silent) 05540 printf("ok\n"); 05541 exit(0); 05542 return 0; /* Keep compiler happy */ 05543 }
Here is the call graph for this function:

Definition at line 6108 of file mysqltest.c.
References st_rep_sets::bit_buffer, st_rep_set::bits, bzero, st_rep_sets::count, st_rep_sets::extra, st_rep_set::found_len, st_rep_set::found_offset, st_rep_sets::invisible, LAST_CHAR_CODE, my_realloc(), MY_WME, MYF, st_rep_set::next, st_rep_sets::set, st_rep_sets::set_buffer, SET_MALLOC_HUNC, st_rep_set::size_of_bits, st_rep_sets::size_of_bits, and st_rep_set::table_offset.
Referenced by init_replace(), and make_new_set().
06109 { 06110 uint i,count,*bit_buffer; 06111 REP_SET *set; 06112 if (sets->extra) 06113 { 06114 sets->extra--; 06115 set=sets->set+ sets->count++; 06116 bzero((char*) set->bits,sizeof(uint)*sets->size_of_bits); 06117 bzero((char*) &set->next[0],sizeof(set->next[0])*LAST_CHAR_CODE); 06118 set->found_offset=0; 06119 set->found_len=0; 06120 set->table_offset= (uint) ~0; 06121 set->size_of_bits=sets->size_of_bits; 06122 return set; 06123 } 06124 count=sets->count+sets->invisible+SET_MALLOC_HUNC; 06125 if (!(set=(REP_SET*) my_realloc((gptr) sets->set_buffer, 06126 sizeof(REP_SET)*count, 06127 MYF(MY_WME)))) 06128 return 0; 06129 sets->set_buffer=set; 06130 sets->set=set+sets->invisible; 06131 if (!(bit_buffer=(uint*) my_realloc((gptr) sets->bit_buffer, 06132 (sizeof(uint)*sets->size_of_bits)*count, 06133 MYF(MY_WME)))) 06134 return 0; 06135 sets->bit_buffer=bit_buffer; 06136 for (i=0 ; i < count ; i++) 06137 { 06138 sets->set_buffer[i].bits=bit_buffer; 06139 bit_buffer+=sets->size_of_bits; 06140 } 06141 sets->extra=SET_MALLOC_HUNC; 06142 return make_new_set(sets); 06143 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void make_sets_invisible | ( | REP_SETS * | sets | ) | [static] |
Definition at line 6101 of file mysqltest.c.
References st_rep_sets::count, st_rep_sets::invisible, and st_rep_sets::set.
Referenced by init_replace().
06102 { 06103 sets->invisible=sets->count; 06104 sets->set+=sets->count; 06105 sets->count=0; 06106 }
Here is the caller graph for this function:

| static void mark_progress | ( | struct st_query *q | __attribute__((unused)), | |
| int | line | |||
| ) | [static] |
Definition at line 5080 of file mysqltest.c.
References buf, cur_file, ds_progress, dynstr_append(), dynstr_append_mem(), test_file::file_name, int10_to_str(), test_file::lineno, longlong2str, progress_start, yaSSL::timer(), and timer_now().
Referenced by main().
05081 { 05082 char buf[32], *end; 05083 ulonglong timer= timer_now(); 05084 if (!progress_start) 05085 progress_start= timer; 05086 timer-= progress_start; 05087 05088 /* Milliseconds since start */ 05089 end= longlong2str(timer, buf, 10); 05090 dynstr_append_mem(&ds_progress, buf, (int)(end-buf)); 05091 dynstr_append_mem(&ds_progress, "\t", 1); 05092 05093 /* Parser line number */ 05094 end= int10_to_str(line, buf, 10); 05095 dynstr_append_mem(&ds_progress, buf, (int)(end-buf)); 05096 dynstr_append_mem(&ds_progress, "\t", 1); 05097 05098 /* Filename */ 05099 dynstr_append(&ds_progress, cur_file->file_name); 05100 dynstr_append_mem(&ds_progress, ":", 1); 05101 05102 /* Line in file */ 05103 end= int10_to_str(cur_file->lineno, buf, 10); 05104 dynstr_append_mem(&ds_progress, buf, (int)(end-buf)); 05105 05106 05107 dynstr_append_mem(&ds_progress, "\n", 1); 05108 05109 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static int match_re | ( | my_regex_t * | , | |
| char * | ||||
| ) | [static] |
Definition at line 4911 of file mysqltest.c.
References die(), err, my_regerror(), my_regexec(), NULL, re_eprint(), and REG_NOMATCH.
Referenced by run_query().
04912 { 04913 int err= my_regexec(re, str, (size_t)0, NULL, 0); 04914 04915 if (err == 0) 04916 return 1; 04917 else if (err == REG_NOMATCH) 04918 return 0; 04919 04920 { 04921 char erbuf[100]; 04922 int len= my_regerror(err, re, erbuf, sizeof(erbuf)); 04923 die("error %s, %d/%d `%s'\n", 04924 re_eprint(err), len, (int)sizeof(erbuf), erbuf); 04925 } 04926 return 0; 04927 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static int multi_reg_replace | ( | struct st_replace_regex * | r, | |
| char * | val | |||
| ) | [static] |
Definition at line 2169 of file mysqltest.c.
References st_replace_regex::buf, st_dynamic_array::elements, st_replace_regex::even_buf, st_replace_regex::even_buf_len, get_dynamic(), st_replace_regex::odd_buf, st_replace_regex::odd_buf_len, reg_replace(), st_replace_regex::regex_arr, and swap_variables.
Referenced by replace_dynstr_append_mem().
02170 { 02171 uint i; 02172 char* in_buf, *out_buf; 02173 int* buf_len_p; 02174 02175 in_buf= val; 02176 out_buf= r->even_buf; 02177 buf_len_p= &r->even_buf_len; 02178 r->buf= 0; 02179 02180 /* For each substitution, do the replace */ 02181 for (i= 0; i < r->regex_arr.elements; i++) 02182 { 02183 struct st_regex re; 02184 char* save_out_buf= out_buf; 02185 02186 get_dynamic(&r->regex_arr,(gptr)&re,i); 02187 02188 if (!reg_replace(&out_buf, buf_len_p, re.pattern, re.replace, 02189 in_buf, re.icase)) 02190 { 02191 /* if the buffer has been reallocated, make adjustements */ 02192 if (save_out_buf != out_buf) 02193 { 02194 if (save_out_buf == r->even_buf) 02195 r->even_buf= out_buf; 02196 else 02197 r->odd_buf= out_buf; 02198 } 02199 02200 r->buf= out_buf; 02201 if (in_buf == val) 02202 in_buf= r->odd_buf; 02203 02204 swap_variables(char*,in_buf,out_buf); 02205 02206 buf_len_p= (out_buf == r->even_buf) ? &r->even_buf_len : 02207 &r->odd_buf_len; 02208 } 02209 } 02210 02211 return (r->buf == 0); 02212 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int my_getc | ( | FILE * | file | ) |
Definition at line 2886 of file mysqltest.c.
References line_buffer, and line_buffer_pos.
Referenced by end_of_query(), and read_line().
02887 { 02888 if (line_buffer_pos == line_buffer) 02889 return fgetc(file); 02890 return *--line_buffer_pos; 02891 }
Here is the caller graph for this function:

| FILE* my_popen | ( | DYNAMIC_STRING * | ds_cmd, | |
| const char * | mode | |||
| ) |
Definition at line 1100 of file mysqltest.c.
References st_dynamic_string::length, popen, st_dynamic_string::str, and str_to_file().
Referenced by do_exec().
01101 { 01102 #ifdef __WIN__ 01103 /* Dump the command into a sh script file and execute with popen */ 01104 str_to_file(tmp_sh_name, ds_cmd->str, ds_cmd->length); 01105 return popen(tmp_sh_cmd, mode); 01106 #else 01107 return popen(ds_cmd->str, mode); 01108 #endif 01109 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int my_system | ( | DYNAMIC_STRING * | ds_cmd | ) |
Definition at line 1430 of file mysqltest.c.
References st_dynamic_string::length, st_dynamic_string::str, and str_to_file().
Referenced by do_system().
01431 { 01432 #ifdef __WIN__ 01433 /* Dump the command into a sh script file and execute with system */ 01434 str_to_file(tmp_sh_name, ds_cmd->str, ds_cmd->length); 01435 return system(tmp_sh_cmd); 01436 #else 01437 return system(ds_cmd->str); 01438 #endif 01439 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void my_ungetc | ( | int | c | ) |
Definition at line 2893 of file mysqltest.c.
References line_buffer_pos.
Referenced by end_of_query(), and read_line().
02894 { 02895 *line_buffer_pos++= (char) c; 02896 }
Here is the caller graph for this function:

Definition at line 496 of file mysqltest.c.
Referenced by do_disable_rpl_parse(), do_save_master_pos(), and do_sync_with_master2().
Here is the caller graph for this function:

Definition at line 495 of file mysqltest.c.
Referenced by do_enable_rpl_parse(), do_save_master_pos(), and do_sync_with_master2().
Here is the caller graph for this function:

Definition at line 497 of file mysqltest.c.
Referenced by do_save_master_pos(), and do_sync_with_master2().
Here is the caller graph for this function:

| int open_file | ( | const char * | name | ) |
Definition at line 963 of file mysqltest.c.
References cur_file, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, die(), test_file::file, FILE_BINARY, test_file::file_name, file_stack_end, fn_format(), FN_REFLEN, test_file::lineno, MY_FAE, my_fopen(), my_strdup(), MY_UNPACK_FILENAME, MYF, NullS, opt_basedir, strxmov(), and test_if_hard_path().
Referenced by do_source(), and main().
00964 { 00965 char buff[FN_REFLEN]; 00966 DBUG_ENTER("open_file"); 00967 DBUG_PRINT("enter", ("name: %s", name)); 00968 if (!test_if_hard_path(name)) 00969 { 00970 strxmov(buff, opt_basedir, name, NullS); 00971 name=buff; 00972 } 00973 fn_format(buff, name, "", "", MY_UNPACK_FILENAME); 00974 00975 if (cur_file == file_stack_end) 00976 die("Source directives are nesting too deep"); 00977 cur_file++; 00978 if (!(cur_file->file = my_fopen(buff, O_RDONLY | FILE_BINARY, MYF(0)))) 00979 { 00980 cur_file--; 00981 die("Could not open file %s", buff); 00982 } 00983 cur_file->file_name= my_strdup(buff, MYF(MY_FAE)); 00984 cur_file->lineno=1; 00985 DBUG_RETURN(0); 00986 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int parse_args | ( | int | argc, | |
| char ** | argv | |||
| ) |
Definition at line 3414 of file mysqltest.c.
References db, default_argv, exit, get_one_option(), get_tty_password(), handle_options(), load_default_groups, load_defaults(), my_long_options, NullS, pass, tty_password, and usage().
03415 { 03416 load_defaults("my",load_default_groups,&argc,&argv); 03417 default_argv= argv; 03418 03419 if ((handle_options(&argc, &argv, my_long_options, get_one_option))) 03420 exit(1); 03421 03422 if (argc > 1) 03423 { 03424 usage(); 03425 exit(1); 03426 } 03427 if (argc == 1) 03428 db= *argv; 03429 if (tty_password) 03430 pass=get_tty_password(NullS); 03431 03432 return 0; 03433 }
Here is the call graph for this function:

| static void print_version | ( | void | ) | [static] |
Definition at line 3302 of file mysqltest.c.
References MACHINE_TYPE, MTEST_VERSION, my_progname, MYSQL_SERVER_VERSION, and SYSTEM_TYPE.
03303 { 03304 printf("%s Ver %s Distrib %s, for %s (%s)\n",my_progname,MTEST_VERSION, 03305 MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); 03306 }
| static char* re_eprint | ( | int | err | ) | [static] |
Definition at line 4850 of file mysqltest.c.
References assert, my_regerror(), NULL, and REG_ITOA.
Referenced by init_re_comp(), and match_re().
04851 { 04852 static char epbuf[100]; 04853 size_t len= my_regerror(REG_ITOA|err, (my_regex_t *)NULL, 04854 epbuf, sizeof(epbuf)); 04855 assert(len <= sizeof(epbuf)); 04856 return(epbuf); 04857 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int read_line | ( | char * | buf, | |
| int | size | |||
| ) |
Definition at line 2947 of file mysqltest.c.
References block_stack, charset_info, cur_block, cur_file, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, die(), end_of_query(), test_file::file, test_file::file_name, file_stack, test_file::lineno, LINT_INIT, MY_ALLOW_ZERO_PTR, my_fclose(), my_free, my_getc(), my_ismbchar, my_isspace, my_mbcharlen, my_ungetc(), MYF, p, parsing_disabled, and start_lineno.
Referenced by read_query().
02948 { 02949 int c; 02950 char quote; 02951 char *p= buf, *buf_end= buf + size - 1; 02952 int no_save= 0; 02953 enum {R_NORMAL, R_Q, R_Q_IN_Q, R_SLASH_IN_Q, 02954 R_COMMENT, R_LINE_START} state= R_LINE_START; 02955 DBUG_ENTER("read_line"); 02956 LINT_INIT(quote); 02957 02958 start_lineno= cur_file->lineno; 02959 for (; p < buf_end ;) 02960 { 02961 no_save= 0; 02962 c= my_getc(cur_file->file); 02963 if (feof(cur_file->file)) 02964 { 02965 found_eof: 02966 if (cur_file->file != stdin) 02967 { 02968 my_fclose(cur_file->file, MYF(0)); 02969 cur_file->file= 0; 02970 } 02971 my_free((gptr)cur_file->file_name, MYF(MY_ALLOW_ZERO_PTR)); 02972 cur_file->file_name= 0; 02973 if (cur_file == file_stack) 02974 { 02975 /* We're back at the first file, check if 02976 all { have matching } 02977 */ 02978 if (cur_block != block_stack) 02979 die("Missing end of block"); 02980 02981 DBUG_PRINT("info", ("end of file")); 02982 DBUG_RETURN(1); 02983 } 02984 cur_file--; 02985 start_lineno= cur_file->lineno; 02986 continue; 02987 } 02988 02989 if (c == '\n') 02990 { 02991 /* Line counting is independent of state */ 02992 cur_file->lineno++; 02993 02994 /* Convert cr/lf to lf */ 02995 if (p != buf && *(p-1) == '\r') 02996 *(p-1)= 0; 02997 } 02998 02999 switch(state) { 03000 case R_NORMAL: 03001 /* Only accept '{' in the beginning of a line */ 03002 if (end_of_query(c)) 03003 { 03004 *p= 0; 03005 DBUG_RETURN(0); 03006 } 03007 else if (c == '\'' || c == '"' || c == '`') 03008 { 03009 quote= c; 03010 state= R_Q; 03011 } 03012 else if (c == '\n') 03013 { 03014 state = R_LINE_START; 03015 } 03016 break; 03017 case R_COMMENT: 03018 if (c == '\n') 03019 { 03020 *p= 0; 03021 DBUG_RETURN(0); 03022 } 03023 break; 03024 case R_LINE_START: 03025 /* Only accept start of comment if this is the first line in query */ 03026 if ((cur_file->lineno == start_lineno) && 03027 (c == '#' || c == '-' || parsing_disabled)) 03028 { 03029 state = R_COMMENT; 03030 } 03031 else if (my_isspace(charset_info, c)) <

