try {
processed = processVoltDBStatement(stmt, db, whichProcs);
} catch (VoltCompilerException e) {
// Reformat the message thrown by VoltDB DDL processing to have a line number.
String msg = "VoltDB DDL Error: \"" + e.getMessage() + "\" in statement starting on lineno: " + stmt.lineNo;
throw m_compiler.new VoltCompilerException(msg);
}
if (!processed) {
try {
// Check for CREATE TABLE, CREATE VIEW, ALTER or DROP TABLE.
// We sometimes choke at parsing statements with newlines, so
// check against a newline free version of the stmt.
String oneLinerStmt = stmt.statement.replace("\n", " ");
Matcher tableMatcher = createTablePattern.matcher(oneLinerStmt);
if (tableMatcher.find()) {
String tableName = tableMatcher.group(2);
m_tableNameToDDL.put(tableName.toUpperCase(), stmt.statement);
} else {
Matcher atableMatcher = alterOrDropTablePattern.matcher(oneLinerStmt);
if (atableMatcher.find()) {
String op = atableMatcher.group(1);
String tableName = atableMatcher.group(3);
if (op.equalsIgnoreCase("DROP")) {
m_tableNameToDDL.remove(tableName.toUpperCase());
} else {
//ALTER - Append the statement
String prevStmt = m_tableNameToDDL.get(tableName.toUpperCase());
if (prevStmt != null) {
//Append the SQL for report...else would blow up compilation.
m_tableNameToDDL.put(tableName.toUpperCase(), prevStmt + "\n" + stmt.statement);
}
}
}
}
// kind of ugly. We hex-encode each statement so we can
// avoid embedded newlines so we can delimit statements
// with newline.
m_fullDDL += Encoder.hexEncode(stmt.statement) + "\n";
// Get the diff that results from applying this statement and apply it
// to our local tree (with Volt-specific additions)
VoltXMLDiff thisStmtDiff = m_hsql.runDDLCommandAndDiff(stmt.statement);
applyDiff(thisStmtDiff);
} catch (HSQLParseException e) {
String msg = "DDL Error: \"" + e.getMessage() + "\" in statement starting on lineno: " + stmt.lineNo;
throw m_compiler.new VoltCompilerException(msg, stmt.lineNo);
}
}
stmt = getNextStatement(reader, m_compiler);
}
try {
reader.close();
} catch (IOException e) {
throw m_compiler.new VoltCompilerException("Error closing schema file");
}
// process extra classes
m_tracker.addExtraClasses(m_classMatcher.getMatchedClassList());
// possibly save some memory