Bug #51423 c/J changing SQL mode not documented
Submitted: 23 Feb 2010 14:33 Modified: 25 Feb 2010 15:55
Reporter: Tonci Grgin Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Documentation Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: Tony Bedford CPU Architecture:Any

[23 Feb 2010 14:33] Tonci Grgin
Description:
ConnectionImpl.java:
private void setupServerForTruncationChecks() throws SQLException {
	if (getJdbcCompliantTruncation()) {
		if (versionMeetsMinimum(5, 0, 2)) {
			String currentSqlMode = (String)this.serverVariables.get("sql_mode");
			boolean strictTransTablesIsSet = StringUtils.indexOfIgnoreCase(currentSqlMode, "STRICT_TRANS_TABLES") != -1;
				
			if (currentSqlMode == null ||
		currentSqlMode.length() == 0 || !strictTransTablesIsSet) {
				StringBuffer commandBuf = new StringBuffer("SET sql_mode='");
					
				if (currentSqlMode != null && currentSqlMode.length() > 0) {
					commandBuf.append(currentSqlMode);
					commandBuf.append(",");
				}
					
					
				commandBuf.append("STRICT_TRANS_TABLES'");
					
				execSQL(null,  commandBuf.toString(), -1, null,
DEFAULT_RESULT_SET_TYPE, DEFAULT_RESULT_SET_CONCURRENCY, false, this.database, null, false);
				setJdbcCompliantTruncation(false); // server's handling this for us now
			} else if (strictTransTablesIsSet) {
				// We didn't set it, but someone did, so we piggy back on it
				setJdbcCompliantTruncation(false); // server's handling this for us now
			}
				
		}
	}
}

shows that c/J is changing SQL mode due to being closer to JDBC compliant behavior when JdbcCompliantTruncation connection string option is in use. However, this fact is not noted in manual, afais.

How to repeat:
-

Suggested fix:
Fix the manual to mention this.
[25 Feb 2010 15:55] Tony Bedford
Thanks for spotting this Tonci.

The entry for jdbcCompliantTruncation has been updated in the Java sources (LocalizedErrorMessages.properties). This will then automatically update the Connector/J connection string option reference info in the online docs.