| 75 | // |
| 76 | |
| 77 | USHORT TDR_analyze(const tdr* trans) |
| 78 | { |
| 79 | if (trans == NULL) |
| 80 | return TRA_none; |
| 81 | |
| 82 | // if the tdr for the first transaction is missing, |
| 83 | // we can assume it was committed |
| 84 | |
| 85 | USHORT advice = TRA_none; |
| 86 | USHORT state = trans->tdr_state; |
| 87 | if (state == TRA_none) |
| 88 | state = TRA_commit; |
| 89 | else if (state == TRA_unknown) |
| 90 | advice = TRA_unknown; |
| 91 | |
| 92 | for (trans = trans->tdr_next; trans; trans = trans->tdr_next) |
| 93 | { |
| 94 | switch (trans->tdr_state) |
| 95 | { |
| 96 | // an explicitly committed transaction necessitates a check for the |
| 97 | // perverse case of a rollback, otherwise a commit if at all possible |
| 98 | |
| 99 | case TRA_commit: |
| 100 | if (state == TRA_rollback) |
| 101 | { |
| 102 | ALICE_print(105); |
| 103 | // msg 105: Warning: Multidatabase transaction is in inconsistent state for recovery. |
| 104 | ALICE_print(106, SafeArg() << trans->tdr_id); |
| 105 | // msg 106: Transaction %ld was committed, but prior ones were rolled back. |
| 106 | return 0; |
| 107 | } |
| 108 | else |
| 109 | advice = TRA_commit; |
| 110 | break; |
| 111 | |
| 112 | // a prepared transaction requires a commit if there are missing |
| 113 | // records up to now, otherwise only do something if somebody else |
| 114 | // already has |
| 115 | |
| 116 | case TRA_limbo: |
| 117 | switch (state) |
| 118 | { |
| 119 | case TRA_none: |
| 120 | case TRA_commit: |
| 121 | advice = TRA_commit; |
| 122 | break; |
| 123 | case TRA_rollback: |
| 124 | advice = TRA_rollback; |
| 125 | break; |
| 126 | } |
| 127 | break; |
| 128 | |
| 129 | // an explicitly rolled back transaction requires a rollback unless a |
| 130 | // transaction has committed or is assumed committed |
| 131 | |
| 132 | case TRA_rollback: |
| 133 | if ((state == TRA_commit) || (state == TRA_none)) |
| 134 | { |
no test coverage detected