提交 950f82d5 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Replace more suspicious invocations of Column.getName() with getSQL()

上级 b056815f
......@@ -388,8 +388,8 @@ public class Insert extends CommandWithValues implements ResultTarget {
Expression[] row = (currentRow == null) ? valuesExpressionList.get((int) getCurrentRowNumber() - 1)
: new Expression[columns.length];
for (int i = 0; i < columns.length; i++) {
String key = table.getSchema().getName() + "." +
table.getName() + "." + columns[i].getName();
StringBuilder builder = table.getSQL(new StringBuilder()).append('.');
String key = columns[i].getSQL(builder).toString();
variableNames.add(key);
Value value;
if (currentRow != null) {
......
......@@ -388,58 +388,55 @@ public class ScriptCommand extends ScriptBase {
Index index = plan.getIndex();
Cursor cursor = index.find(session, null, null);
Column[] columns = table.getColumns();
StatementBuilder buff = new StatementBuilder("INSERT INTO ");
table.getSQL(buff.builder()).append('(');
for (Column col : columns) {
buff.appendExceptFirst(", ");
Parser.quoteIdentifier(buff.builder(), col.getName());
}
buff.append(") VALUES");
StringBuilder builder = new StringBuilder("INSERT INTO ");
table.getSQL(builder).append('(');
Column.writeColumns(builder, columns);
builder.append(") VALUES");
if (!simple) {
buff.append('\n');
builder.append('\n');
}
buff.append('(');
String ins = buff.toString();
buff = null;
builder.append('(');
String ins = builder.toString();
builder = null;
while (cursor.next()) {
Row row = cursor.get();
if (buff == null) {
buff = new StatementBuilder(ins);
if (builder == null) {
builder = new StringBuilder(ins);
} else {
buff.append(",\n(");
builder.append(",\n(");
}
for (int j = 0; j < row.getColumnCount(); j++) {
if (j > 0) {
buff.append(", ");
builder.append(", ");
}
Value v = row.getValue(j);
if (v.getType().getPrecision() > lobBlockSize) {
int id;
if (v.getValueType() == Value.CLOB) {
id = writeLobStream(v);
buff.append("SYSTEM_COMBINE_CLOB(").append(id).append(')');
builder.append("SYSTEM_COMBINE_CLOB(").append(id).append(')');
} else if (v.getValueType() == Value.BLOB) {
id = writeLobStream(v);
buff.append("SYSTEM_COMBINE_BLOB(").append(id).append(')');
builder.append("SYSTEM_COMBINE_BLOB(").append(id).append(')');
} else {
v.getSQL(buff.builder());
v.getSQL(builder);
}
} else {
v.getSQL(buff.builder());
v.getSQL(builder);
}
}
buff.append(')');
builder.append(')');
count++;
if ((count & 127) == 0) {
checkCanceled();
}
if (simple || buff.length() > Constants.IO_BUFFER_SIZE) {
add(buff.toString(), true);
buff = null;
if (simple || builder.length() > Constants.IO_BUFFER_SIZE) {
add(builder.toString(), true);
builder = null;
}
}
if (buff != null) {
add(buff.toString(), true);
if (builder != null) {
add(builder.toString(), true);
}
return count;
}
......
......@@ -1478,11 +1478,7 @@ public class Select extends Query {
t.getSchema().getSQL(buff.builder()).append('.');
Parser.quoteIdentifier(buff.builder(), t.getName())
.append('(');
buff.resetCount();
for (Column c : t.getColumns()) {
buff.appendExceptFirst(",");
buff.append(c.getName());
}
Column.writeColumns(buff.builder(), t.getColumns());
buff.append(") AS ");
t.getSQL(buff.builder()).append('\n');
}
......
......@@ -575,7 +575,7 @@ public class ConstraintReferential extends Constraint {
buff.resetCount();
for (IndexColumn c : columns) {
buff.appendExceptFirst(", ");
Parser.quoteIdentifier(buff.builder(), c.column.getName()).append("=?");
c.column.getSQL(buff.builder()).append("=?");
}
}
......@@ -584,7 +584,7 @@ public class ConstraintReferential extends Constraint {
buff.resetCount();
for (IndexColumn c : columns) {
buff.appendExceptFirst(" AND ");
Parser.quoteIdentifier(buff.builder(), c.column.getName()).append("=?");
c.column.getSQL(buff.builder()).append("=?");
}
}
......
......@@ -58,7 +58,7 @@ public class ConstraintUnique extends Constraint {
buff.append(' ').append(getConstraintType().getSqlName()).append('(');
for (IndexColumn c : columns) {
buff.appendExceptFirst(", ");
Parser.quoteIdentifier(buff.builder(), c.column.getName());
c.column.getSQL(buff.builder());
}
buff.append(')');
if (internalIndex && indexOwner && forTable == this.table) {
......
......@@ -1713,10 +1713,15 @@ public class Function extends Expression implements FunctionCall {
}
break;
}
case VALUES:
result = session.getVariable(args[0].getSchemaName() + "." +
args[0].getTableName() + "." + args[0].getColumnName());
case VALUES: {
Expression a0 = args[0];
StringBuilder builder = new StringBuilder();
Parser.quoteIdentifier(builder, a0.getSchemaName()).append('.');
Parser.quoteIdentifier(builder, a0.getTableName()).append('.');
Parser.quoteIdentifier(builder, a0.getColumnName());
result = session.getVariable(builder.toString());
break;
}
case SIGNAL: {
String sqlState = v0.getString();
if (sqlState.startsWith("00") || !SIGNAL_PATTERN.matcher(sqlState).matches()) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论