--- sysbench-0.5.0/sysbench/drivers/mysql/drv_mysql.c 2006-10-10 12:22:51.000000000 -0700 +++ venu-patch/sysbench/drivers/mysql/drv_mysql.c 2007-12-22 02:30:36.492383000 -0800 @@ -65,6 +65,7 @@ SB_ARG_TYPE_STRING, "auto"}, {"mysql-ssl", "use SSL connections, if available in the client library", SB_ARG_TYPE_FLAG, "off"}, {"myisam-max-rows", "max-rows parameter for MyISAM tables", SB_ARG_TYPE_INT, "1000000"}, + {"mysql-ignore-duplicates", "Ignore the duplicate key errors", SB_ARG_TYPE_FLAG, "off"}, {NULL, NULL, SB_ARG_TYPE_NULL, NULL} }; @@ -87,6 +88,7 @@ unsigned int myisam_max_rows; mysql_drv_trx_t engine_trx; unsigned int use_ssl; + unsigned int ignore_duplicates; } mysql_drv_args_t; #ifdef HAVE_PS @@ -232,6 +234,10 @@ args.db = sb_get_value_string("mysql-db"); args.myisam_max_rows = sb_get_value_int("myisam-max-rows"); args.use_ssl = sb_get_value_flag("mysql-ssl"); + args.ignore_duplicates = sb_get_value_flag("mysql-ignore-duplicates"); + + if (args.ignore_duplicates) + log_text(LOG_ALERT, "WARNING: Duplicate Key errors will be ignored"); use_ps = 0; #ifdef HAVE_PS @@ -640,6 +646,12 @@ if (rc == ER_LOCK_DEADLOCK || rc == ER_LOCK_WAIT_TIMEOUT || rc == ER_CHECKREAD) return SB_DB_ERROR_DEADLOCK; + if (args.ignore_duplicates && rc == ER_DUP_ENTRY) { + log_text(LOG_ALERT, "WARNING: Ignoring the duplicate error on execute mysql_stmt_execute(): Err%d %s", + mysql_errno(con->ptr), + mysql_error(con->ptr)); + return SB_DB_ERROR_NONE; + } log_text(LOG_ALERT, "failed to execute mysql_stmt_execute(): Err%d %s", mysql_errno(con->ptr), mysql_error(con->ptr));