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.FunctionAlias; 11 import org.h2.engine.Session; 12 import org.h2.message.Message; 13 14 public class DropFunctionAlias extends DefineCommand { 15 16 private String aliasName; 17 private boolean ifExists; 18 19 public DropFunctionAlias(Session session) { 20 super(session); 21 } 22 23 public int update() throws SQLException { 24 session.getUser().checkAdmin(); 25 session.commit(); 26 Database db = session.getDatabase(); 27 FunctionAlias functionAlias = db.findFunctionAlias(aliasName); 28 if(functionAlias == null) { 29 if(!ifExists) { 30 throw Message.getSQLException(Message.FUNCTION_ALIAS_NOT_FOUND_1, aliasName); 31 } 32 } else { 33 db.removeDatabaseObject(session, functionAlias); 34 } 35 return 0; 36 } 37 38 public void setAliasName(String name) { 39 this.aliasName = name; 40 } 41 42 public void setIfExists(boolean ifExists) { 43 this.ifExists = ifExists; 44 } 45 46 } 47 | Popular Tags |