提交 c70f75bd authored 作者: Thomas Mueller's avatar Thomas Mueller

support BOOL_OR and BOOL_AND

上级 c11b7c64
...@@ -97,8 +97,20 @@ public class Aggregate extends Expression { ...@@ -97,8 +97,20 @@ public class Aggregate extends Expression {
* The aggregate type for VAR_SAMP(expression). * The aggregate type for VAR_SAMP(expression).
*/ */
public static final int VAR_SAMP = 10; public static final int VAR_SAMP = 10;
public static final int SOME = 11;
public static final int EVERY = 12; /**
* The aggregate type for BOOL_OR(expression).
*/
public static final int BOOL_OR = 11;
/**
* The aggregate type for BOOL_AND(expression).
*/
public static final int BOOL_AND = 12;
/**
* The aggregate type for SELECTIVITY(expression).
*/
public static final int SELECTIVITY = 13; public static final int SELECTIVITY = 13;
private final Database database; private final Database database;
...@@ -116,6 +128,15 @@ public class Aggregate extends Expression { ...@@ -116,6 +128,15 @@ public class Aggregate extends Expression {
private static final HashMap AGGREGATES = new HashMap(); private static final HashMap AGGREGATES = new HashMap();
/**
* Create a new aggregate object.
*
* @param database the database
* @param type the aggregate type
* @param on the aggregated expression
* @param select the select statement
* @param distinct if distinct is used
*/
public Aggregate(Database database, int type, Expression on, Select select, boolean distinct) { public Aggregate(Database database, int type, Expression on, Select select, boolean distinct) {
this.database = database; this.database = database;
this.type = type; this.type = type;
...@@ -140,8 +161,12 @@ public class Aggregate extends Expression { ...@@ -140,8 +161,12 @@ public class Aggregate extends Expression {
addAggregate("VAR_SAMP", VAR_SAMP); addAggregate("VAR_SAMP", VAR_SAMP);
addAggregate("VAR", VAR_SAMP); addAggregate("VAR", VAR_SAMP);
addAggregate("VARIANCE", VAR_SAMP); addAggregate("VARIANCE", VAR_SAMP);
addAggregate("SOME", SOME); addAggregate("BOOL_OR", BOOL_OR);
addAggregate("EVERY", EVERY); // HSQLDB compatibility, but conflicts with >EVERY(...)
addAggregate("SOME", BOOL_OR);
addAggregate("BOOL_AND", BOOL_AND);
// HSQLDB compatibility, but conflicts with >SOME(...)
addAggregate("EVERY", BOOL_AND);
addAggregate("SELECTIVITY", SELECTIVITY); addAggregate("SELECTIVITY", SELECTIVITY);
} }
...@@ -161,10 +186,20 @@ public class Aggregate extends Expression { ...@@ -161,10 +186,20 @@ public class Aggregate extends Expression {
return type == null ? -1 : type.intValue(); return type == null ? -1 : type.intValue();
} }
/**
* Set the order for GROUP_CONCAT.
*
* @param orderBy the order by list
*/
public void setOrder(ObjectArray orderBy) { public void setOrder(ObjectArray orderBy) {
this.orderList = orderBy; this.orderList = orderBy;
} }
/**
* Set the separator for GROUP_CONCAT.
*
* @param separator the separator expression
*/
public void setSeparator(Expression separator) { public void setSeparator(Expression separator) {
this.separator = separator; this.separator = separator;
} }
...@@ -371,8 +406,8 @@ public class Aggregate extends Expression { ...@@ -371,8 +406,8 @@ public class Aggregate extends Expression {
displaySize = ValueDouble.DISPLAY_SIZE; displaySize = ValueDouble.DISPLAY_SIZE;
scale = 0; scale = 0;
break; break;
case EVERY: case BOOL_AND:
case SOME: case BOOL_OR:
dataType = Value.BOOLEAN; dataType = Value.BOOLEAN;
precision = ValueBoolean.PRECISION; precision = ValueBoolean.PRECISION;
displaySize = ValueBoolean.DISPLAY_SIZE; displaySize = ValueBoolean.DISPLAY_SIZE;
...@@ -470,11 +505,11 @@ public class Aggregate extends Expression { ...@@ -470,11 +505,11 @@ public class Aggregate extends Expression {
case VAR_SAMP: case VAR_SAMP:
text = "VAR_SAMP"; text = "VAR_SAMP";
break; break;
case EVERY: case BOOL_AND:
text = "EVERY"; text = "BOOL_AND";
break; break;
case SOME: case BOOL_OR:
text = "SOME"; text = "BOOL_OR";
break; break;
default: default:
throw Message.getInternalError("type=" + type); throw Message.getInternalError("type=" + type);
......
...@@ -108,7 +108,7 @@ public class AggregateData { ...@@ -108,7 +108,7 @@ public class AggregateData {
} }
break; break;
} }
case Aggregate.EVERY: case Aggregate.BOOL_AND:
v = v.convertTo(Value.BOOLEAN); v = v.convertTo(Value.BOOLEAN);
if (value == null) { if (value == null) {
value = v; value = v;
...@@ -116,7 +116,7 @@ public class AggregateData { ...@@ -116,7 +116,7 @@ public class AggregateData {
value = ValueBoolean.get(value.getBoolean().booleanValue() && v.getBoolean().booleanValue()); value = ValueBoolean.get(value.getBoolean().booleanValue() && v.getBoolean().booleanValue());
} }
break; break;
case Aggregate.SOME: case Aggregate.BOOL_OR:
v = v.convertTo(Value.BOOLEAN); v = v.convertTo(Value.BOOLEAN);
if (value == null) { if (value == null) {
value = v; value = v;
...@@ -160,8 +160,8 @@ public class AggregateData { ...@@ -160,8 +160,8 @@ public class AggregateData {
case Aggregate.SUM: case Aggregate.SUM:
case Aggregate.MIN: case Aggregate.MIN:
case Aggregate.MAX: case Aggregate.MAX:
case Aggregate.SOME: case Aggregate.BOOL_OR:
case Aggregate.EVERY: case Aggregate.BOOL_AND:
v = value; v = value;
break; break;
case Aggregate.AVG: case Aggregate.AVG:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论