1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Added more descriptive error message of why statement was automaticly dropped

Print information if net_clear() skipped bytes (As this otherwise hides critical timeing bugs)
Added DBUG_ASSERT if we get packets out of order
mysql_change_user() could on error send multiple packets, which caused mysql_client_test to randomly fail
This commit is contained in:
monty@mysql.com/narttu.mysql.fi
2007-04-13 01:56:22 +03:00
parent 4a065f5f60
commit 6e8b72a6bb
9 changed files with 112 additions and 73 deletions

View File

@ -83,6 +83,7 @@ struct my_tests_st
};
#define myheader(str) \
DBUG_PRINT("test", ("name: %s", str)); \
if (opt_silent < 2) \
{ \
fprintf(stdout, "\n\n#####################################\n"); \
@ -90,7 +91,9 @@ if (opt_silent < 2) \
opt_count, str); \
fprintf(stdout, " \n#####################################\n"); \
}
#define myheader_r(str) \
DBUG_PRINT("test", ("name: %s", str)); \
if (!opt_silent) \
{ \
fprintf(stdout, "\n\n#####################################\n"); \
@ -298,7 +301,7 @@ static void client_connect(ulong flag)
mysql->reconnect= 1;
if (!opt_silent)
fprintf(stdout, " OK");
fprintf(stdout, "OK");
/* set AUTOCOMMIT to ON*/
mysql_autocommit(mysql, TRUE);
@ -321,7 +324,7 @@ static void client_connect(ulong flag)
have_innodb= check_have_innodb(mysql);
if (!opt_silent)
fprintf(stdout, " OK");
fprintf(stdout, "OK");
}
@ -341,12 +344,13 @@ static void client_disconnect()
mysql_query(mysql, query);
if (!opt_silent)
fprintf(stdout, " OK");
fprintf(stdout, "OK");
if (!opt_silent)
fprintf(stdout, "\n closing the connection ...");
mysql_close(mysql);
fprintf(stdout, " OK\n");
if (!opt_silent)
fprintf(stdout, "OK\n");
}
}
@ -2498,7 +2502,7 @@ static void test_ps_query_cache()
exit(1);
}
if (!opt_silent)
fprintf(stdout, " OK");
fprintf(stdout, "OK");
mysql= lmysql;
}
@ -4940,7 +4944,7 @@ static void test_stmt_close()
}
lmysql->reconnect= 1;
if (!opt_silent)
fprintf(stdout, " OK");
fprintf(stdout, "OK");
/* set AUTOCOMMIT to ON*/
@ -7471,7 +7475,7 @@ static void test_prepare_grant()
}
lmysql->reconnect= 1;
if (!opt_silent)
fprintf(stdout, " OK");
fprintf(stdout, "OK");
mysql= lmysql;
rc= mysql_query(mysql, "INSERT INTO test_grant VALUES(NULL)");
@ -7932,7 +7936,7 @@ static void test_drop_temp()
}
lmysql->reconnect= 1;
if (!opt_silent)
fprintf(stdout, " OK");
fprintf(stdout, "OK");
mysql= lmysql;
rc= mysql_query(mysql, "INSERT INTO t1 VALUES(10, 'C')");
@ -12018,16 +12022,24 @@ static void test_bug5315()
stmt= mysql_stmt_init(mysql);
rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
DIE_UNLESS(rc == 0);
if (!opt_silent)
printf("Excuting mysql_change_user\n");
mysql_change_user(mysql, opt_user, opt_password, current_db);
if (!opt_silent)
printf("Excuting mysql_stmt_execute\n");
rc= mysql_stmt_execute(stmt);
DIE_UNLESS(rc != 0);
if (rc)
{
if (!opt_silent)
printf("Got error (as expected):\n%s", mysql_stmt_error(stmt));
printf("Got error (as expected): '%s'\n", mysql_stmt_error(stmt));
}
/* check that connection is OK */
if (!opt_silent)
printf("Excuting mysql_stmt_close\n");
mysql_stmt_close(stmt);
if (!opt_silent)
printf("Excuting mysql_stmt_init\n");
stmt= mysql_stmt_init(mysql);
rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
DIE_UNLESS(rc == 0);
@ -12716,6 +12728,7 @@ static void test_rewind(void)
/* retreive all result sets till we are at the end */
while(!mysql_stmt_fetch(stmt))
if (!opt_silent)
printf("fetched result:%ld\n", Data);
DIE_UNLESS(rc != MYSQL_NO_DATA);
@ -12726,6 +12739,7 @@ static void test_rewind(void)
/* now we should be able to fetch the results again */
/* but mysql_stmt_fetch returns MYSQL_NO_DATA */
while(!(rc= mysql_stmt_fetch(stmt)))
if (!opt_silent)
printf("fetched result after seek:%ld\n", Data);
DIE_UNLESS(rc == MYSQL_NO_DATA);
@ -13276,7 +13290,7 @@ static void test_bug8378()
exit(1);
}
if (!opt_silent)
fprintf(stdout, " OK");
fprintf(stdout, "OK");
len= mysql_real_escape_string(mysql, out, TEST_BUG8378_IN, 4);
@ -13445,7 +13459,8 @@ static void test_bug9520()
DIE_UNLESS(rc == MYSQL_NO_DATA);
printf("Fetched %d rows\n", row_count);
if (!opt_silent)
printf("Fetched %d rows\n", row_count);
DBUG_ASSERT(row_count == 3);
mysql_stmt_close(stmt);
@ -15345,8 +15360,28 @@ static void test_bug17667()
myheader("test_bug17667");
master_log_filename = (char *) malloc(strlen(opt_vardir) + strlen("/log/master.log") + 1);
strxmov(master_log_filename, opt_vardir, "/log/master.log", NullS);
if (!opt_silent)
printf("Opening '%s'\n", master_log_filename);
log_file= my_fopen(master_log_filename, (int) (O_RDONLY | O_BINARY), MYF(0));
free(master_log_filename);
if (log_file == NULL)
{
if (!opt_silent)
{
printf("Could not find the log file, VARDIR/log/master.log, so "
"test_bug17667 is not run.\n"
"Run test from the mysql-test/mysql-test-run* program to set up "
"correct environment for this test.\n\n");
}
return;
}
for (statement_cursor= statements; statement_cursor->buffer != NULL;
statement_cursor++) {
statement_cursor++)
{
if (statement_cursor->qt == QT_NORMAL)
{
/* Run statement as normal query */
@ -15357,10 +15392,10 @@ static void test_bug17667()
else if (statement_cursor->qt == QT_PREPARED)
{
/*
Run as prepared statement
Run as prepared statement
NOTE! All these queries should be in the log twice,
one time for prepare and one time for execute
NOTE! All these queries should be in the log twice,
one time for prepare and one time for execute
*/
stmt= mysql_stmt_init(mysql);
@ -15383,66 +15418,49 @@ static void test_bug17667()
rc= mysql_query(mysql, "flush logs");
myquery(rc);
master_log_filename = (char *) malloc(strlen(opt_vardir) + strlen("/log/master.log") + 1);
strcpy(master_log_filename, opt_vardir);
strcat(master_log_filename, "/log/master.log");
printf("Opening '%s'\n", master_log_filename);
log_file= my_fopen(master_log_filename, (int) (O_RDONLY | O_BINARY), MYF(MY_WME));
free(master_log_filename);
for (statement_cursor= statements; statement_cursor->buffer != NULL;
statement_cursor++)
{
int expected_hits= 1, hits= 0;
char line_buffer[MAX_TEST_QUERY_LENGTH*2];
/* more than enough room for the query and some marginalia. */
if (log_file != NULL) {
/* Prepared statments always occurs twice in log */
if (statement_cursor->qt == QT_PREPARED)
expected_hits++;
for (statement_cursor= statements; statement_cursor->buffer != NULL;
statement_cursor++) {
int expected_hits= 1, hits= 0;
char line_buffer[MAX_TEST_QUERY_LENGTH*2];
/* more than enough room for the query and some marginalia. */
/* Prepared statments always occurs twice in log */
if (statement_cursor->qt == QT_PREPARED)
expected_hits++;
/* Loop until we found expected number of log entries */
/* Loop until we found expected number of log entries */
do {
/* Loop until statement is found in log */
do {
/* Loop until statement is found in log */
do {
memset(line_buffer, '/', MAX_TEST_QUERY_LENGTH*2);
memset(line_buffer, '/', MAX_TEST_QUERY_LENGTH*2);
if(fgets(line_buffer, MAX_TEST_QUERY_LENGTH*2, log_file) == NULL)
{
/* If fgets returned NULL, it indicates either error or EOF */
if (feof(log_file))
DIE("Found EOF before all statements where found");
if(fgets(line_buffer, MAX_TEST_QUERY_LENGTH*2, log_file) == NULL)
{
/* If fgets returned NULL, it indicates either error or EOF */
if (feof(log_file))
DIE("Found EOF before all statements where found");
fprintf(stderr, "Got error %d while reading from file\n",
ferror(log_file));
DIE("Read error");
}
fprintf(stderr, "Got error %d while reading from file\n",
ferror(log_file));
DIE("Read error");
}
} while (my_memmem(line_buffer, MAX_TEST_QUERY_LENGTH*2,
statement_cursor->buffer,
statement_cursor->length) == NULL);
hits++;
} while (hits < expected_hits);
} while (my_memmem(line_buffer, MAX_TEST_QUERY_LENGTH*2,
statement_cursor->buffer,
statement_cursor->length) == NULL);
hits++;
} while (hits < expected_hits);
if (!opt_silent)
printf("Found statement starting with \"%s\"\n",
statement_cursor->buffer);
}
}
if (!opt_silent)
printf("success. All queries found intact in the log.\n");
}
else
{
fprintf(stderr, "Could not find the log file, VARDIR/log/master.log, so "
"test_bug17667 is \ninconclusive. Run test from the "
"mysql-test/mysql-test-run* program \nto set up the correct "
"environment for this test.\n\n");
}
if (log_file != NULL)
my_fclose(log_file, MYF(0));
my_fclose(log_file, MYF(0));
}
@ -16008,12 +16026,14 @@ static void test_bug21635()
for (i= 0; i < field_count; ++i)
{
field= mysql_fetch_field_direct(result, i);
printf("%s -> %s ... ", expr[i * 2], field->name);
if (!opt_silent)
printf("%s -> %s ... ", expr[i * 2], field->name);
fflush(stdout);
DIE_UNLESS(field->db[0] == 0 && field->org_table[0] == 0 &&
field->table[0] == 0 && field->org_name[0] == 0);
DIE_UNLESS(strcmp(field->name, expr[i * 2 + 1]) == 0);
puts("OK");
if (!opt_silent)
puts("OK");
}
mysql_free_result(result);