Skip to content

Commit

Permalink
MONDRIAN: In pretty-print mode, don't put linefeed at start of an SQL…
Browse files Browse the repository at this point in the history
… statement; it makes DB2 barf.

[git-p4: depot-paths = "//open/mondrian/": change = 8871]
  • Loading branch information
julianhyde committed Mar 16, 2007
1 parent 4b6d228 commit b17195c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
11 changes: 8 additions & 3 deletions src/main/mondrian/rolap/RolapUtil.java
Expand Up @@ -238,7 +238,7 @@ public static ResultSet executeQuery(
* @param resultSetType Result set type, or -1 to use default
* @param resultSetConcurrency Result set concurrency, or -1 to use default
* @return ResultSet
* @throws SQLException
* @throws SQLException if query has error
*/
public static ResultSet executeQuery(
Connection jdbcConnection,
Expand All @@ -254,8 +254,13 @@ public static ResultSet executeQuery(
ResultSet resultSet;
String status = "failed";
if (produceDebugOut == Boolean.TRUE) {
RolapUtil.debugOut.print(
component + ": executing sql [" + sql + "]");
RolapUtil.debugOut.print(component + ": executing sql [");
if (sql.indexOf('\n') >= 0) {
// SQL appears to be formatted. Make it start on its own line.
RolapUtil.debugOut.println();
}
RolapUtil.debugOut.print(sql);
RolapUtil.debugOut.print(']');
RolapUtil.debugOut.flush();
}
ExecuteQueryHook hook = threadHooks.get();
Expand Down
12 changes: 7 additions & 5 deletions src/main/mondrian/rolap/sql/SqlQuery.java
Expand Up @@ -467,12 +467,14 @@ public String toString()
}
}

/**
* Prints this SqlQuery to a PrintWriter with each clause on a separate
* line, and with the specified indentation prefix.
*
* @param pw Print writer
* @param prefix Prefix for each line
*/
public void print(PrintWriter pw, String prefix) {
// This <CR> is added to the front because the part of the code
// that prints out the sql (if the trace level is non-zero),
// RolapUtil, does not print the sql at the start of a new line.
pw.println();

select.print(pw, prefix,
distinct ? "select distinct " : "select ", ", ");
from.print(pw, prefix, "from ", ", ");
Expand Down

0 comments on commit b17195c

Please sign in to comment.