001package gudusoft.gsqlparser.stmt.sqlite;
002
003import gudusoft.gsqlparser.EDbVendor;
004import gudusoft.gsqlparser.ESqlStatementType;
005import gudusoft.gsqlparser.TCustomSqlStatement;
006import gudusoft.gsqlparser.TVisitorAbs;
007import gudusoft.gsqlparser.nodes.*;
008
009/**
010 * SQLite DETACH DATABASE statement.
011 *
012 * <p>Two forms:</p>
013 * <ul>
014 *   <li>DETACH DATABASE schema_name</li>
015 *   <li>DETACH schema_name (DATABASE keyword is optional)</li>
016 * </ul>
017 */
018public class TDetachStmt extends TCustomSqlStatement {
019
020    public TDetachStmt(EDbVendor dbvendor) {
021        super(dbvendor);
022        sqlstatementtype = ESqlStatementType.sstSqliteDetach;
023    }
024
025    void buildsql() {
026    }
027
028    void clear() {
029    }
030
031    String getasprettytext() {
032        return "";
033    }
034
035    void iterate(TVisitorAbs pvisitor) {
036    }
037
038    private TObjectName schemaName = null;
039
040    /**
041     * Returns the schema name to detach.
042     */
043    public TObjectName getSchemaName() {
044        return schemaName;
045    }
046
047    public int doParseStatement(TCustomSqlStatement psql) {
048        if (rootNode == null) return -1;
049        super.doParseStatement(psql);
050
051        TDummy dummySqlNode = (TDummy) rootNode;
052        if (dummySqlNode.node1 != null) {
053            schemaName = (TObjectName) dummySqlNode.node1;
054        }
055
056        return 0;
057    }
058
059    public void accept(TParseTreeVisitor v) {
060        v.preVisit(this);
061        v.postVisit(this);
062    }
063
064    public void acceptChildren(TParseTreeVisitor v) {
065        v.preVisit(this);
066        v.postVisit(this);
067    }
068}