class YieldableMerSert extends YieldableLoopUpdateBase
            implements ResultTarget {

        final MerSert statement;
        final Table table;
        final int listSize;

        int index;
        YieldableBase<Result> yieldableQuery;

        public YieldableMerSert(MerSert statement, AsyncHandler<AsyncResult<Integer>> asyncHandler) {
            super(statement, asyncHandler);
            this.statement = statement;
            table = statement.table;
            listSize = statement.list.size();
        }

        @Override
        protected boolean startInternal() {
            statement.setCurrentRowNumber(0);
            if (statement.query != null) {
                yieldableQuery = statement.query.createYieldableQuery(0, false, null, this);
            }
            return false;
        }

        @Override
        protected void executeLoopUpdate() {
            if (table.containsLargeObject()) {
                DataHandler dh = session.getDataHandler();
                session.setDataHandler(table.getDataHandler()); // lob字段通过FILE_READ函数赋值时会用到
                try {
                    executeLoopUpdate0();
                } finally {
                    session.setDataHandler(dh);
                }
            } else {
                executeLoopUpdate0();
            }
        }

        private void executeLoopUpdate0() {
            if (yieldableQuery == null) {
                while (pendingException == null && index < listSize) {
                    merSert(createNewRow());
                    if (yieldIfNeeded(++index)) {
                        return;
                    }
                }
                onLoopEnd();
            } else {
                yieldableQuery.run();
                if (yieldableQuery.isStopped()) {
                    onLoopEnd();
                }
            }
        }

        protected Row createNewRow() {
            Row newRow = table.getTemplateRow(); // newRow的长度是全表字段的个数，会>=columns的长度
            Expression[] expr = statement.list.get(index);
            int columnLen = statement.columns.length;
            for (int i = 0; i < columnLen; i++) {
                Column c = statement.columns[i];
                int index = c.getColumnId(); // 从0开始
                Expression e = expr[i];
                if (e != null) {
                    // e can be null (DEFAULT)
                    e = e.optimize(session);
                    try {
                        Value v = c.convert(e.getValue(session));
                        newRow.setValue(index, v);
                    } catch (DbException ex) {
                        throw statement.setRow(ex, this.index + 1, getSQL(expr));
                    }
                }
            }
            return newRow;
        }

        protected Row createNewRow(Value[] values) {
            Row newRow = table.getTemplateRow();
            for (int i = 0, len = statement.columns.length; i < len; i++) {
                Column c = statement.columns[i];
                int index = c.getColumnId();
                try {
                    Value v = c.convert(values[i]);
                    newRow.setValue(index, v);
                } catch (DbException ex) {
                    throw statement.setRow(ex, updateCount.get() + 1, getSQL(values));
                }
            }
            return newRow;
        }

        protected void addRowInternal(Row newRow) {
            table.validateConvertUpdateSequence(session, newRow);
            boolean done = table.fireBeforeRow(session, null, newRow); // INSTEAD OF触发器会返回true
            if (!done) {
                onPendingOperationStart();
                table.addRow(session, newRow).onComplete(ar -> {
                    if (ar.isSucceeded()) {
                        try {
                            // 有可能抛出异常
                            table.fireAfterRow(session, null, newRow, false);
                        } catch (Throwable e) {
                            setPendingException(e);
                        }
                    }
                    onPendingOperationComplete(ar);
                });
            }
        }

        protected abstract void merSert(Row row);

        // 以下实现ResultTarget接口，可以在执行查询时，边查边增加新记录
        @Override
        public boolean addRow(Value[] values) {<FILL_FUNCTION_BODY>}

        @Override
        public int getRowCount() {
            return updateCount.get();
        }
    }

            merSert(createNewRow(values));
            if (yieldIfNeeded(updateCount.get() + 1)) {
                return true;
            }
            return false;
        
<methods>public void <init>(com.lealone.db.session.ServerSession) <variables>