Commit ae4a9ea8 authored by unknown's avatar unknown

Fix for subsequent error calls in multi-query

sql/sql_parse.cc:
  Fix for subsequent errors calls in multi-query
tests/client_test.c:
  Misc cleanups
parent fccbabe0
......@@ -1225,6 +1225,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
}
thd->query_length= length;
thd->query= packet;
thd->net.last_error[0]= '\0';
VOID(pthread_mutex_lock(&LOCK_thread_count));
thd->query_id= query_id++;
VOID(pthread_mutex_unlock(&LOCK_thread_count));
......
......@@ -80,10 +80,10 @@ static void print_error(const char *msg)
if (mysql)
{
if (mysql->server_version)
fprintf(stderr,"\n [MySQL-%s]",mysql->server_version);
fprintf(stdout,"\n [MySQL-%s]",mysql->server_version);
else
fprintf(stderr,"\n [MySQL]");
fprintf(stderr,"[%d] %s\n",mysql_errno(mysql),mysql_error(mysql));
fprintf(stdout,"\n [MySQL]");
fprintf(stdout,"[%d] %s\n",mysql_errno(mysql),mysql_error(mysql));
}
else if (msg) fprintf(stderr, " [MySQL] %s\n", msg);
}
......@@ -93,11 +93,11 @@ static void print_st_error(MYSQL_STMT *stmt, const char *msg)
if (stmt)
{
if (stmt->mysql && stmt->mysql->server_version)
fprintf(stderr,"\n [MySQL-%s]",stmt->mysql->server_version);
fprintf(stdout,"\n [MySQL-%s]",stmt->mysql->server_version);
else
fprintf(stderr,"\n [MySQL]");
fprintf(stdout,"\n [MySQL]");
fprintf(stderr,"[%d] %s\n",mysql_stmt_errno(stmt),
fprintf(stdout,"[%d] %s\n",mysql_stmt_errno(stmt),
mysql_stmt_error(stmt));
}
else if (msg) fprintf(stderr, " [MySQL] %s\n", msg);
......@@ -4425,6 +4425,9 @@ static void test_multi_query()
int rc;
const char *query= "DROP TABLE IF EXISTS test_multi_tab;\
CREATE TABLE test_multi_tab(id int,name char(20));\
INSERT INTO test_multi_tab(xxxx) VALUES(10);\
UPDATE test_multi_tab SET id=10 WHERE unkown_col=10;\
CREATE TABLE test_multi_tab(id int,name char(20));\
INSERT INTO test_multi_tab(id) VALUES(10),(20);\
INSERT INTO test_multi_tab VALUES(20,'insert;comma');\
......@@ -4434,8 +4437,11 @@ static void test_multi_query()
DELETE FROM test_multi_tab WHERE name='new;name';\
SELECT * FROM test_multi_tab;\
DELETE FROM test_multi_tab WHERE id=10;\
SELECT * FROM test_multi_tab";
uint count, rows[10]={0,2,1,3,0,2,2,1,1,0};
SELECT * FROM test_multi_tab;\
DROP TABLE test_multi_tab;\
DROP TABLE test_multi_tab;\
DROP TABLE IF EXISTS test_multi_tab";
uint count, rows[16]={0,1054,1054,1050,2,1,3,1054,2,2,1,1,0,0,1051,0}, exp_value;
myheader("test_multi_query");
......@@ -4463,19 +4469,25 @@ static void test_multi_query()
rc = mysql_query(mysql, query);
myquery(rc);
count= 0;
while (mysql_more_results(mysql) && count < sizeof(rows)/sizeof(uint))
count= exp_value= 0;
while (mysql_more_results(mysql) && count < array_elements(rows))
{
fprintf(stdout,"\n query %d", count);
fprintf(stdout,"\n Query %d: ", count);
if ((rc= mysql_next_result(mysql)))
fprintf(stdout, "\n\t failed(%s)", mysql_error(mysql));
{
exp_value= mysql_errno(mysql);
fprintf(stdout, "ERROR %d: %s", exp_value, mysql_error(mysql));
}
else
fprintf(stdout,"\n\t affected rows: %lld", mysql_affected_rows(mysql));
{
if ((result= mysql_store_result(mysql)))
my_process_result_set(result);
if (!rc)
myassert(rows[count] == (uint)mysql_affected_rows(mysql));
count++;
else
fprintf(stdout,"OK, %d row(s) affected, %d warning(s)", exp_value,
mysql_warning_count(mysql));
exp_value= (uint) mysql_affected_rows(mysql);
}
myassert(rows[count++] == exp_value);
}
mysql= org_mysql;
}
......@@ -4932,7 +4944,7 @@ static void test_bind_date_conv(uint row_count)
for (i= 0; i < array_elements(bind); i++)
{
fprintf(stdout, "\n");
fprintf(stdout,"time[%d]: %02d-%02d-%02d %02d:%02d:%02d.%02lu",
fprintf(stdout," time[%d]: %02d-%02d-%02d %02d:%02d:%02d.%02lu",
i, tm[i].year, tm[i].month, tm[i].day,
tm[i].hour, tm[i].minute, tm[i].second,
tm[i].second_part);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment