@Override public String getSQL() { StatementBuilder buff = new StatementBuilder("("); buff.append(left.getSQL()).append(" IN("); for (Expression e : valueList) { buff.appendExceptFirst(", "); buff.append(e.getSQL()); } return buff.append("))").toString(); }
@Override public String getSQL() { String text; switch (type) { case GROUP_CONCAT: return getSQLGroupConcat(); case COUNT_ALL: return "COUNT(*)"; case COUNT: text = "COUNT"; break; case SELECTIVITY: text = "SELECTIVITY"; break; case HISTOGRAM: text = "HISTOGRAM"; break; case SUM: text = "SUM"; break; case MIN: text = "MIN"; break; case MAX: text = "MAX"; break; case AVG: text = "AVG"; break; case STDDEV_POP: text = "STDDEV_POP"; break; case STDDEV_SAMP: text = "STDDEV_SAMP"; break; case VAR_POP: text = "VAR_POP"; break; case VAR_SAMP: text = "VAR_SAMP"; break; case BOOL_AND: text = "BOOL_AND"; break; case BOOL_OR: text = "BOOL_OR"; break; default: throw DbException.throwInternalError("type=" + type); } if (distinct) { return text + "(DISTINCT " + on.getSQL() + ")"; } return text + StringUtils.enclose(on.getSQL()); }
/** Returns SQL for default value. */ public String getDefaultSQL() { String ddl = null; ddl = defaultExpression == null ? null : defaultExpression.getSQL(); return ddl; }
public String getSQL() { StringBuffer sb = new StringBuffer(); switch (type) { case StatementTypes.SIGNAL: sb.append(Tokens.T_SIGNAL); break; case StatementTypes.RESIGNAL: sb.append(Tokens.T_RESIGNAL); break; // todo case StatementTypes.ITERATE: sb.append(Tokens.T_ITERATE).append(' ').append(label); break; case StatementTypes.LEAVE: sb.append(Tokens.T_LEAVE).append(' ').append(label); break; case StatementTypes.RETURN: /* sb.append(Tokens.T_RETURN); if (expression != null) { sb.append(' ').append(expression.getSQL()); } break; */ return sql; case StatementTypes.CONDITION: sb.append(expression.getSQL()); break; case StatementTypes.ASSIGNMENT: sb.append(Tokens.T_SET).append(' '); sb.append(variable.getName().statementName).append(' '); sb.append('=').append(' ').append(expression.getSQL()); break; } return sb.toString(); }
@Override public String getSQL() { StatementBuilder buff = new StatementBuilder(); buff.append(Parser.quoteIdentifier(userAggregate.getName())).append('('); for (Expression e : args) { buff.appendExceptFirst(", "); buff.append(e.getSQL()); } return buff.append(')').toString(); }
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() { StatementBuilder buff = new StatementBuilder("("); for (Expression e : list) { buff.appendExceptFirst(", "); buff.append(e.getSQL()); } if (list.length == 1) { buff.append(','); } return buff.append(')').toString(); }
private String getSQLGroupConcat() { StatementBuilder buff = new StatementBuilder("GROUP_CONCAT("); if (distinct) { buff.append("DISTINCT "); } buff.append(on.getSQL()); if (groupConcatOrderList != null) { buff.append(" ORDER BY "); for (SelectOrderBy o : groupConcatOrderList) { buff.appendExceptFirst(", "); buff.append(o.expression.getSQL()); if (o.descending) { buff.append(" DESC"); } } } if (groupConcatSeparator != null) { buff.append(" SEPARATOR ").append(groupConcatSeparator.getSQL()); } return buff.append(')').toString(); }
public String getSQL() { StatementBuilder buff = new StatementBuilder(); // TODO always append the schema once FUNCTIONS_IN_SCHEMA is enabled if (functionAlias.getDatabase().getSettings().functionsInSchema || !functionAlias.getSchema().getName().equals(Constants.SCHEMA_MAIN)) { buff.append(Parser.quoteIdentifier(functionAlias.getSchema().getName())).append('.'); } buff.append(Parser.quoteIdentifier(functionAlias.getName())).append('('); for (Expression e : args) { buff.appendExceptFirst(", "); buff.append(e.getSQL()); } return buff.append(')').toString(); }
public String getSQL() { StringBuffer sb = new StringBuffer(); switch (operationType) { case StatementSet.VARIABLE_SET: { /** @todo - cover row assignment */ sb.append(Tokens.T_SET).append(' '); sb.append(variables[0].getName().statementName).append(' '); sb.append('=').append(' ').append(expression.getSQL()); break; } } return sb.toString(); }
void recompile(Session session, Table newTable) { String ddl = check.getSQL(); Scanner scanner = new Scanner(ddl); ParserDQL parser = new ParserDQL(session, scanner); parser.read(); parser.isCheckOrTriggerCondition = true; Expression condition = parser.XreadBooleanValueExpression(); check = condition; schemaObjectNames = parser.compileContext.getSchemaObjectNames(); // this workaround is here to stop LIKE optimisation (for proper scripting) QuerySpecification s = Expression.getCheckSelect(session, newTable, check); rangeVariable = s.rangeVariables[0]; rangeVariable.setForCheckConstraint(); }
public String getSQL() { StringBuffer sb = new StringBuffer(); switch (type) { case StatementTypes.RETURN: /* sb.append(Tokens.T_RETURN); if (expression != null) { sb.append(' ').append(expression.getSQL()); } break; */ return sql; case StatementTypes.CONDITION: sb.append(expression.getSQL()); break; } return sb.toString(); }
/** Returns the SQL for the expression in CHECK clause */ public String getCheckSQL() { return check.getSQL(); }
public String getSQL() { StringBuffer sb = new StringBuffer(); switch (getConstraintType()) { case Constraint.PRIMARY_KEY: if (getMainColumns().length > 1 || (getMainColumns().length == 1 && !getName().isReservedName())) { if (!getName().isReservedName()) { sb.append(Tokens.T_CONSTRAINT).append(' '); sb.append(getName().statementName).append(' '); } sb.append(Tokens.T_PRIMARY).append(' ').append(Tokens.T_KEY); getColumnList(getMain(), getMainColumns(), getMainColumns().length, sb); } break; case Constraint.UNIQUE: if (!getName().isReservedName()) { sb.append(Tokens.T_CONSTRAINT).append(' '); sb.append(getName().statementName); sb.append(' '); } sb.append(Tokens.T_UNIQUE); int[] col = getMainColumns(); getColumnList(getMain(), col, col.length, sb); break; case Constraint.FOREIGN_KEY: if (isForward) { sb.append(Tokens.T_ALTER).append(' ').append(Tokens.T_TABLE).append(' '); sb.append(getRef().getName().getSchemaQualifiedStatementName()); sb.append(' ').append(Tokens.T_ADD).append(' '); getFKStatement(sb); } else { getFKStatement(sb); } break; case Constraint.CHECK: if (isNotNull()) { break; } if (!getName().isReservedName()) { sb.append(Tokens.T_CONSTRAINT).append(' '); sb.append(getName().statementName).append(' '); } sb.append(Tokens.T_CHECK).append('('); sb.append(check.getSQL()); sb.append(')'); // should not throw as it is already tested OK break; } return sb.toString(); }
public String getSQL() { switch (opType) { case OpTypes.DEFAULT: return Tokens.T_DEFAULT; case OpTypes.DYNAMIC_PARAM: return Tokens.T_QUESTION; case OpTypes.ASTERISK: return "*"; case OpTypes.COALESCE: return alias.getStatementName(); case OpTypes.DIAGNOSTICS_VARIABLE: case OpTypes.VARIABLE: case OpTypes.PARAMETER: return column.getName().statementName; case OpTypes.ROWNUM: { StringBuffer sb = new StringBuffer(Tokens.T_ROWNUM); sb.append('(').append(')'); } case OpTypes.COLUMN: { if (column == null) { if (alias != null) { return alias.getStatementName(); } else { return columnName; } } if (rangeVariable.tableAlias == null) { return column.getName().getSchemaQualifiedStatementName(); } else { StringBuffer sb = new StringBuffer(); sb.append(rangeVariable.tableAlias.getStatementName()); sb.append('.'); sb.append(column.getName().statementName); return sb.toString(); } } case OpTypes.MULTICOLUMN: { if (nodes.length == 0) { return "*"; } StringBuffer sb = new StringBuffer(); for (int i = 0; i < nodes.length; i++) { Expression e = nodes[i]; if (i > 0) { sb.append(','); } String s = e.getSQL(); sb.append(s); } return sb.toString(); } default: throw Error.runtimeError(ErrorCode.U_S0500, "ExpressionColumn"); } }