=== modified file 'src/com/mysql/jdbc/CallableStatement.java' --- src/com/mysql/jdbc/CallableStatement.java 2010-09-13 15:33:30 +0000 +++ src/com/mysql/jdbc/CallableStatement.java 2010-10-05 12:24:35 +0000 @@ -479,6 +479,9 @@ protected CallableStatementParamInfo paramInfo; private CallableStatementParam returnValueParam; + + /** What character to use when quoting identifiers */ + protected String quotedId = null; /** * Creates a new CallableStatement @@ -597,6 +600,27 @@ } } } + + /** + * What's the string used to quote SQL identifiers? This returns a space " " + * if identifier quoting isn't supported. A JDBC compliant driver always + * uses a double quote character. + * + * @return the quoting string + * @throws SQLException + * DOCUMENT ME! + */ + public String getIdentifierQuoteString() throws SQLException { + if (this.connection.supportsQuotedIdentifiers()) { + if (!this.connection.useAnsiQuotedIdentifiers()) { + return "`"; + } + + return "\""; + } + + return " "; + } /** * Creates a new CallableStatement @@ -615,6 +639,16 @@ boolean isFunctionCall) throws SQLException { super(conn, sql, catalog); + try { + this.quotedId = this.connection.supportsQuotedIdentifiers() ? getIdentifierQuoteString() + : ""; + } catch (SQLException sqlEx) { + // Forced by API, never thrown from getIdentifierQuoteString() in + // this + // implementation. + AssertionFailedException.shouldNotHappen(sqlEx); + } + this.callingStoredFunction = isFunctionCall; if (!this.callingStoredFunction) { @@ -814,19 +848,34 @@ java.sql.ResultSet paramTypesRs = null; try { + //Not good enough, see Bug#57022 + //We need to check for db.SPname notation first and pass on only SPname String procName = extractProcedureName(); - + + List parseList = StringUtils.splitDBdotName(procName, "", + this.quotedId , this.connection.isNoBackslashEscapesSet()); + String tmpCatalog = ""; + //There *should* be 2 rows, if any. + if (parseList.size() == 2) { + tmpCatalog = (String) parseList.get(0); + procName = (String) parseList.get(1); + } else { + //keep values as they are + } + java.sql.DatabaseMetaData dbmd = this.connection.getMetaData(); boolean useCatalog = false; - if (procName.indexOf(".") == -1) { + //After the above changes, procName.indexOf(".") is always -1! + // Except if . is in the SP name which is of no concern here.((procName.indexOf(".") == -1) && + if (tmpCatalog.length() <= 0) { useCatalog = true; } - + paramTypesRs = dbmd.getProcedureColumns(this.connection .versionMeetsMinimum(5, 0, 2) - && useCatalog ? this.currentCatalog : null, null, procName, + && useCatalog ? this.currentCatalog : tmpCatalog/*null*/, null, procName, "%"); //$NON-NLS-1$ boolean hasResults = false;