(ZTransactStmt s)
| 424 | } |
| 425 | |
| 426 | public void handleTransactStatement(ZTransactStmt s) |
| 427 | throws IOException, |
| 428 | simpledb.ParsingException { |
| 429 | switch (s.getStmtType()) { |
| 430 | case "COMMIT": |
| 431 | if (curtrans == null) |
| 432 | throw new ParsingException( |
| 433 | "No transaction is currently running"); |
| 434 | curtrans.commit(); |
| 435 | curtrans = null; |
| 436 | inUserTrans = false; |
| 437 | System.out.println("Transaction " + curtrans.getId().getId() |
| 438 | + " committed."); |
| 439 | break; |
| 440 | case "ROLLBACK": |
| 441 | if (curtrans == null) |
| 442 | throw new ParsingException( |
| 443 | "No transaction is currently running"); |
| 444 | curtrans.abort(); |
| 445 | curtrans = null; |
| 446 | inUserTrans = false; |
| 447 | System.out.println("Transaction " + curtrans.getId().getId() |
| 448 | + " aborted."); |
| 449 | |
| 450 | break; |
| 451 | case "SET TRANSACTION": |
| 452 | if (curtrans != null) |
| 453 | throw new ParsingException( |
| 454 | "Can't start new transactions until current transaction has been committed or rolledback."); |
| 455 | curtrans = new Transaction(); |
| 456 | curtrans.start(); |
| 457 | inUserTrans = true; |
| 458 | System.out.println("Started a new transaction tid = " |
| 459 | + curtrans.getId().getId()); |
| 460 | break; |
| 461 | default: |
| 462 | throw new ParsingException("Unsupported operation"); |
| 463 | } |
| 464 | } |
| 465 | |
| 466 | public LogicalPlan generateLogicalPlan(TransactionId tid, String s) |
| 467 | throws simpledb.ParsingException, IOException { |
no test coverage detected