Search in sources :

Example 1 with MycatUpdateRel

use of io.mycat.calcite.physical.MycatUpdateRel in project Mycat2 by MyCATApache.

the class DrdsSqlCompiler method complieNormalUpdate.

@NotNull
private MycatRel complieNormalUpdate(OptimizationContext optimizationContext, DrdsSql drdsSql, SQLStatement sqlStatement, NormalTable logicTable) {
    MycatUpdateRel mycatUpdateRel = new MycatUpdateRel(sqlStatement);
    optimizationContext.saveAlways();
    return mycatUpdateRel;
}
Also used : MycatUpdateRel(io.mycat.calcite.physical.MycatUpdateRel) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with MycatUpdateRel

use of io.mycat.calcite.physical.MycatUpdateRel in project Mycat2 by MyCATApache.

the class ObservablePlanImplementorImpl method executeUpdate.

@Override
public Future<Void> executeUpdate(Plan plan) {
    MycatUpdateRel mycatRel = (MycatUpdateRel) plan.getMycatRel();
    Collection<VertxExecuter.EachSQL> eachSQLS = VertxUpdateExecuter.explainUpdate(drdsSqlWithParams, context);
    Future<long[]> future = VertxExecuter.simpleUpdate(context, mycatRel.isInsert(), true, mycatRel.isGlobal(), eachSQLS);
    return future.eventually(u -> context.getTransactionSession().closeStatementState()).flatMap(result -> response.sendOk(result[0], result[1]));
}
Also used : VertxExecuter(io.mycat.vertx.VertxExecuter) Logger(org.slf4j.Logger) io.mycat(io.mycat) VertxUpdateExecuter(io.mycat.vertx.VertxUpdateExecuter) Collection(java.util.Collection) SQLInsertStatement(com.alibaba.druid.sql.ast.statement.SQLInsertStatement) ExecutorProvider(io.mycat.calcite.ExecutorProvider) LoggerFactory(org.slf4j.LoggerFactory) Future(io.vertx.core.Future) MycatUpdateRel(io.mycat.calcite.physical.MycatUpdateRel) ArrayBindable(org.apache.calcite.runtime.ArrayBindable) TimeUnit(java.util.concurrent.TimeUnit) MycatInsertRel(io.mycat.calcite.physical.MycatInsertRel) TimeRateLimiterService(io.mycat.ratelimiter.TimeRateLimiterService) List(java.util.List) PrepareExecutor(io.mycat.calcite.PrepareExecutor) MysqlPayloadObject(io.mycat.api.collector.MysqlPayloadObject) Observable(io.reactivex.rxjava3.core.Observable) XaSqlConnection(cn.mycat.vertx.xa.XaSqlConnection) Optional(java.util.Optional) Plan(io.mycat.calcite.spm.Plan) MycatUpdateRel(io.mycat.calcite.physical.MycatUpdateRel)

Example 3 with MycatUpdateRel

use of io.mycat.calcite.physical.MycatUpdateRel in project Mycat2 by MyCATApache.

the class DrdsSqlCompiler method compileUpdate.

private MycatRel compileUpdate(TableHandler logicTable, OptimizationContext optimizationContext, DrdsSql drdsSql, SchemaPlus plus) {
    MycatUpdateRel mycatUpdateRel = new MycatUpdateRel(drdsSql.getParameterizedStatement());
    optimizationContext.saveAlways();
    return mycatUpdateRel;
}
Also used : MycatUpdateRel(io.mycat.calcite.physical.MycatUpdateRel)

Example 4 with MycatUpdateRel

use of io.mycat.calcite.physical.MycatUpdateRel in project Mycat2 by MyCATApache.

the class DrdsSqlCompiler method compileDelete.

private MycatRel compileDelete(TableHandler logicTable, OptimizationContext optimizationContext, DrdsSql drdsSql, SchemaPlus plus) {
    MycatUpdateRel mycatUpdateRel = new MycatUpdateRel(drdsSql.getParameterizedStatement());
    optimizationContext.saveAlways();
    return mycatUpdateRel;
}
Also used : MycatUpdateRel(io.mycat.calcite.physical.MycatUpdateRel)

Example 5 with MycatUpdateRel

use of io.mycat.calcite.physical.MycatUpdateRel in project Mycat2 by MyCATApache.

the class DrdsSqlCompiler method complieGlobalUpdate.

@NotNull
private MycatRel complieGlobalUpdate(OptimizationContext optimizationContext, DrdsSql drdsSql, SQLStatement sqlStatement, GlobalTable logicTable) {
    MycatUpdateRel mycatUpdateRel = new MycatUpdateRel(sqlStatement, true);
    optimizationContext.saveAlways();
    return mycatUpdateRel;
}
Also used : MycatUpdateRel(io.mycat.calcite.physical.MycatUpdateRel) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

MycatUpdateRel (io.mycat.calcite.physical.MycatUpdateRel)5 NotNull (org.jetbrains.annotations.NotNull)2 XaSqlConnection (cn.mycat.vertx.xa.XaSqlConnection)1 SQLInsertStatement (com.alibaba.druid.sql.ast.statement.SQLInsertStatement)1 io.mycat (io.mycat)1 MysqlPayloadObject (io.mycat.api.collector.MysqlPayloadObject)1 ExecutorProvider (io.mycat.calcite.ExecutorProvider)1 PrepareExecutor (io.mycat.calcite.PrepareExecutor)1 MycatInsertRel (io.mycat.calcite.physical.MycatInsertRel)1 Plan (io.mycat.calcite.spm.Plan)1 TimeRateLimiterService (io.mycat.ratelimiter.TimeRateLimiterService)1 VertxExecuter (io.mycat.vertx.VertxExecuter)1 VertxUpdateExecuter (io.mycat.vertx.VertxUpdateExecuter)1 Observable (io.reactivex.rxjava3.core.Observable)1 Future (io.vertx.core.Future)1 Collection (java.util.Collection)1 List (java.util.List)1 Optional (java.util.Optional)1 TimeUnit (java.util.concurrent.TimeUnit)1 ArrayBindable (org.apache.calcite.runtime.ArrayBindable)1