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

Remove custom implementations of Value.getSQL()

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