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 void buildsql() { 018 } 019 020 void clear() { 021 } 022 023 String getasprettytext() { 024 return ""; 025 } 026 027 void iterate(TVisitorAbs pvisitor) { 028 } 029 030 /** 031 * Please use getDropIndexItemList() instead if it's a sql server drop index statement. 032 * @return the name of the index to be dropped. 033 */ 034 public TObjectName getIndexName() { 035 return indexName; 036 } 037 038 private TObjectName tableName; 039 040 public TObjectName getTableName() { 041 return tableName; 042 } 043 044 private TDropIndexItemList dropIndexItemList = null; 045 046 /** 047 * Used in sql server drop index statement 048 * @return 049 */ 050 public TDropIndexItemList getDropIndexItemList() { 051 return dropIndexItemList; 052 } 053 054 public TObjectNameList getIndexNameList() { 055 return indexNameList; 056 } 057 058 private TObjectNameList indexNameList; 059 060 public int doParseStatement(TCustomSqlStatement psql) { 061 if (rootNode == null) return -1; 062 TDropIndexSqlNode dropIndexNode = (TDropIndexSqlNode)rootNode; 063 super.doParseStatement(psql); 064 this.indexName = dropIndexNode.getIndexName(); 065 if (this.indexName != null){ 066 this.indexName.setDbObjectType(EDbObjectType.index); 067 } 068 this.tableName = dropIndexNode.getTableName(); 069 if (this.tableName != null){ 070 this.tableName.setDbObjectType(EDbObjectType.table); 071 } 072 if (dropIndexNode.getDropIndexItemList() != null){ 073 this.dropIndexItemList = dropIndexNode.getDropIndexItemList(); 074 this.indexName = this.dropIndexItemList.getDropIndexItem(0).getIndexName(); 075 } 076 077 indexNameList = dropIndexNode.getIndexNameList(); 078 if (indexNameList != null){ 079 this.indexName = indexNameList.getObjectName(0); 080 } 081 082 dropRestrictType = dropIndexNode.getDropRestrictType(); 083 084 //couchbase 085 keyspaceRef = dropIndexNode.getKeyspaceRef(); 086 indexType = dropIndexNode.getIndexType(); 087 088 return 0; 089 } 090 091 private TObjectName indexName = null; 092 093 public void accept(TParseTreeVisitor v){ 094 v.preVisit(this); 095 v.postVisit(this); 096 } 097 098 public void acceptChildren(TParseTreeVisitor v){ 099 v.preVisit(this); 100 if (this.dropIndexItemList != null){ 101 this.dropIndexItemList.acceptChildren(v); 102 }else { 103 this.indexName.acceptChildren(v); 104 } 105 106 if (this.tableName != null){ 107 this.tableName.acceptChildren(v); 108 } 109 110 v.postVisit(this); 111 } 112 113 public void setTableName(TObjectName tableName) { 114 this.tableName = tableName; 115 } 116 117 public void setDropIndexItemList(TDropIndexItemList dropIndexItemList) { 118 this.dropIndexItemList = dropIndexItemList; 119 } 120 121 public void setIndexName(TObjectName indexName) { 122 this.indexName = indexName; 123 } 124 125 private TKeyspaceRef keyspaceRef; 126 127 public void setKeyspaceRef(TKeyspaceRef keyspaceRef) { 128 this.keyspaceRef = keyspaceRef; 129 } 130 131 public TKeyspaceRef getKeyspaceRef() { 132 133 return keyspaceRef; 134 } 135 136 private EIndexType indexType; 137 138 public void setIndexType(EIndexType indexType) { 139 this.indexType = indexType; 140 } 141 142 public EIndexType getIndexType() { 143 144 return indexType; 145 } 146 147}