| 1129 | |
| 1130 | |
| 1131 | jrd_tra* TRA_reconnect(thread_db* tdbb, const UCHAR* id, USHORT length) |
| 1132 | { |
| 1133 | /************************************** |
| 1134 | * |
| 1135 | * T R A _ r e c o n n e c t |
| 1136 | * |
| 1137 | ************************************** |
| 1138 | * |
| 1139 | * Functional description |
| 1140 | * Reconnect to a transaction in limbo. |
| 1141 | * |
| 1142 | **************************************/ |
| 1143 | SET_TDBB(tdbb); |
| 1144 | Database* const dbb = tdbb->getDatabase(); |
| 1145 | CHECK_DBB(dbb); |
| 1146 | Jrd::Attachment* const attachment = tdbb->getAttachment(); |
| 1147 | |
| 1148 | // Cannot work on limbo transactions for ReadOnly database |
| 1149 | if (dbb->readOnly()) |
| 1150 | ERR_post(Arg::Gds(isc_read_only_database)); |
| 1151 | |
| 1152 | const TraNumber number = isc_portable_integer(id, length); |
| 1153 | if (number > dbb->dbb_next_transaction) |
| 1154 | PAG_header(tdbb, true); |
| 1155 | |
| 1156 | const int state = (number > dbb->dbb_next_transaction) ? |
| 1157 | 255 : limbo_transaction(tdbb, number); |
| 1158 | |
| 1159 | if (state != tra_limbo) |
| 1160 | { |
| 1161 | USHORT message; |
| 1162 | |
| 1163 | switch (state) |
| 1164 | { |
| 1165 | case tra_active: |
| 1166 | message = 262; // ACTIVE |
| 1167 | break; |
| 1168 | case tra_dead: |
| 1169 | message = 264; // ROLLED BACK |
| 1170 | break; |
| 1171 | case tra_committed: |
| 1172 | message = 263; // COMMITTED |
| 1173 | break; |
| 1174 | default: |
| 1175 | message = 265; // ILL DEFINED |
| 1176 | break; |
| 1177 | } |
| 1178 | |
| 1179 | TEXT text[128]; |
| 1180 | USHORT flags = 0; |
| 1181 | gds__msg_lookup(NULL, FB_IMPL_MSG_FACILITY_JRD_BUGCHK, message, sizeof(text), text, &flags); |
| 1182 | |
| 1183 | // Cannot use Arg::Num here because transaction number is 64-bit unsigned integer |
| 1184 | ERR_post(Arg::Gds(isc_no_recon) << |
| 1185 | Arg::Gds(isc_tra_state) << Arg::Int64(number) << Arg::Str(text)); |
| 1186 | } |
| 1187 | |
| 1188 | MemoryPool* const pool = attachment->createPool(); |
no test coverage detected