Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
3.0.1
-
None
-
None
-
10.2 server
Description
Server supports prepared statements bulk operations for INSERT and UPDATE, and not for DELETE, in particular. That might change with new releases, but currently that will result in error, if application tries to DELETE with parameters array.
Code to repeat the problem
ODBC_TEST(t_bulk_delete)
{
SQLINTEGER a[3]=
;
SQLCHAR val[7], insert_val[][7]=
;
SQLLEN val_indicator[]=
, id_ind[]=
{4, 4, 4};
OK_SIMPLE_STMT(Stmt, "DROP TABLE IF EXISTS t_bulk_delete");
OK_SIMPLE_STMT(Stmt, "CREATE TABLE t_bulk_delete (id INT unsigned not null primary key, val VARCHAR(20) not null)");
/OK_SIMPLE_STMT(Stmt, "INSERT INTO t_bulk_delete VALUES(1, 'first'), (2, 'second'), (3, 'third')");/
CHECK_STMT_RC(Stmt, SQLFreeStmt(Stmt, SQL_CLOSE));
CHECK_STMT_RC(Stmt, SQLSetStmtAttr(Stmt, SQL_ATTR_PARAMSET_SIZE,
(SQLPOINTER)3, 0));
CHECK_STMT_RC(Stmt, SQLBindParameter(Stmt, 1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, a, 0, id_ind));
CHECK_STMT_RC(Stmt, SQLBindParameter(Stmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 0, 0, insert_val, 0, val_indicator));
OK_SIMPLE_STMT(Stmt, "INSERT INTO t_bulk_delete VALUES(?, ?)");
CHECK_STMT_RC(Stmt, SQLSetStmtAttr(Stmt, SQL_ATTR_PARAMSET_SIZE,
(SQLPOINTER)2, 0));
OK_SIMPLE_STMT(Stmt, "DELETE FROM t_bulk_delete WHERE id=?");
OK_SIMPLE_STMT(Stmt, "SELECT id, val FROM t_bulk_insert");
CHECK_STMT_RC(Stmt, SQLFetch(Stmt));
is_num(my_fetch_int(Stmt, 1), 2);
IS_STR(my_fetch_str(Stmt, val, 1), "second", 7);
EXPECT_STMT(Stmt, SQLFetch(Stmt), SQL_NO_DATA);
CHECK_STMT_RC(Stmt, SQLFreeStmt(Stmt, SQL_CLOSE));
CHECK_STMT_RC(Stmt, SQLSetStmtAttr(Stmt, SQL_ATTR_ROW_ARRAY_SIZE,
(SQLPOINTER)1, 0));
OK_SIMPLE_STMT(Stmt, "DROP TABLE IF EXISTS t_bulk_delete");
return OK;
}