@Override public Expression optimize(Session session) { left = left.optimize(session); if (left.isConstant() && left == ValueExpression.getNull()) { return left; } return this; }
/** * Add an additional element if possible. Example: given two conditions * A IN(1, 2) OR A=3, the constant 3 is added: A IN(1, 2, 3). * * @param session the session * @param other the second condition * @return null if the condition was not added, or the new condition */ Expression getAdditional(Session session, Comparison other) { Expression add = other.getIfEquals(left); if (add != null) { if (add.isConstant()) { valueList.add(add); valueSet.add(add.getValue(session).convertTo(left.getType())); return this; } } return null; } }
@Override public Expression optimize(Session session) { boolean allConst = true; for (int i = 0; i < list.length; i++) { Expression e = list[i].optimize(session); if (!e.isConstant()) { allConst = false; } list[i] = e; } if (allConst) { return ValueExpression.get(getValue(session)); } return this; }
/** * Get the column for the given table filter, if the sort column is for this * filter. * * @param index the column index (0, 1,..) * @param filter the table filter * @return the column, or null */ public Column getColumn(int index, TableFilter filter) { if (orderList == null) { return null; } SelectOrderBy order = orderList.get(index); Expression expr = order.expression; if (expr == null) { return null; } expr = expr.getNonAliasExpression(); if (expr.isConstant()) { return null; } if (!(expr instanceof ExpressionColumn)) { return null; } ExpressionColumn exprCol = (ExpressionColumn) expr; if (exprCol.getTableFilter() != filter) { return null; } return exprCol.getColumn(); }
boolean lc = left.isConstant(); boolean rc = right.isConstant(); boolean l2c = other.left.isConstant(); boolean r2c = other.right.isConstant(); String l = left.getSQL(); String l2 = other.left.getSQL();
/** * Set the on update expression. * * @param session the session * @param onUpdateExpression the on update expression */ public void setOnUpdateExpression(Session session, Expression onUpdateExpression) { // also to test that no column names are used if (onUpdateExpression != null) { onUpdateExpression = onUpdateExpression.optimize(session); if (onUpdateExpression.isConstant()) { onUpdateExpression = ValueExpression.get(onUpdateExpression.getValue(session)); } } this.onUpdateExpression = onUpdateExpression; }
/** * Set the default expression. * * @param session the session * @param defaultExpression the default expression */ public void setDefaultExpression(Session session, Expression defaultExpression) { // also to test that no column names are used if (defaultExpression != null) { defaultExpression = defaultExpression.optimize(session); if (defaultExpression.isConstant()) { defaultExpression = ValueExpression.get( defaultExpression.getValue(session)); } } this.defaultExpression = defaultExpression; }
@Override public Expression optimize(Session session) { boolean allConst = isDeterministic(); for (int i = 0, len = args.length; i < len; i++) { Expression e = args[i].optimize(session); args[i] = e; allConst &= e.isConstant(); } if (allConst) { return ValueExpression.get(getValue(session)); } return this; }
@Override public Expression optimize(Session session) { left = left.optimize(session); boolean constant = left.isConstant(); if (constant && left == ValueExpression.getNull()) { return left; Expression e = valueList.get(i); e = e.optimize(session); if (e.isConstant() && e.getValue(session) != ValueNull.INSTANCE) { allValuesNull = false; if (allValuesConstant && !e.isConstant()) { allValuesConstant = false;
@Override public Expression optimize(Session session) { Expression e2 = condition.getNotIfPossible(session); if (e2 != null) { return e2.optimize(session); } Expression expr = condition.optimize(session); if (expr.isConstant()) { Value v = expr.getValue(session); if (v == ValueNull.INSTANCE) { return ValueExpression.getNull(); } return ValueExpression.get(v.convertTo(Value.BOOLEAN).negate()); } condition = expr; return this; }
right = right.optimize(session); if (right instanceof ExpressionColumn) { if (left.isConstant() || left instanceof Parameter) { Expression temp = left; left = right; if (right.isConstant()) { Value r = right.getValue(session); if (r == ValueNull.INSTANCE) { if (left.isConstant()) { return ValueExpression.get(getValue(session)); if (left.isConstant() && right.isConstant()) { return ValueExpression.get(getValue(session));
if (expr.isConstant()) { continue;
if (!e.isConstant()) { allConst = false; p = args[0].getPrecision(); s = 0; if (args[1].isConstant()) { if (args.length == 3 && args[2].isConstant()) {
Value l = left.isConstant() ? left.getValue(session) : null; Value r = right.isConstant() ? right.getValue(session) : null; if (l == null && r == null) { return this;
right = right.optimize(session); dataType = Value.STRING; if (left.isConstant() && right.isConstant()) { return ValueExpression.get(getValue(session)); DbException.throwInternalError("type=" + opType); if (left.isConstant() && (right == null || right.isConstant())) { return ValueExpression.get(getValue(session));
if (!col.getDefaultExpression().isConstant()) { throw new IgniteSQLException("Non-constant DEFAULT expressions are not supported [colName=" + col.getName() + ']', IgniteQueryErrorCode.UNSUPPORTED_OPERATION);
public void setDefaultExpression(Session session, Expression defaultExpression) throws SQLException { // also to test that no column names are used if (defaultExpression != null) { defaultExpression = defaultExpression.optimize(session); if (defaultExpression.isConstant()) { defaultExpression = ValueExpression.get(defaultExpression.getValue(session)); } } this.defaultExpression = defaultExpression; }
public Expression optimize(Session session) throws SQLException { boolean allConst = true; for (int i = 0; i < list.length; i++) { Expression e = list[i].optimize(session); if (!e.isConstant()) { allConst = false; } list[i] = e; } if (allConst) { return ValueExpression.get(getValue(session)); } return this; }
@Override public Expression optimize(Session session) { boolean allConst = isDeterministic(); for (int i = 0, len = args.length; i < len; i++) { Expression e = args[i].optimize(session); args[i] = e; allConst &= e.isConstant(); } if (allConst) { return ValueExpression.get(getValue(session)); } return this; }
@Override public Expression optimize(Session session) { boolean allConst = isDeterministic(); for (int i = 0, len = args.length; i < len; i++) { Expression e = args[i].optimize(session); args[i] = e; allConst &= e.isConstant(); } if (allConst) { return ValueExpression.get(getValue(session)); } return this; }