Bug #11663 Incorrect generation of TestcaseScripts
Submitted: 30 Jun 2005 12:17 Modified: 2 Aug 2005 18:14
Reporter: Paul Shmarev Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:3.1.10 OS:Any (any)
Assigned to: Mark Matthews

[30 Jun 2005 12:17] Paul Shmarev
Description:
Incorrect generation of TestcaseScript. 
For examle (part of STDERR output):

/* conn id 0 */ PREPARE debug_stmt_3 FROM "SELECT T0.id, T0.name FROM T0 WHERE T0.id=?;
/* conn id 0 */ SET @debug_stmt_param3_0=123;
/* conn id 0 */ EXECUTE debug_stmt_3 USING @debug_stmt_param1_0;

As you can see the debug_stmt_param3_0 has set, but for execution of statement used  another variable debug_stmt_param1_0.

How to repeat:
Turn autoGenerateTestcaseScript parametr to true and look to the output.

Suggested fix:
I suggest to change com.mysql.jdbc.ServerPreparedStatement

private void dumpExecuteForTestcase() throws SQLException {
        /* skipped */
	if (this.parameterCount > 0) {
		buf.append(" USING ");
		for (int i = 0; i < this.parameterCount; i++) {
			if (i > 0) {
				buf.append(", ");
			}
			buf.append("@debug_stmt_param");
			// buf.append(this.serverStatementId); -- it's wrong
                        buf.append(this.statementId); // it's correct
			buf.append("_");
			buf.append(i);
		}
	}
	/* skipped */
}
[2 Jul 2005 6:18] Vasily Kishkin
Could you please attach full text of test case ? What is definition of table ?
[2 Aug 2005 18:14] Mark Matthews
Fix is checked in, present in nightly snapshot builds at http://downloads.mysql.com/snapshots.php