public void setValue(Value value) { this.value = value; expression = ValueExpression.get(value); }
@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; }
Function f = Function.getFunction(database, "ARRAY_GET"); f.setParameter(0, expression); f.setParameter(1, ValueExpression.get(ValueInt.get(i + 1))); f.doneWithParameters(); command.setAssignment(column, f);
@Override public Expression getNotIfPossible(Session session) { return new Comparison(session, Comparison.EQUAL, this, ValueExpression.get(ValueBoolean.FALSE)); }
return ValueExpression.get(getValue(session));
@Override public Expression getNotIfPossible(Session session) { return new Comparison(session, Comparison.EQUAL, this, ValueExpression.get(ValueBoolean.FALSE)); }
@Override public Expression getNotIfPossible(Session session) { return new Comparison(session, Comparison.EQUAL, this, ValueExpression.get(ValueBoolean.FALSE)); }
public void setInt(int value) { this.expression = ValueExpression.get(ValueInt.get(value)); }
private Table getDualTable(boolean noColumns) { Schema main = database.findSchema(Constants.SCHEMA_MAIN); Expression one = ValueExpression.get(ValueLong.get(1)); return new RangeTable(main, one, one, noColumns); }
@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; }
/** * 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 void createIndexConditions(Session session, TableFilter filter) { TableFilter tf = getTableFilter(); if (filter == tf && column.getType() == Value.BOOLEAN) { IndexCondition cond = IndexCondition.get( Comparison.EQUAL, this, ValueExpression.get( ValueBoolean.TRUE)); filter.addIndexCondition(cond); } }
@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; }
private Expression readWildcardOrSequenceValue(String schema, String objectName) { if (readIf("*")) { return new Wildcard(schema, objectName); } if (schema == null) { schema = session.getCurrentSchemaName(); } if (readIf("NEXTVAL")) { Sequence sequence = findSequence(schema, objectName); if (sequence != null) { return new SequenceValue(sequence); } } else if (readIf("CURRVAL")) { Sequence sequence = findSequence(schema, objectName); if (sequence != null) { Function function = Function.getFunction(database, "CURRVAL"); function.setParameter(0, ValueExpression.get(ValueString .get(sequence.getSchema().getName()))); function.setParameter(1, ValueExpression.get(ValueString .get(sequence.getName()))); function.doneWithParameters(); return function; } } return null; }
private CreateUser parseCreateUser() { CreateUser command = new CreateUser(session); command.setIfNotExists(readIfNotExists()); command.setUserName(readUniqueIdentifier()); command.setComment(readCommentIf()); if (readIf("PASSWORD")) { command.setPassword(readExpression()); } else if (readIf("SALT")) { command.setSalt(readExpression()); read("HASH"); command.setHash(readExpression()); } else if (readIf("IDENTIFIED")) { read("BY"); // uppercase if not quoted command.setPassword(ValueExpression.get(ValueString .get(readColumnIdentifier()))); } else { throw getSyntaxError(); } if (readIf("ADMIN")) { command.setAdmin(true); } return command; }
command.setCycle(false); } else if (readIf("CACHE")) { command.setCacheSize(ValueExpression.get(ValueLong.get(1))); } else { break; command.setCacheSize(readExpression()); } else if (readIf("NOCACHE")) { command.setCacheSize(ValueExpression.get(ValueLong.get(1))); } else if (readIf("BELONGS_TO_TABLE")) { command.setBelongsToTable(true);