1 5 package org.h2.command.ddl; 6 7 import java.sql.SQLException ; 8 9 import org.h2.engine.Database; 10 import org.h2.engine.Session; 11 import org.h2.engine.UserDataType; 12 import org.h2.message.Message; 13 14 public class DropUserDataType extends DefineCommand { 15 16 private String typeName; 17 private boolean ifExists; 18 19 public DropUserDataType(Session session) { 20 super(session); 21 } 22 23 public void setIfExists(boolean ifExists) { 24 this.ifExists = ifExists; 25 } 26 27 public int update() throws SQLException { 28 session.getUser().checkAdmin(); 29 session.commit(); 30 Database db = session.getDatabase(); 31 UserDataType type = db.findUserDataType(typeName); 32 if(type == null) { 33 if(!ifExists) { 34 throw Message.getSQLException(Message.USER_DATA_TYPE_NOT_FOUND_1, typeName); 35 } 36 } else { 37 db.removeDatabaseObject(session, type); 38 } 39 return 0; 40 } 41 42 public void setTypeName(String name) { 43 this.typeName = name; 44 } 45 46 } 47 48 | Popular Tags |