public static void appendMap(StatementBuilder sql, Map<String, String> map) { sql.resetCount(); sql.append("("); for (Entry<String, String> e : map.entrySet()) { if (e.getValue() == null) continue; sql.appendExceptFirst(","); sql.append(e.getKey()).append('=').append("'").append(e.getValue()).append("'"); } sql.append(')'); }
private void rewriteSql() { StatementBuilder sql = new StatementBuilder("ALTER DATABASE "); sql.append(db.getShortName()); sql.append(" RUN MODE ").append(runMode.toString()); if (replicationProperties != null && !replicationProperties.isEmpty()) { sql.append(" WITH REPLICATION STRATEGY"); Database.appendMap(sql, replicationProperties); } sql.append(" PARAMETERS"); Database.appendMap(sql, db.getParameters()); this.sql = sql.toString(); }
@Override public void rename(String newName) { StatementBuilder sql = new StatementBuilder("alter table "); sql.append(getName()).append(" rename to").append(newName); PreparedStatement prepared = getDatabase().getSystemSession().prepareStatement(sql.toString(), true); prepared.setLocal(true); prepared.update(); }
@Override public String getSQL(boolean isDistributed) { StatementBuilder buff = new StatementBuilder("("); buff.append(left.getSQL(isDistributed)).append(" IN("); for (Expression e : valueList) { buff.appendExceptFirst(", "); buff.append(e.getSQL(isDistributed)); } return buff.append("))").toString(); }
@Override public String getSQL(boolean isDistributed) { StatementBuilder buff = new StatementBuilder(getName()); buff.append('('); int i = 0; for (Expression e : args) { buff.appendExceptFirst(", "); buff.append(columnList[i++].getCreateSQL()).append('=').append(e.getSQL(isDistributed)); } return buff.append(')').toString(); }
@Override public String getSQL(boolean isDistributed) { StatementBuilder buff = new StatementBuilder(); buff.append(Parser.quoteIdentifier(userAggregate.getName())).append('('); for (Expression e : args) { buff.appendExceptFirst(", "); buff.append(e.getSQL(isDistributed)); } return buff.append(')').toString(); }
/** * Get the list of columns as a string. * * @return the list of columns */ private String getColumnListSQL() { StatementBuilder buff = new StatementBuilder(); for (IndexColumn c : indexColumns) { buff.appendExceptFirst(", "); buff.append(c.getSQL()); } return buff.toString(); }
private DbException getSyntaxError() { if (expectedList == null || expectedList.isEmpty()) { return DbException.getSyntaxError(sqlCommand, parseIndex); } StatementBuilder buff = new StatementBuilder(); for (String e : expectedList) { buff.appendExceptFirst(", "); buff.append(e); } return DbException.getSyntaxError(sqlCommand, parseIndex, buff.toString()); }