class RunScript extends ScriptBase {

    /**
     * The byte order mark.
     * 0xfeff because this is the Unicode char
     * represented by the UTF-8 byte order mark (EF BB BF).
     */
    private static final char UTF8_BOM = '\uFEFF';

    private Charset charset = Constants.UTF8;

    public RunScript(ServerSession session) {
        super(session);
    }

    @Override
    public int getType() {
        return SQLStatement.RUNSCRIPT;
    }

    public void setCharset(Charset charset) {
        this.charset = charset;
    }

    @Override
    public int update() {<FILL_FUNCTION_BODY>}

    private void execute(String sql) {
        try {
            StatementBase command = (StatementBase) session.prepareStatement(sql);
            if (command.isQuery()) {
                command.query(0);
            } else {
                command.update();
            }
            if (session.isAutoCommit()) {
                session.commit();
            }
        } catch (DbException e) {
            throw e.addSQL(sql);
        }
    }
}

        session.getUser().checkAdmin();
        int count = 0;
        try {
            openInput();
            BufferedReader reader = new BufferedReader(new InputStreamReader(in, charset));
            // if necessary, strip the BOM from the front of the file
            reader.mark(1);
            if (reader.read() != UTF8_BOM) {
                reader.reset();
            }
            ScriptReader r = new ScriptReader(reader);
            while (true) {
                String sql = r.readStatement();
                if (sql == null) {
                    break;
                }
                execute(sql);
                count++;
                if ((count & 127) == 0) {
                    checkCanceled();
                }
            }
            reader.close();
        } catch (IOException e) {
            throw DbException.convertIOException(e, null);
        } finally {
            closeIO();
        }
        return count;
    
<methods>public void <init>(com.lealone.db.session.ServerSession) ,public boolean needRecompile() ,public void setCipher(java.lang.String) ,public void setCompressionAlgorithm(java.lang.String) ,public void setFileNameExpr(com.lealone.sql.expression.Expression) ,public void setPassword(com.lealone.sql.expression.Expression) <variables>private static final java.lang.String SCRIPT_SQL,private java.lang.String cipher,private java.lang.String compressionAlgorithm,private java.lang.String fileName,private com.lealone.sql.expression.Expression fileNameExpr,private com.lealone.storage.fs.FileStorage fileStorage,protected java.io.InputStream in,protected java.io.OutputStream out,private com.lealone.sql.expression.Expression password