Skip to content
Permalink
Browse files

ODBC-226 SQLMoreResults would not return error

if batch was sent via text protocol, and a statement in the batch resulted in an error.
Since MariaDB stops processing the batchin such case, specs say
SQLMoreResults should return SQL_ERROR(otherwise should be
SQL_SUCCESS_WITH INFO)
Added OS X build on travis to "allow failures" section, while it's not
clear how to fix it atm, and "manual" build works
  • Loading branch information...
lawrinn committed Aug 7, 2019
1 parent 0670781 commit 07bc4115f2f7321529241ce130504913bdc6378a
Showing with 58 additions and 5 deletions.
  1. +4 −2 .travis.yml
  2. +36 −3 ma_result.c
  3. +18 −0 test/error.c
@@ -27,14 +27,16 @@ matrix:
allow_failures:
- os: linux
env: DB=mariadb:10.2 PACKET=8M MAXSCALE_VERSION=2.1.8
- os: linux
env: DB=build
- os: linux
env: DB=mysql:5.5
- os: linux
env: DB=mysql:5.6
- os: linux
env: DB=mysql:5.7
- os: linux
env: DB=build
- os: osx
env: DB=mariadb:10.4
include:
- os: linux
env: DB=build
@@ -50,6 +50,27 @@ SQLRETURN MADB_StmtDataSeek(MADB_Stmt *Stmt, my_ulonglong FetchOffset)
}
/* }}} */

/* {{{ */
void QuickDropAllPendingResults(MYSQL* Mariadb)
{
int Next= 0;
do {
if (Next == 0)
{
if (mysql_field_count(Mariadb) > 0)
{
MYSQL_RES *Res= mysql_store_result(Mariadb);

if (Res)
{
mysql_free_result(Res);
}
}
}
} while ((Next= mysql_next_result(Mariadb)) != -1);
}
/* }}} */

/* {{{ MADB_StmtMoreResults */
SQLRETURN MADB_StmtMoreResults(MADB_Stmt *Stmt)
{
@@ -85,11 +106,23 @@ SQLRETURN MADB_StmtMoreResults(MADB_Stmt *Stmt)
return SQL_NO_DATA;
else
{
int Next;

LOCK_MARIADB(Stmt->Connection);
mysql_next_result(Stmt->Connection->mariadb);
if (mysql_field_count(Stmt->Connection->mariadb) != 0)
Next= mysql_next_result(Stmt->Connection->mariadb);

if (Next > 0)
{
ret= MADB_SetError(&Stmt->Error, MADB_ERR_HY000, mysql_error(Stmt->Connection->mariadb), 0);
}
else if (mysql_field_count(Stmt->Connection->mariadb) != 0)
{
ret= MADB_SetError(&Stmt->Error, MADB_ERR_HY000, "Can't process text result", 0);
MYSQL_RES *Res= mysql_store_result(Stmt->Connection->mariadb);
if (Res != NULL)
{
mysql_free_result(Res);
}
ret= MADB_SetError(&Stmt->Error, MADB_ERR_01000, "Internal error - unexpected text result received", 0);
}
else
{
@@ -754,6 +754,23 @@ ODBC_TEST(t_odbc43)
return OK;
}


ODBC_TEST(t_odbc226)
{
/* The testcase relies on the fact, that default connection provided to tests, allows multistatement */
EXPECT_STMT(Stmt, SQLExecDirect( Stmt, "drop temporary table if exists test.odbc226;"
"create temporary table test.odbc226 as select 1 from nonexistend_table.field", SQL_NTS), SQL_SUCCESS);

EXPECT_STMT(Stmt, SQLMoreResults(Stmt), SQL_ERROR);
odbc_print_error(SQL_HANDLE_STMT, Stmt);
CHECK_SQLSTATE(Stmt, "HY000");

CHECK_STMT_RC(Stmt, SQLFreeStmt(Stmt, SQL_CLOSE));

return OK;
}


MA_ODBC_TESTS my_tests[]=
{
{t_odbc3_error, "t_odbc3_error"},
@@ -776,6 +793,7 @@ MA_ODBC_TESTS my_tests[]=
{t_odbc115, "t_odbc115"},
{t_odbc123, "t_odbc123"},
{t_odbc43, "t_odbc43_datetime_overflow"},
{t_odbc226, "t_odbc226"},
{NULL, NULL}
};

0 comments on commit 07bc411

Please sign in to comment.
You can’t perform that action at this time.