@Override public int getType() { return expr.getType(); }
@Override public int getColumnType(int i) { return expressions[i].getType(); }
@Override public void prepare() { expression = expression.optimize(session); expressions = new Expression[]{expression}; isResultSet = expression.getType() == Value.RESULT_SET; if (isResultSet) { prepareAlways = true; } }
@Override public int getType() { return getExpression().getType(); }
private Value[] convert(Value[] values, int columnCount) { Value[] newValues; if (columnCount == values.length) { // re-use the array if possible newValues = values; } else { // create a new array if needed, // for the value hash set newValues = new Value[columnCount]; } for (int i = 0; i < columnCount; i++) { Expression e = expressions.get(i); newValues[i] = values[i].convertTo(e.getType()); } return newValues; }
/** * Create a new IN(..) condition. * * @param session the session * @param left the expression before IN * @param valueList the value list (at least two elements) */ public ConditionInConstantSet(final Session session, Expression left, ArrayList<Expression> valueList) { this.left = left; this.valueList = valueList; this.valueSet = new TreeSet<Value>(new Comparator<Value>() { @Override public int compare(Value o1, Value o2) { return session.getDatabase().compare(o1, o2); } }); int type = left.getType(); for (Expression expression : valueList) { valueSet.add(expression.getValue(session).convertTo(type)); } }
/** * 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 Row get() { if (current == null) { current = createRow(); for (int i = 0; i < current.getColumnCount(); i++) { Value v = DataType.readValue(rs, i + 1, cols[i].getType()); current.setValue(i, v); } } return current; }
@Override public Expression[] getExpressionColumns(Session session) { ExpressionColumn[] expr = new ExpressionColumn[list.length]; for (int i = 0; i < list.length; i++) { Expression e = list[i]; Column col = new Column("C" + (i + 1), e.getType(), e.getPrecision(), e.getScale(), e.getDisplaySize()); expr[i] = new ExpressionColumn(session.getDatabase(), col); } return expr; }
for (Expression e : args) { if (e != ValueExpression.getNull()) { int type = e.getType(); if (type != Value.UNKNOWN && type != Value.NULL) { t = Value.getHigherOrder(t, type); Expression then = args[i]; if (then != ValueExpression.getNull()) { int type = then.getType(); if (type != Value.UNKNOWN && type != Value.NULL) { t = Value.getHigherOrder(t, type); Expression elsePart = args[args.length - 1]; if (elsePart != ValueExpression.getNull()) { int type = elsePart.getType(); if (type != Value.UNKNOWN && type != Value.NULL) { t = Value.getHigherOrder(t, type); t = Value.getHigherOrder(args[1].getType(), args[2].getType()); p = Math.max(args[1].getPrecision(), args[2].getPrecision()); d = Math.max(args[1].getDisplaySize(), args[2].getDisplaySize()); break; case NVL2: switch (args[1].getType()) { case Value.STRING: case Value.CLOB: case Value.STRING_FIXED: case Value.STRING_IGNORECASE:
Expression expr = readExpression(); expr = expr.optimize(session); int type = expr.getType(); long prec; int scale, displaySize;
int leftType = left.getType(); if (leftType == Value.UNKNOWN) { return this;
private void generateColumnsFromQuery() { int columnCount = prepared.getQuery().getColumnCount(); ArrayList<Expression> expressions = prepared.getQuery().getExpressions(); for (int i = 0; i < columnCount; i++) { Expression expr = expressions.get(i); int type = expr.getType(); String name = expr.getAlias(); long precision = expr.getPrecision(); int displaySize = expr.getDisplaySize(); DataType dt = DataType.getDataType(type); if (precision > 0 && (dt.defaultPrecision == 0 || (dt.defaultPrecision > precision && dt.defaultPrecision < Byte.MAX_VALUE))) { // dont' set precision to MAX_VALUE if this is the default precision = dt.defaultPrecision; } int scale = expr.getScale(); if (scale > 0 && (dt.defaultScale == 0 || (dt.defaultScale > scale && dt.defaultScale < precision))) { scale = dt.defaultScale; } if (scale > precision) { precision = scale; } Column col = new Column(name, type, precision, scale, displaySize); prepared.addColumn(col); } }
name = expr.getAlias(); int type = expr.getType(); long precision = expr.getPrecision(); int scale = expr.getScale();
if (on != null) { on = on.optimize(session); dataType = on.getType(); scale = on.getScale(); precision = on.getPrecision();
left = left.optimize(session); right = right.optimize(session); if (left.getType() == Value.STRING_IGNORECASE) { ignoreCase = true;
switch (opType) { case NEGATE: dataType = left.getType(); if (dataType == Value.UNKNOWN) { dataType = Value.DECIMAL; case MODULUS: right = right.optimize(session); int l = left.getType(); int r = right.getType(); if ((l == Value.NULL && r == Value.NULL) || (l == Value.UNKNOWN && r == Value.UNKNOWN)) {
Expression expr = readExpression(); if (canBeNumber && expr instanceof ValueExpression && expr.getType() == Value.INT) { order.columnIndexExpr = expr; } else if (expr instanceof Parameter) {