提交 f98b8066 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Remove custom implementations of Value.getSQL()

上级 e9982ac2
...@@ -134,14 +134,6 @@ public class ValueExpression extends Expression { ...@@ -134,14 +134,6 @@ public class ValueExpression extends Expression {
return value.getDisplaySize(); return value.getDisplaySize();
} }
@Override
public String getSQL() {
if (this == DEFAULT) {
return "DEFAULT";
}
return value.getSQL();
}
@Override @Override
public StringBuilder getSQL(StringBuilder builder) { public StringBuilder getSQL(StringBuilder builder) {
if (this == DEFAULT) { if (this == DEFAULT) {
......
...@@ -174,7 +174,7 @@ public class Column { ...@@ -174,7 +174,7 @@ public class Column {
getCreateSQL(); getCreateSQL();
throw DbException.get( throw DbException.get(
ErrorCode.DATA_CONVERSION_ERROR_1, e, ErrorCode.DATA_CONVERSION_ERROR_1, e,
v.getSQL() + " (" + target + ")"); v.getTraceSQL() + " (" + target + ")");
} }
throw e; throw e;
} }
......
...@@ -417,7 +417,7 @@ public class Recover extends Tool implements DataHandler { ...@@ -417,7 +417,7 @@ public class Recover extends Tool implements DataHandler {
} }
} }
private String getSQL(String column, Value v) { private void getSQL(StringBuilder builder, String column, Value v) {
if (v instanceof ValueLob) { if (v instanceof ValueLob) {
ValueLob lob = (ValueLob) v; ValueLob lob = (ValueLob) v;
byte[] small = lob.getSmall(); byte[] small = lob.getSmall();
...@@ -428,7 +428,8 @@ public class Recover extends Tool implements DataHandler { ...@@ -428,7 +428,8 @@ public class Recover extends Tool implements DataHandler {
dumpLob(file, true); dumpLob(file, true);
file += ".comp"; file += ".comp";
} }
return "READ_" + type + "('" + file + ".txt')"; builder.append("READ_").append(type).append("('").append(file).append(".txt')");
return;
} }
} else if (v instanceof ValueLobDb) { } else if (v instanceof ValueLobDb) {
ValueLobDb lob = (ValueLobDb) v; ValueLobDb lob = (ValueLobDb) v;
...@@ -437,25 +438,25 @@ public class Recover extends Tool implements DataHandler { ...@@ -437,25 +438,25 @@ public class Recover extends Tool implements DataHandler {
int type = lob.getType(); int type = lob.getType();
long id = lob.getLobId(); long id = lob.getLobId();
long precision = lob.getPrecision(); long precision = lob.getPrecision();
String m;
String columnType; String columnType;
if (type == Value.BLOB) { if (type == Value.BLOB) {
columnType = "BLOB"; columnType = "BLOB";
m = "READ_BLOB"; builder.append("READ_BLOB");
} else { } else {
columnType = "CLOB"; columnType = "CLOB";
m = "READ_CLOB"; builder.append("READ_CLOB");
} }
if (lobMaps) { if (lobMaps) {
m += "_MAP"; builder.append("_MAP");
} else { } else {
m += "_DB"; builder.append("_DB");
} }
columnTypeMap.put(column, columnType); columnTypeMap.put(column, columnType);
return m + "(" + id + ", " + precision + ")"; builder.append('(').append(id).append(", ").append(precision).append(')');
return;
} }
} }
return v.getSQL(); v.getSQL(builder);
} }
private void setDatabaseName(String name) { private void setDatabaseName(String name) {
...@@ -666,9 +667,11 @@ public class Recover extends Tool implements DataHandler { ...@@ -666,9 +667,11 @@ public class Recover extends Tool implements DataHandler {
if (!init) { if (!init) {
setStorage(Integer.parseInt(tableId)); setStorage(Integer.parseInt(tableId));
// init the column types // init the column types
StringBuilder builder = new StringBuilder();
for (valueId = 0; valueId < recordLength; valueId++) { for (valueId = 0; valueId < recordLength; valueId++) {
String columnName = storageName + "." + valueId; String columnName = storageName + "." + valueId;
getSQL(columnName, values[valueId]); builder.setLength(0);
getSQL(builder, columnName, values[valueId]);
} }
createTemporaryTable(writer); createTemporaryTable(writer);
init = true; init = true;
...@@ -681,7 +684,7 @@ public class Recover extends Tool implements DataHandler { ...@@ -681,7 +684,7 @@ public class Recover extends Tool implements DataHandler {
buff.append(", "); buff.append(", ");
} }
String columnName = storageName + "." + valueId; String columnName = storageName + "." + valueId;
buff.append(getSQL(columnName, values[valueId])); getSQL(buff, columnName, values[valueId]);
} }
buff.append(");"); buff.append(");");
writer.println(buff.toString()); writer.println(buff.toString());
...@@ -1497,7 +1500,7 @@ public class Recover extends Tool implements DataHandler { ...@@ -1497,7 +1500,7 @@ public class Recover extends Tool implements DataHandler {
sb.append(", "); sb.append(", ");
} }
String columnName = storageName + "." + valueId; String columnName = storageName + "." + valueId;
sb.append(getSQL(columnName, v)); getSQL(sb, columnName, v);
} catch (Exception e) { } catch (Exception e) {
writeDataError(writer, "exception " + e, s.getBytes()); writeDataError(writer, "exception " + e, s.getBytes());
} catch (OutOfMemoryError e) { } catch (OutOfMemoryError e) {
......
...@@ -1485,7 +1485,7 @@ public abstract class Value { ...@@ -1485,7 +1485,7 @@ public abstract class Value {
* @return the SQL expression * @return the SQL expression
*/ */
public String getTraceSQL() { public String getTraceSQL() {
return getSQL(); return getSQL(new StringBuilder()).toString();
} }
@Override @Override
......
...@@ -45,11 +45,6 @@ public class ValueBoolean extends Value { ...@@ -45,11 +45,6 @@ public class ValueBoolean extends Value {
return Value.BOOLEAN; return Value.BOOLEAN;
} }
@Override
public String getSQL() {
return getString();
}
@Override @Override
public StringBuilder getSQL(StringBuilder builder) { public StringBuilder getSQL(StringBuilder builder) {
return builder.append(getString()); return builder.append(getString());
......
...@@ -87,11 +87,6 @@ public class ValueByte extends Value { ...@@ -87,11 +87,6 @@ public class ValueByte extends Value {
return ValueByte.get((byte) (value % other.value)); return ValueByte.get((byte) (value % other.value));
} }
@Override
public String getSQL() {
return Integer.toString(value);
}
@Override @Override
public StringBuilder getSQL(StringBuilder builder) { public StringBuilder getSQL(StringBuilder builder) {
return builder.append(value); return builder.append(value);
......
...@@ -116,11 +116,6 @@ public class ValueDecimal extends Value { ...@@ -116,11 +116,6 @@ public class ValueDecimal extends Value {
return ValueDecimal.get(bd); return ValueDecimal.get(bd);
} }
@Override
public String getSQL() {
return getString();
}
@Override @Override
public StringBuilder getSQL(StringBuilder builder) { public StringBuilder getSQL(StringBuilder builder) {
return builder.append(getString()); return builder.append(getString());
......
...@@ -91,18 +91,6 @@ public class ValueDouble extends Value { ...@@ -91,18 +91,6 @@ public class ValueDouble extends Value {
return get(value % other.value); return get(value % other.value);
} }
@Override
public String getSQL() {
if (value == Double.POSITIVE_INFINITY) {
return "POWER(0, -1)";
} else if (value == Double.NEGATIVE_INFINITY) {
return "(-POWER(0, -1))";
} else if (Double.isNaN(value)) {
return "SQRT(-1)";
}
return getString();
}
@Override @Override
public StringBuilder getSQL(StringBuilder builder) { public StringBuilder getSQL(StringBuilder builder) {
if (value == Double.POSITIVE_INFINITY) { if (value == Double.POSITIVE_INFINITY) {
......
...@@ -93,11 +93,6 @@ public class ValueEnumBase extends Value { ...@@ -93,11 +93,6 @@ public class ValueEnumBase extends Value {
return Integer.signum(ordinal); return Integer.signum(ordinal);
} }
@Override
public String getSQL() {
return StringUtils.quoteStringSQL(label);
}
@Override @Override
public StringBuilder getSQL(StringBuilder builder) { public StringBuilder getSQL(StringBuilder builder) {
return builder.append(StringUtils.quoteStringSQL(label)); return builder.append(StringUtils.quoteStringSQL(label));
......
...@@ -91,18 +91,6 @@ public class ValueFloat extends Value { ...@@ -91,18 +91,6 @@ public class ValueFloat extends Value {
return get(value % other.value); return get(value % other.value);
} }
@Override
public String getSQL() {
if (value == Float.POSITIVE_INFINITY) {
return "POWER(0, -1)";
} else if (value == Float.NEGATIVE_INFINITY) {
return "(-POWER(0, -1))";
} else if (Float.isNaN(value)) {
return "SQRT(-1)";
}
return Float.toString(value);
}
@Override @Override
public StringBuilder getSQL(StringBuilder builder) { public StringBuilder getSQL(StringBuilder builder) {
if (value == Float.POSITIVE_INFINITY) { if (value == Float.POSITIVE_INFINITY) {
......
...@@ -120,11 +120,6 @@ public class ValueInt extends Value { ...@@ -120,11 +120,6 @@ public class ValueInt extends Value {
return ValueInt.get(value % other.value); return ValueInt.get(value % other.value);
} }
@Override
public String getSQL() {
return Integer.toString(value);
}
@Override @Override
public StringBuilder getSQL(StringBuilder builder) { public StringBuilder getSQL(StringBuilder builder) {
return builder.append(value); return builder.append(value);
......
...@@ -569,14 +569,6 @@ public class ValueLob extends Value { ...@@ -569,14 +569,6 @@ public class ValueLob extends Value {
} }
} }
@Override
public String getSQL() {
if (valueType == Value.CLOB) {
return StringUtils.quoteStringSQL(getString());
}
return "X'" + StringUtils.convertBytesToHex(getBytes()) + '\'';
}
@Override @Override
public StringBuilder getSQL(StringBuilder builder) { public StringBuilder getSQL(StringBuilder builder) {
if (valueType == Value.CLOB) { if (valueType == Value.CLOB) {
......
...@@ -460,14 +460,6 @@ public class ValueLobDb extends Value { ...@@ -460,14 +460,6 @@ public class ValueLobDb extends Value {
} }
} }
@Override
public String getSQL() {
if (valueType == Value.CLOB) {
return StringUtils.quoteStringSQL(getString());
}
return "X'" + StringUtils.convertBytesToHex(getBytes()) + '\'';
}
@Override @Override
public StringBuilder getSQL(StringBuilder builder) { public StringBuilder getSQL(StringBuilder builder) {
if (valueType == Value.CLOB) { if (valueType == Value.CLOB) {
......
...@@ -145,11 +145,6 @@ public class ValueLong extends Value { ...@@ -145,11 +145,6 @@ public class ValueLong extends Value {
return ValueLong.get(this.value % other.value); return ValueLong.get(this.value % other.value);
} }
@Override
public String getSQL() {
return Long.toString(value);
}
@Override @Override
public StringBuilder getSQL(StringBuilder builder) { public StringBuilder getSQL(StringBuilder builder) {
return builder.append(value); return builder.append(value);
......
...@@ -48,11 +48,6 @@ public class ValueNull extends Value { ...@@ -48,11 +48,6 @@ public class ValueNull extends Value {
// don't allow construction // don't allow construction
} }
@Override
public String getSQL() {
return "NULL";
}
@Override @Override
public StringBuilder getSQL(StringBuilder builder) { public StringBuilder getSQL(StringBuilder builder) {
return builder.append("NULL"); return builder.append("NULL");
......
...@@ -165,11 +165,6 @@ public class ValueResultSet extends Value { ...@@ -165,11 +165,6 @@ public class ValueResultSet extends Value {
throw getUnsupportedExceptionForOperation("PreparedStatement.set"); throw getUnsupportedExceptionForOperation("PreparedStatement.set");
} }
@Override
public String getSQL() {
return "";
}
@Override @Override
public StringBuilder getSQL(StringBuilder builder) { public StringBuilder getSQL(StringBuilder builder) {
return builder; return builder;
......
...@@ -87,11 +87,6 @@ public class ValueShort extends Value { ...@@ -87,11 +87,6 @@ public class ValueShort extends Value {
return ValueShort.get((short) (value % other.value)); return ValueShort.get((short) (value % other.value));
} }
@Override
public String getSQL() {
return Integer.toString(value);
}
@Override @Override
public StringBuilder getSQL(StringBuilder builder) { public StringBuilder getSQL(StringBuilder builder) {
return builder.append(value); return builder.append(value);
......
...@@ -33,11 +33,6 @@ public class ValueString extends Value { ...@@ -33,11 +33,6 @@ public class ValueString extends Value {
this.value = value; this.value = value;
} }
@Override
public String getSQL() {
return StringUtils.quoteStringSQL(value);
}
@Override @Override
public StringBuilder getSQL(StringBuilder builder) { public StringBuilder getSQL(StringBuilder builder) {
return builder.append(StringUtils.quoteStringSQL(value)); return builder.append(StringUtils.quoteStringSQL(value));
......
...@@ -336,11 +336,6 @@ public class TestCustomDataTypesHandler extends TestDb { ...@@ -336,11 +336,6 @@ public class TestCustomDataTypesHandler extends TestDb {
return new ValueComplex(val); return new ValueComplex(val);
} }
@Override
public String getSQL() {
return val.toString();
}
@Override @Override
public StringBuilder getSQL(StringBuilder builder) { public StringBuilder getSQL(StringBuilder builder) {
return builder.append(val.toString()); return builder.append(val.toString());
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论