001package gudusoft.gsqlparser.stmt; 002 003import gudusoft.gsqlparser.*; 004import gudusoft.gsqlparser.nodes.*; 005import gudusoft.gsqlparser.nodes.couchbase.TKeyspaceRef; 006 007/** 008 * remove an index or domain index from the database. 009 */ 010 011public class TDropIndexSqlStatement extends TCustomDropStatement { 012 public TDropIndexSqlStatement(EDbVendor dbvendor) { 013 super(dbvendor); 014 sqlstatementtype = ESqlStatementType.sstdropindex; 015 } 016 017 private boolean ifExists; 018 019 public void setIfExists(boolean ifExists) { 020 this.ifExists = ifExists; 021 } 022 023 public boolean isIfExists() { 024 return ifExists; 025 } 026 027 void buildsql() { 028 } 029 030 void clear() { 031 } 032 033 String getasprettytext() { 034 return ""; 035 } 036 037 void iterate(TVisitorAbs pvisitor) { 038 } 039 040 /** 041 * Please use getDropIndexItemList() instead if it's a sql server drop index statement. 042 * @return the name of the index to be dropped. 043 */ 044 public TObjectName getIndexName() { 045 return indexName; 046 } 047 048 private TObjectName tableName; 049 050 public TObjectName getTableName() { 051 return tableName; 052 } 053 054 private TDropIndexItemList dropIndexItemList = null; 055 056 /** 057 * Used in sql server drop index statement 058 * @return 059 */ 060 public TDropIndexItemList getDropIndexItemList() { 061 return dropIndexItemList; 062 } 063 064 public TObjectNameList getIndexNameList() { 065 return indexNameList; 066 } 067 068 private TObjectNameList indexNameList; 069 070 public int doParseStatement(TCustomSqlStatement psql) { 071 if (rootNode == null) return -1; 072 TDropIndexSqlNode dropIndexNode = (TDropIndexSqlNode)rootNode; 073 super.doParseStatement(psql); 074 this.indexName = dropIndexNode.getIndexName(); 075 if (this.indexName != null){ 076 this.indexName.setDbObjectType(EDbObjectType.index); 077 } 078 this.tableName = dropIndexNode.getTableName(); 079 if (this.tableName != null){ 080 this.tableName.setDbObjectType(EDbObjectType.table); 081 } 082 if (dropIndexNode.getDropIndexItemList() != null){ 083 this.dropIndexItemList = dropIndexNode.getDropIndexItemList(); 084 this.indexName = this.dropIndexItemList.getDropIndexItem(0).getIndexName(); 085 } 086 087 indexNameList = dropIndexNode.getIndexNameList(); 088 if (indexNameList != null){ 089 this.indexName = indexNameList.getObjectName(0); 090 } 091 092 dropRestrictType = dropIndexNode.getDropRestrictType(); 093 ifExists = dropIndexNode.isIfExists(); 094 095 //couchbase 096 keyspaceRef = dropIndexNode.getKeyspaceRef(); 097 indexType = dropIndexNode.getIndexType(); 098 099 return 0; 100 } 101 102 private TObjectName indexName = null; 103 104 public void accept(TParseTreeVisitor v){ 105 v.preVisit(this); 106 v.postVisit(this); 107 } 108 109 public void acceptChildren(TParseTreeVisitor v){ 110 v.preVisit(this); 111 if (this.dropIndexItemList != null){ 112 this.dropIndexItemList.acceptChildren(v); 113 }else { 114 this.indexName.acceptChildren(v); 115 } 116 117 if (this.tableName != null){ 118 this.tableName.acceptChildren(v); 119 } 120 121 v.postVisit(this); 122 } 123 124 public void setTableName(TObjectName tableName) { 125 this.tableName = tableName; 126 } 127 128 public void setDropIndexItemList(TDropIndexItemList dropIndexItemList) { 129 this.dropIndexItemList = dropIndexItemList; 130 } 131 132 public void setIndexName(TObjectName indexName) { 133 this.indexName = indexName; 134 } 135 136 private TKeyspaceRef keyspaceRef; 137 138 public void setKeyspaceRef(TKeyspaceRef keyspaceRef) { 139 this.keyspaceRef = keyspaceRef; 140 } 141 142 public TKeyspaceRef getKeyspaceRef() { 143 144 return keyspaceRef; 145 } 146 147 private EIndexType indexType; 148 149 public void setIndexType(EIndexType indexType) { 150 this.indexType = indexType; 151 } 152 153 public EIndexType getIndexType() { 154 155 return indexType; 156 } 157 158}