1 21 22 package org.apache.derby.impl.sql.execute; 23 24 import org.apache.derby.iapi.sql.execute.ConstantAction; 25 26 import org.apache.derby.iapi.sql.conn.LanguageConnectionContext; 27 28 import org.apache.derby.iapi.sql.Activation; 29 30 import org.apache.derby.iapi.error.StandardException; 31 32 import org.apache.derby.iapi.sql.conn.StatementContext; 33 import org.apache.derby.iapi.reference.SQLState; 34 35 39 40 class SavepointConstantAction extends DDLConstantAction 41 { 42 43 private final String savepointName; private final int savepointStatementType; 46 52 SavepointConstantAction( 53 String savepointName, 54 int savepointStatementType) 55 { 56 this.savepointName = savepointName; 57 this.savepointStatementType = savepointStatementType; 58 } 59 60 public String toString() 62 { 63 if (savepointStatementType == 1) 64 return constructToString("SAVEPOINT ", savepointName + " ON ROLLBACK RETAIN CURSORS ON ROLLBACK RETAIN LOCKS"); 65 else if (savepointStatementType == 2) 66 return constructToString("ROLLBACK WORK TO SAVEPOINT ", savepointName); 67 else 68 return constructToString("RELEASE TO SAVEPOINT ", savepointName); 69 } 70 71 73 74 81 public void executeConstantAction( Activation activation ) 82 throws StandardException 83 { 84 LanguageConnectionContext lcc = activation.getLanguageConnectionContext(); 85 86 StatementContext stmtCtxt = lcc.getStatementContext(); 88 if (stmtCtxt!= null && stmtCtxt.inTrigger()) 89 throw StandardException.newException(SQLState.NO_SAVEPOINT_IN_TRIGGER); 90 91 if (savepointStatementType == 1) { if (savepointName.startsWith("SYS")) throw StandardException.newException(SQLState.INVALID_SCHEMA_SYS, "SYS"); 94 lcc.languageSetSavePoint(savepointName, savepointName); 95 } else if (savepointStatementType == 2) { lcc.internalRollbackToSavepoint(savepointName,true, savepointName); 97 } else { lcc.releaseSavePoint(savepointName, savepointName); 99 } 100 } 101 102 } 103 | Popular Tags |