db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Army <qoz...@sbcglobal.net>
Subject Re: [jira] Commented: (DERBY-506) Implement Statement.setQueryTimeout in the Client Driver
Date Tue, 15 Nov 2005 01:57:25 GMT
Satheesh Bandaram (JIRA) wrote:

>     2) What would happen if a 10.2 client tries to send a SET STATEMENT_TIMEOUT 
> statement to a 10.1 server? There doesn't seem to be any mechanism to prevent 
> unpleasant events.

I was reviewing the patch and decided to look into your question more, and I 
think there is actually code there to catch this.  The choice of a "SET ..." 
syntax was a good one in this particular case: there is already code in 
DRDAConnThread that looks for "SET ..." statements that are included as part of 
an EXCSQLSET command, and if the statement isn't recognized, the server will 
simply return a warning and ignore it.  The code that does this is in the 
"parseEXCSQLSETobjects()" method:


	try {
	} catch (SQLException e) {

		// if this is a syntax error, then we take it
		// to mean that the given SET statement is not
		// recognized; take note (so we can throw a
		// warning later), but don't interfere otherwise.
		if (e.getSQLState().equals(SYNTAX_ERR))
			hadUnrecognizedStmt = true;
		// something else; assume it's serious.
			throw e;


	// Now that we've processed all SET statements (assuming no
	// severe exceptions), check for warnings and, if we had any,
	// note this in the SQLCARD reply object (but DON'T cause the
	// EXCSQLSET statement to fail).
	if (hadUnrecognizedStmt) {
		SQLWarning warn = new SQLWarning("One or more SET statements " +
			"not recognized.", "01000");
		throw warn;
	} // end if.


To confirm, I tried to run jdbcapi/SetQueryTimeoutTest from a client that had 
the patch applied against a server that did not.  The result was the following 
diff, which looks correct to me:

 > Test SetQueryTimeoutTest FAILED

fetch did not time out. Highest execution time: 7000 ms

In other words, the call to "SET QUERY_TIMEOUT" failed with a syntax error and 
was ignored, and thus the statement never timed out.

Does that sound correct?

View raw message