ServerSession server,
Store givenStore) {
final ChangeLevel changeLevel = commonChangeLevel(changeSets);
final Schema newSchema = SchemaCache.globalSchema(newAIS);
Plannable deletePlan = null;
Plannable insertPlan = null;
for(ChangeSet cs : changeSets) {
if(cs.hasSelectStatement()) {
SQLParser parser = server.getParser();
StatementNode insertStmt;
try {
insertStmt = parser.parseStatement("insert into " + newAIS.getTable(cs.getToTableId()).getName().toStringEscaped() + " " + cs.getSelectStatement());
} catch (StandardException e) {
throw new SQLParserInternalException(e);
}
StoreAdapter adapter = givenStore.createAdapter(session, SchemaCache.globalSchema(newAIS));
CreateAsCompiler compiler = new CreateAsCompiler(server, adapter, true, newAIS);
PlanContext planContext = new PlanContext(compiler);
BasePlannable insertResult = compiler.compile((DMLStatementNode) insertStmt, null, planContext);
insertPlan = insertResult.getPlannable();
deletePlan = new Delete_Returning(insertPlan.getInputOperators().iterator().next(), false);
}
int tableID = cs.getTableId();
TableRowType newType = newSchema.tableRowType(tableID);
TableTransform transform = buildTableTransform(cs, changeLevel, oldAIS, newType, typesRegistry,
typesTranslator, (Operator)deletePlan, (Operator)insertPlan);