Search in sources :

Example 1 with ScriptCommand

use of org.h2.command.dml.ScriptCommand in project h2database by h2database.

the class Parser method parseScript.

private ScriptCommand parseScript() {
    ScriptCommand command = new ScriptCommand(session);
    boolean data = true, passwords = true, settings = true;
    boolean dropTables = false, simple = false;
    if (readIf("SIMPLE")) {
        simple = true;
    }
    if (readIf("NODATA")) {
        data = false;
    }
    if (readIf("NOPASSWORDS")) {
        passwords = false;
    }
    if (readIf("NOSETTINGS")) {
        settings = false;
    }
    if (readIf("DROP")) {
        dropTables = true;
    }
    if (readIf("BLOCKSIZE")) {
        long blockSize = readLong();
        command.setLobBlockSize(blockSize);
    }
    command.setData(data);
    command.setPasswords(passwords);
    command.setSettings(settings);
    command.setDrop(dropTables);
    command.setSimple(simple);
    if (readIf("TO")) {
        command.setFileNameExpr(readExpression());
        if (readIf("COMPRESSION")) {
            command.setCompressionAlgorithm(readUniqueIdentifier());
        }
        if (readIf("CIPHER")) {
            command.setCipher(readUniqueIdentifier());
            if (readIf("PASSWORD")) {
                command.setPassword(readExpression());
            }
        }
        if (readIf("CHARSET")) {
            command.setCharset(Charset.forName(readString()));
        }
    }
    if (readIf("SCHEMA")) {
        HashSet<String> schemaNames = new HashSet<>();
        do {
            schemaNames.add(readUniqueIdentifier());
        } while (readIf(","));
        command.setSchemaNames(schemaNames);
    } else if (readIf("TABLE")) {
        ArrayList<Table> tables = New.arrayList();
        do {
            tables.add(readTableOrView());
        } while (readIf(","));
        command.setTables(tables);
    }
    return command;
}
Also used : ArrayList(java.util.ArrayList) ValueString(org.h2.value.ValueString) RunScriptCommand(org.h2.command.dml.RunScriptCommand) ScriptCommand(org.h2.command.dml.ScriptCommand) LinkedHashSet(java.util.LinkedHashSet) HashSet(java.util.HashSet)

Aggregations

ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 RunScriptCommand (org.h2.command.dml.RunScriptCommand)1 ScriptCommand (org.h2.command.dml.ScriptCommand)1 ValueString (org.h2.value.ValueString)1