1 package com.quadcap.sql; 2 3 40 41 import java.util.Vector ; 42 43 import java.io.IOException ; 44 45 import java.sql.SQLException ; 46 47 import com.quadcap.util.Debug; 48 49 54 55 public class StmtDropIndex implements Stmt { 56 String indexName; 57 58 public StmtDropIndex() {} 59 60 public StmtDropIndex(String indexName) { 61 this.indexName = indexName; 62 } 63 64 public void execute(Session session) throws IOException , SQLException { 65 session.getTableWriteLock("#Schema"); 66 Database db = session.getDatabase(); 67 String tableName = db.getTableForIndex(indexName); 68 if (tableName == null) { 69 throw new SQLException ("No such index: " + indexName); 70 } 71 session.getTableWriteLock(tableName); 72 Table t = (Table)db.getRelation(tableName); 73 if (t == null) { 74 throw new SQLException ("No table: " + tableName + " for index " + 75 indexName); 76 } 77 Constraint c = t.getConstraint(indexName); 78 if (c == null) { 79 throw new SQLException ("Can't find constraint associated with " + 80 "index " + indexName + " for table " + 81 tableName); 82 } 83 session.doStep(new DeleteConstraint(session, t, c, true)); 84 } 85 } 86 87 | Popular Tags |