1 21 22 package org.apache.derby.impl.sql.execute; 23 24 import org.apache.derby.iapi.services.sanity.SanityManager; 25 26 import org.apache.derby.iapi.sql.execute.ConstantAction; 27 28 import org.apache.derby.iapi.reference.SQLState; 29 30 import org.apache.derby.iapi.sql.Activation; 31 32 import org.apache.derby.iapi.error.StandardException; 33 34 import org.apache.derby.iapi.store.access.ConglomerateController; 35 import org.apache.derby.iapi.store.access.TransactionController; 36 37 import org.apache.derby.catalog.UUID; 38 39 40 46 47 class LockTableConstantAction extends GenericConstantAction 48 { 49 50 private final String fullTableName; 51 private final long conglomerateNumber; 52 private final boolean exclusiveMode; 53 54 56 63 LockTableConstantAction(String fullTableName, 64 long conglomerateNumber, boolean exclusiveMode) 65 { 66 this.fullTableName = fullTableName; 67 this.conglomerateNumber = conglomerateNumber; 68 this.exclusiveMode = exclusiveMode; 69 } 70 71 73 public String toString() 74 { 75 return "LOCK TABLE " + fullTableName; 78 } 79 80 82 83 90 public void executeConstantAction( Activation activation ) 91 throws StandardException 92 { 93 ConglomerateController cc; 94 TransactionController tc; 95 96 97 tc = activation.getTransactionController(); 98 99 try 100 { 101 cc = tc.openConglomerate( 102 conglomerateNumber, 103 false, 104 (exclusiveMode) ? 105 (TransactionController.OPENMODE_FORUPDATE | 106 TransactionController.OPENMODE_FOR_LOCK_ONLY) : 107 TransactionController.OPENMODE_FOR_LOCK_ONLY, 108 TransactionController.MODE_TABLE, 109 TransactionController.ISOLATION_SERIALIZABLE); 110 cc.close(); 111 } 112 catch (StandardException se) 113 { 114 String msgId = se.getMessageId(); 115 if (msgId.equals(SQLState.DEADLOCK) || msgId.equals(SQLState.LOCK_TIMEOUT) || msgId.equals(SQLState.LOCK_TIMEOUT_LOG)) { 116 String mode = (exclusiveMode) ? "EXCLUSIVE" : "SHARE"; 117 se = StandardException.newException(SQLState.LANG_CANT_LOCK_TABLE, se, fullTableName, mode); 118 } 119 120 throw se; 121 } 122 } 123 } 124 | Popular Tags |