use of org.hsqldb_voltpatches.VoltXMLElement in project voltdb by VoltDB.
the class ReplicateTable method processStatement.
@Override
protected boolean processStatement(DDLStatement ddlStatement, Database db, DdlProceduresToLoad whichProcs) throws VoltCompilerException {
// matches if it is REPLICATE TABLE <table-name>
Matcher statementMatcher = SQLParser.matchReplicateTable(ddlStatement.statement);
if (!statementMatcher.matches()) {
return false;
}
// group(1) -> table
String tableName = checkIdentifierStart(statementMatcher.group(1), ddlStatement.statement);
VoltXMLElement tableXML = m_schema.findChild("table", tableName.toUpperCase());
if (tableXML != null) {
tableXML.attributes.remove("partitioncolumn");
// mark the table as dirty for the purposes of caching sql statements
m_compiler.markTableAsDirty(tableName);
} else {
throw m_compiler.new VoltCompilerException(String.format("Invalid REPLICATE statement: table %s does not exist", tableName));
}
return true;
}
use of org.hsqldb_voltpatches.VoltXMLElement in project voltdb by VoltDB.
the class AbstractParsedStmt method parseParameters.
/**
* Populate the statement's paramList from the "parameters" element. Each
* parameter has an id and an index, both of which are numeric. It also has
* a type and an indication of whether it's a vector parameter. For each
* parameter, we create a ParameterValueExpression, named pve, which holds
* the type and vector parameter indication. We add the pve to two maps,
* m_paramsById and m_paramsByIndex.
*
* We also set a counter, MAX_PARAMETER_ID, to the largest id in the
* expression. This helps give ids to references to correlated expressions
* of subqueries.
*
* @param paramsNode
*/
protected void parseParameters(VoltXMLElement root) {
VoltXMLElement paramsNode = null;
for (VoltXMLElement node : root.children) {
if (node.name.equalsIgnoreCase("parameters")) {
paramsNode = node;
break;
}
}
if (paramsNode == null) {
return;
}
long max_parameter_id = -1;
for (VoltXMLElement node : paramsNode.children) {
if (node.name.equalsIgnoreCase("parameter")) {
long id = Long.parseLong(node.attributes.get("id"));
int index = Integer.parseInt(node.attributes.get("index"));
if (index > max_parameter_id) {
max_parameter_id = index;
}
String typeName = node.attributes.get("valuetype");
String isVectorParam = node.attributes.get("isvector");
VoltType type = VoltType.typeFromString(typeName);
ParameterValueExpression pve = new ParameterValueExpression();
pve.setParameterIndex(index);
pve.setValueType(type);
if (isVectorParam != null && isVectorParam.equalsIgnoreCase("true")) {
pve.setParamIsVector();
}
m_paramsById.put(id, pve);
m_paramsByIndex.put(index, pve);
}
}
if (max_parameter_id >= NEXT_PARAMETER_ID) {
NEXT_PARAMETER_ID = (int) max_parameter_id + 1;
}
}
use of org.hsqldb_voltpatches.VoltXMLElement in project voltdb by VoltDB.
the class AbstractParsedStmt method limitPlanNodeFromXml.
/**
* Produce a LimitPlanNode from the given XML
* @param limitXml Volt XML for limit
* @param offsetXml Volt XML for offset
* @return An instance of LimitPlanNode for the given XML
*/
LimitPlanNode limitPlanNodeFromXml(VoltXMLElement limitXml, VoltXMLElement offsetXml) {
if (limitXml == null && offsetXml == null) {
return null;
}
String node;
long limitParameterId = -1;
long offsetParameterId = -1;
long limit = -1;
long offset = 0;
if (limitXml != null) {
// Parse limit
if ((node = limitXml.attributes.get("limit_paramid")) != null) {
limitParameterId = Long.parseLong(node);
} else {
assert (limitXml.children.size() == 1);
VoltXMLElement valueNode = limitXml.children.get(0);
String isParam = valueNode.attributes.get("isparam");
if ((isParam != null) && (isParam.equalsIgnoreCase("true"))) {
limitParameterId = Long.parseLong(valueNode.attributes.get("id"));
} else {
node = limitXml.attributes.get("limit");
assert (node != null);
limit = Long.parseLong(node);
}
}
}
if (offsetXml != null) {
// Parse offset
if ((node = offsetXml.attributes.get("offset_paramid")) != null) {
offsetParameterId = Long.parseLong(node);
} else {
if (offsetXml.children.size() == 1) {
VoltXMLElement valueNode = offsetXml.children.get(0);
String isParam = valueNode.attributes.get("isparam");
if ((isParam != null) && (isParam.equalsIgnoreCase("true"))) {
offsetParameterId = Long.parseLong(valueNode.attributes.get("id"));
} else {
node = offsetXml.attributes.get("offset");
assert (node != null);
offset = Long.parseLong(node);
}
}
}
}
// limit and offset can't have both value and parameter
if (limit != -1)
assert limitParameterId == -1 : "Parsed value and param. limit.";
if (offset != 0)
assert offsetParameterId == -1 : "Parsed value and param. offset.";
LimitPlanNode limitPlanNode = new LimitPlanNode();
limitPlanNode.setLimit((int) limit);
limitPlanNode.setOffset((int) offset);
limitPlanNode.setLimitParameterIndex(parameterCountIndexById(limitParameterId));
limitPlanNode.setOffsetParameterIndex(parameterCountIndexById(offsetParameterId));
return limitPlanNode;
}
use of org.hsqldb_voltpatches.VoltXMLElement in project voltdb by VoltDB.
the class AbstractParsedStmt method parseTableCondition.
/** Parse a where or join clause. This behavior is common to all kinds of statements.
*/
private AbstractExpression parseTableCondition(VoltXMLElement tableScan, String joinOrWhere) {
AbstractExpression condExpr = null;
for (VoltXMLElement childNode : tableScan.children) {
if (!childNode.name.equalsIgnoreCase(joinOrWhere)) {
continue;
}
assert (childNode.children.size() == 1);
assert (condExpr == null);
condExpr = parseConditionTree(childNode.children.get(0));
assert (condExpr != null);
ExpressionUtil.finalizeValueTypes(condExpr);
condExpr = ExpressionUtil.evaluateExpression(condExpr);
// If the condition is a trivial CVE(TRUE) (after the evaluation) simply drop it
if (ConstantValueExpression.isBooleanTrue(condExpr)) {
condExpr = null;
}
}
return condExpr;
}
use of org.hsqldb_voltpatches.VoltXMLElement in project voltdb by VoltDB.
the class AbstractParsedStmt method parseRowExpression.
/**
*
* @param exprNode
* @return
*/
private AbstractExpression parseRowExpression(List<VoltXMLElement> exprNodes) {
// Parse individual columnref expressions from the IN output schema
List<AbstractExpression> exprs = new ArrayList<>();
for (VoltXMLElement exprNode : exprNodes) {
AbstractExpression expr = parseExpressionNode(exprNode);
exprs.add(expr);
}
return new RowSubqueryExpression(exprs);
}
Aggregations