use of org.hsqldb_voltpatches.VoltXMLElement in project voltdb by VoltDB.
the class AbstractParsedStmt method parseVectorExpression.
/**
* Parse a Vector value for SQL-IN
*/
private AbstractExpression parseVectorExpression(VoltXMLElement exprNode) {
ArrayList<AbstractExpression> args = new ArrayList<>();
for (VoltXMLElement argNode : exprNode.children) {
assert (argNode != null);
// recursively parse each argument subtree (could be any kind of expression).
AbstractExpression argExpr = parseExpressionNode(argNode);
assert (argExpr != null);
args.add(argExpr);
}
VectorValueExpression vve = new VectorValueExpression();
vve.setValueType(VoltType.VOLTTABLE);
vve.setArgs(args);
return vve;
}
use of org.hsqldb_voltpatches.VoltXMLElement in project voltdb by VoltDB.
the class TestDDLCompiler method testTooManyColumnTable.
//
// Note, this should succeed as HSQL doesn't have a hard limit
// on the number of columns. The test in TestVoltCompiler will
// fail on 1025 columns.
// @throws HSQLParseException
//
public void testTooManyColumnTable() throws IOException, HSQLParseException {
String schemaPath = "";
URL url = TestVoltCompiler.class.getResource("toowidetable-ddl.sql");
schemaPath = URLDecoder.decode(url.getPath(), "UTF-8");
FileReader fr = new FileReader(new File(schemaPath));
BufferedReader br = new BufferedReader(fr);
String ddl1 = "";
String line;
while ((line = br.readLine()) != null) {
ddl1 += line + "\n";
}
br.close();
HSQLInterface hsql = HSQLInterface.loadHsqldb();
hsql.runDDLCommand(ddl1);
VoltXMLElement xml = hsql.getXMLFromCatalog();
System.out.println(xml);
assertTrue(xml != null);
}
use of org.hsqldb_voltpatches.VoltXMLElement in project voltdb by VoltDB.
the class TestDDLCompiler method testSimpleDDLCompiler.
public void testSimpleDDLCompiler() throws HSQLParseException {
String ddl1 = "CREATE TABLE warehouse ( " + "w_id integer default '0' NOT NULL, " + "w_name varchar(16) default NULL, " + "w_street_1 varchar(32) default NULL, " + "w_street_2 varchar(32) default NULL, " + "w_city varchar(32) default NULL, " + "w_state varchar(2) default NULL, " + "w_zip varchar(9) default NULL, " + "w_tax float default NULL, " + "PRIMARY KEY (w_id) " + ");";
HSQLInterface hsql = HSQLInterface.loadHsqldb();
hsql.runDDLCommand(ddl1);
VoltXMLElement xml = hsql.getXMLFromCatalog();
System.out.println(xml);
assertTrue(xml != null);
}
use of org.hsqldb_voltpatches.VoltXMLElement in project voltdb by VoltDB.
the class VoltXMLElementHelper method buildLimitElements.
// Build VoltXMLElement for expression like "LIMIT 1".
public static List<VoltXMLElement> buildLimitElements(int limit, String limitValueElementId) {
if (limitValueElementId == null) {
return null;
}
List<VoltXMLElement> retval = new ArrayList<VoltXMLElement>();
retval.add(new VoltXMLElement("offset"));
VoltXMLElement limitElement = new VoltXMLElement("limit");
String strLimit = String.valueOf(limit);
limitElement.attributes.put("limit", strLimit);
limitElement.children.add(buildValueElement(limitValueElementId, false, strLimit, "BIGINT"));
retval.add(limitElement);
return retval;
}
use of org.hsqldb_voltpatches.VoltXMLElement in project voltdb by VoltDB.
the class DRTable method processStatement.
@Override
protected boolean processStatement(DDLStatement ddlStatement, Database db, DdlProceduresToLoad whichProcs) throws VoltCompilerException {
// matches if it is DR TABLE <table-name> [DISABLE]
// group 1 -- table name
// group 2 -- NULL: enable dr
// NOT NULL: disable dr
// TODO: maybe I should write one fit all regex for this.
Matcher statementMatcher = SQLParser.matchDRTable(ddlStatement.statement);
if (!statementMatcher.matches()) {
return false;
}
String tableName;
if (statementMatcher.group(1).equalsIgnoreCase("*")) {
tableName = "*";
} else {
tableName = checkIdentifierStart(statementMatcher.group(1), ddlStatement.statement);
}
//System.out.println("\n\n" + m_schema.toString());
VoltXMLElement tableXML = m_schema.findChild("table", tableName.toUpperCase());
if (tableXML != null) {
if (tableXML.attributes.containsKey("export")) {
throw m_compiler.new VoltCompilerException(String.format("Invalid DR statement: table %s is an export table", tableName));
} else {
if ((statementMatcher.group(2) != null)) {
tableXML.attributes.put("drTable", "DISABLE");
} else {
tableXML.attributes.put("drTable", "ENABLE");
}
}
} else {
throw m_compiler.new VoltCompilerException(String.format("While configuring dr, table %s was not present in the catalog.", tableName));
}
return true;
}
Aggregations