#include #include #include #include int main(int argc, char *argv) { MYSQL *ma; MYSQL_STMT *stmt; MYSQL_BIND bind[25]; unsigned int i, paramCount= 1; const char charvalue[] = "012345678901234567890123456789012345"; ma = mysql_init(NULL); if (!mysql_real_connect(ma, "localhost", "root", "", "test", 3306, NULL, CLIENT_MULTI_STATEMENTS)) { printf("Could not connect: %s\n", mysql_error(ma)); exit(1); } else { printf("Server info %s\nClient info: %s\n", mysql_get_server_info(ma), mysql_get_client_info()); } mysql_query(ma, "DROP TABLE IF EXISTS mdev19838"); mysql_query(ma, "CREATE TABLE mdev19838(" "f1 char(36)," "f2 char(36)," "f3 char(36)," "f4 char(36)," "f5 char(36)," "f6 char(36)," "f7 char(36)," "f8 char(36)," "f9 char(36)," "f10 char(36)," "f11 char(36)," "f12 char(36)," "f13 char(36)," "f14 char(36)," "f15 char(36)," "f16 char(36)," "f17 char(36)" ")"); stmt= mysql_stmt_init(ma); if (!stmt) { printf("Could not init stmt handler(s)"); return 1; } memset(bind, 0, sizeof(bind)); for (i=0; i < 25; ++i) { bind[i].buffer= charvalue; bind[i].buffer_type= MYSQL_TYPE_STRING; bind[i].buffer_length= strlen(charvalue) + 1; bind[i].length= &bind[i].length_value; bind[i].length_value= bind[i].buffer_length - 1; } for (paramCount = 1; paramCount < 17; ++paramCount) { mysql_stmt_attr_set(stmt, STMT_ATTR_PREBIND_PARAMS, ¶mCount); mysql_stmt_bind_param(stmt, bind); if (mariadb_stmt_execute_direct(stmt, "INSERT INTO mdev19838" "(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17)" " VALUES " "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", -1)) { printf("%s %s\n", mysql_stmt_sqlstate(stmt), mysql_stmt_error(stmt)); } mysql_stmt_close(stmt); stmt = mysql_stmt_init(ma); } paramCount = 0; mysql_stmt_attr_set(stmt, STMT_ATTR_PREBIND_PARAMS, ¶mCount); if (mariadb_stmt_execute_direct(stmt, "INSERT INTO mdev19838(f1)" " VALUES (?)", -1)) { printf("%s %s\n", mysql_stmt_sqlstate(stmt), mysql_stmt_error(stmt)); } mysql_stmt_close(stmt); stmt= mysql_stmt_init(ma); paramCount= 17; mysql_stmt_attr_set(stmt, STMT_ATTR_PREBIND_PARAMS, ¶mCount); mysql_stmt_bind_param(stmt, bind); if (mariadb_stmt_execute_direct(stmt, "INSERT INTO mdev19838" "(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17)" " VALUES " "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", -1)) { printf("We should not get the error, but %s %s\n", mysql_stmt_sqlstate(stmt), mysql_stmt_error(stmt)); } bind[0].buffer_type= MYSQL_TYPE_TINY; bind[0].length_value= 1; bind[0].buffer_length= 1; for (paramCount = 8; paramCount > 0; --paramCount) { mysql_stmt_close(stmt); stmt = mysql_stmt_init(ma); mysql_stmt_attr_set(stmt, STMT_ATTR_PREBIND_PARAMS, ¶mCount); mysql_stmt_bind_param(stmt, bind); if (mariadb_stmt_execute_direct(stmt, "INSERT INTO mdev19838" "(f1, f2, f3, f4, f5, f6, f7, f8, f9)" " VALUES " "(?, ?, ?, ?, ?, ?, ?, ?, ?)", -1)) { printf("%s %s\n", mysql_stmt_sqlstate(stmt), mysql_stmt_error(stmt)); } } mysql_stmt_close(stmt); mysql_close(ma); exit(0); }