提交 d103edc1 authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 7b41b960
......@@ -17,9 +17,7 @@ import org.h2.expression.Parameter;
import org.h2.message.Message;
import org.h2.result.LocalResult;
import org.h2.util.ObjectArray;
import org.h2.util.StringUtils;
import org.h2.value.Value;
import org.h2.value.ValueLob;
/**
* A prepared statement.
......@@ -320,35 +318,7 @@ public abstract class Prepared {
buff.append(": ");
Expression e = (Expression) parameters.get(i);
Value v = e.getValue(session);
try {
if (v.getPrecision() > SysProperties.MAX_TRACE_DATA_LENGTH) {
if (v.getType() == Value.CLOB) {
ValueLob lob = (ValueLob) v;
buff.append("SPACE(");
buff.append(lob.getPrecision());
buff.append(")");
buff.append("/* ");
buff.append(lob.getObjectId());
buff.append("*/");
} else if (v.getType() == Value.BLOB) {
ValueLob lob = (ValueLob) v;
buff.append("CAST(REPEAT('00', ");
buff.append(lob.getPrecision());
buff.append(") AS BINARY)");
buff.append("/* ");
buff.append(lob.getObjectId());
buff.append("*/");
} else {
buff.append(v.getSQL());
}
} else {
buff.append(v.getSQL());
}
} catch (Exception t) {
buff.append("? /*");
buff.append(StringUtils.quoteJavaString(t.getMessage()));
buff.append("*/");
}
buff.append(v.getTraceSQL());
}
buff.append("}");
params = buff.toString();
......
......@@ -289,6 +289,6 @@ public class JdbcArray extends TraceObject implements Array {
* INTERNAL
*/
public String toString() {
return getTraceObjectName() + ": " + value.getSQL();
return getTraceObjectName() + ": " + value.getTraceSQL();
}
}
......@@ -292,7 +292,7 @@ public class JdbcBlob extends TraceObject implements Blob {
* INTERNAL
*/
public String toString() {
return getTraceObjectName() + ": " + value.getSQL();
return getTraceObjectName() + ": " + value.getTraceSQL();
}
}
......@@ -232,7 +232,7 @@ public class JdbcClob extends TraceObject implements Clob
* INTERNAL
*/
public String toString() {
return getTraceObjectName() + ": " + value.getSQL();
return getTraceObjectName() + ": " + value.getTraceSQL();
}
}
......@@ -170,7 +170,7 @@ public class ResultRemote implements ResultInterface {
try {
v.close();
} catch (SQLException e) {
trace.error("delete lob " + v.getSQL(), e);
trace.error("delete lob " + v.getTraceSQL(), e);
}
}
lobValues = null;
......
......@@ -100,7 +100,7 @@ public class Row extends Record implements SearchRow {
if (i > 0) {
buff.append(", ");
}
buff.append(data[i].getSQL());
buff.append(data[i].getTraceSQL());
}
buff.append(')');
return buff.toString();
......
......@@ -51,7 +51,7 @@ public class SimpleRowValue implements SearchRow {
}
public String toString() {
return "( /* " + pos + " */ " + data.getSQL() + " )";
return "( /* " + pos + " */ " + data.getTraceSQL() + " )";
}
}
......@@ -292,7 +292,11 @@ public class Column {
value = value.convertScale(mode.convertOnlyToSmallerScale, scale);
if (precision > 0) {
if (!value.checkPrecision(precision)) {
throw Message.getSQLException(ErrorCode.VALUE_TOO_LONG_2, new String[]{name, value.getSQL()});
String s = value.getTraceSQL();
if (s.length() > 127) {
s = s.substring(0, 128) + "...";
}
throw Message.getSQLException(ErrorCode.VALUE_TOO_LONG_2, new String[]{name, s});
}
}
updateSequenceIfRequired(session, value);
......
......@@ -968,8 +968,18 @@ public abstract class Value {
return getPrecision() <= precision;
}
public String toString() {
/**
* Get a medium size SQL expression for debugging or tracing. If the precision is
* too large, only a subset of the value is returned.
*
* @return the SQL expression
*/
public String getTraceSQL() {
return getSQL();
}
public String toString() {
return getTraceSQL();
}
}
......@@ -115,6 +115,18 @@ public class ValueArray extends Value {
return buff.toString();
}
public String getTraceSQL() {
StringBuffer buff = new StringBuffer();
buff.append('(');
for (int i = 0; i < values.length; i++) {
if (i > 0) {
buff.append(", ");
}
buff.append(values[i].getTraceSQL());
}
buff.append(')');
return buff.toString();
}
public int getDisplaySize() {
long size = 0;
for (int i = 0; i < values.length; i++) {
......
......@@ -653,12 +653,27 @@ public class ValueLob extends Value {
}
}
public String toString() {
if (small == null) {
return getClass().getName() + " file: " + fileName + " type: " + type + " precision: " + precision;
}
public String getTraceSQL() {
if (getPrecision() <= SysProperties.MAX_TRACE_DATA_LENGTH) {
return getSQL();
}
StringBuffer buff = new StringBuffer();
if (type == Value.CLOB) {
buff.append("SPACE(");
buff.append(getPrecision());
} else {
buff.append("CAST(REPEAT('00', ");
buff.append(getPrecision());
buff.append(") AS BINARY");
}
if (small != null) {
buff.append(" /* ");
buff.append(fileName);
buff.append(" */");
}
buff.append(")");
return buff.toString();
}
/**
* Get the data if this a small lob value.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论