diff --git a/test/prepare.c b/test/prepare.c index 7cd5b7b..0fc9f10 100644 --- a/test/prepare.c +++ b/test/prepare.c @@ -1219,6 +1219,94 @@ ODBC_TEST(t_odbc141) } +ODBC_TEST(t_expect_need_data2) +{ + const char charvalue[] = "012345678901234567890123456789012345"; + SQLINTEGER len = -2; + + OK_SIMPLE_STMT(Stmt, "DROP TABLE IF EXISTS crash_after_invalid_command2"); + + OK_SIMPLE_STMT(Stmt, "CREATE TABLE crash_after_invalid_command2(" + "f1 char(10)," + "f2 char(10)," + "f3 char(10)," + "f4 char(10)," + "f5 char(10)," + "f6 char(10)," + "f7 char(10)," + "f8 char(10)," + "f9 char(10)," + "f10 char(10)," + "f11 char(10)," + "f12 char(10)," + "f13 char(10)," + "f14 char(10)," + "f15 char(10)," + "f16 char(10)," + "f17 char(10)," + "f18 char(10)," + "f19 char(10)," + "f20 char(10)," + "f21 char(10)," + "f22 char(10)," + "f23 char(10)," + "m1 text," + "m2 text)"); + + CHECK_STMT_RC(Stmt, SQLFreeStmt(Stmt, SQL_CLOSE)); + + rc = SQLBindParameter(Stmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 10, 0, charvalue, 26, NULL); + rc = SQLBindParameter(Stmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 10, 0, charvalue, 26, NULL); + rc = SQLBindParameter(Stmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 10, 0, charvalue, 26, NULL); + rc = SQLBindParameter(Stmt, 4, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 10, 0, charvalue, 26, NULL); + rc = SQLBindParameter(Stmt, 5, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 10, 0, charvalue, 26, NULL); + rc = SQLBindParameter(Stmt, 6, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 10, 0, charvalue, 26, NULL); + rc = SQLBindParameter(Stmt, 7, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 10, 0, charvalue, 26, NULL); + rc = SQLBindParameter(Stmt, 8, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 10, 0, charvalue, 26, NULL); + rc = SQLBindParameter(Stmt, 9, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 10, 0, charvalue, 26, NULL); + + EXPECT_STMT(Stmt, SQLExecDirect(Stmt, "any invalid command with parameter ?, ?, ?, ?, ?, ?, ?, ?, ?,", SQL_NTS), + SQL_ERROR); + + CHECK_STMT_RC(Stmt, SQLFreeStmt(Stmt, SQL_CLOSE)); + + rc = SQLBindParameter(Stmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 10, 0, charvalue, 26, NULL); + rc = SQLBindParameter(Stmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 10, 0, charvalue, 26, NULL); + rc = SQLBindParameter(Stmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 10, 0, charvalue, 26, NULL); + rc = SQLBindParameter(Stmt, 4, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 10, 0, charvalue, 26, NULL); + rc = SQLBindParameter(Stmt, 5, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 10, 0, charvalue, 26, NULL); + rc = SQLBindParameter(Stmt, 6, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 10, 0, charvalue, 26, NULL); + rc = SQLBindParameter(Stmt, 7, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 10, 0, charvalue, 26, NULL); + rc = SQLBindParameter(Stmt, 8, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 10, 0, charvalue, 26, NULL); + rc = SQLBindParameter(Stmt, 9, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 10, 0, charvalue, 26, NULL); + rc = SQLBindParameter(Stmt, 10, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 10, 0, charvalue, 26, NULL); + rc = SQLBindParameter(Stmt, 11, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 10, 0, charvalue, 26, NULL); + rc = SQLBindParameter(Stmt, 12, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 10, 0, charvalue, 26, NULL); + rc = SQLBindParameter(Stmt, 13, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 10, 0, charvalue, 26, NULL); + rc = SQLBindParameter(Stmt, 14, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 10, 0, charvalue, 26, NULL); + rc = SQLBindParameter(Stmt, 15, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 10, 0, charvalue, 26, NULL); + rc = SQLBindParameter(Stmt, 16, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 10, 0, charvalue, 26, NULL); + rc = SQLBindParameter(Stmt, 17, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 10, 0, charvalue, 26, NULL); + rc = SQLBindParameter(Stmt, 18, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 10, 0, charvalue, 26, NULL); + rc = SQLBindParameter(Stmt, 19, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 10, 0, charvalue, 26, NULL); + rc = SQLBindParameter(Stmt, 20, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 10, 0, charvalue, 26, NULL); + rc = SQLBindParameter(Stmt, 21, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 10, 0, charvalue, 26, NULL); + rc = SQLBindParameter(Stmt, 22, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 10, 0, charvalue, 26, NULL); + rc = SQLBindParameter(Stmt, 23, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 10, 0, charvalue, 26, NULL); + rc = SQLBindParameter(Stmt, 24, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 10, 0, 0x00000001, 0, &len); + rc = SQLBindParameter(Stmt, 25, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 10, 0, 0x00000002, 0, &len); + + EXPECT_STMT(Stmt, + SQLExecDirect(Stmt, "INSERT INTO crash_after_invalid_command2" + "(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, m1, m2)" + " VALUES " + "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", SQL_NTS), + SQL_NEED_DATA); + + CHECK_STMT_RC(Stmt, SQLFreeStmt(Stmt, SQL_CLOSE)); + return OK; +} + MA_ODBC_TESTS my_tests[]= { {t_prep_basic, "t_prep_basic"}, @@ -1238,7 +1326,8 @@ MA_ODBC_TESTS my_tests[]= {t_bug67340, "t_bug67340"}, {t_bug67702, "t_bug67702"}, {t_odbc57, "odbc-57-query_in_parenthesis" }, - {t_odbc141, "odbc-141-load_data_infile" }, + {t_expect_need_data2, "t_expect_need_data_2" }, + {t_odbc141, "odbc-141-load_data_infile" }, {NULL, NULL} };