| 2229 | } |
| 2230 | |
| 2231 | int handle_sql_commitrollback(struct sqlthdstate *thd, |
| 2232 | struct sqlclntstate *clnt, |
| 2233 | enum trans_clntcomm sideeffects) |
| 2234 | { |
| 2235 | int rc = 0; |
| 2236 | int outrc = 0; |
| 2237 | |
| 2238 | if (sideeffects == TRANS_CLNTCOMM_NORMAL) { |
| 2239 | /* Don't setup(reset) logger for commits of individual chunks, |
| 2240 | and for the implicit commit from an SP */ |
| 2241 | reqlog_setup_begin_commit_rollback(thd, clnt); |
| 2242 | } |
| 2243 | |
| 2244 | int64_t rows = clnt->log_effects.num_updated + |
| 2245 | clnt->log_effects.num_deleted + |
| 2246 | clnt->log_effects.num_inserted; |
| 2247 | |
| 2248 | reqlog_set_cost(thd->logger, 0); |
| 2249 | reqlog_set_rows(thd->logger, rows); |
| 2250 | |
| 2251 | if (rows > 0 && gbl_forbid_incoherent_writes && !clnt->had_lease_at_begin) { |
| 2252 | abort_dbtran(clnt); |
| 2253 | errstat_cat_str(&clnt->osql.xerr, "failed write from incoherent node"); |
| 2254 | clnt->osql.xerr.errval = ERR_BLOCK_FAILED + ERR_VERIFY; |
| 2255 | sql_set_sqlengine_state(clnt, __FILE__, __LINE__, |
| 2256 | SQLENG_NORMAL_PROCESS); |
| 2257 | outrc = CDB2ERR_VERIFY_ERROR; |
| 2258 | Pthread_mutex_lock(&clnt->wait_mutex); |
| 2259 | clnt->ready_for_heartbeats = 0; |
| 2260 | Pthread_mutex_unlock(&clnt->wait_mutex); |
| 2261 | if (do_send_commitrollback_response(clnt, sideeffects)) { |
| 2262 | write_response(clnt, RESPONSE_ERROR, clnt->osql.xerr.errstr, outrc); |
| 2263 | } |
| 2264 | goto done; |
| 2265 | } |
| 2266 | |
| 2267 | rc = do_commitrollback(thd, clnt, sideeffects); |
| 2268 | |
| 2269 | clnt->ins_keys = 0ULL; |
| 2270 | clnt->del_keys = 0ULL; |
| 2271 | |
| 2272 | if (clnt->arr) { |
| 2273 | currangearr_free(clnt->arr); |
| 2274 | clnt->arr = NULL; |
| 2275 | } |
| 2276 | if (clnt->selectv_arr) { |
| 2277 | currangearr_free(clnt->selectv_arr); |
| 2278 | clnt->selectv_arr = NULL; |
| 2279 | } |
| 2280 | |
| 2281 | destroy_hash(clnt->ddl_tables, free_it); |
| 2282 | destroy_hash(clnt->dml_tables, free_it); |
| 2283 | clnt->ddl_tables = NULL; |
| 2284 | clnt->dml_tables = NULL; |
| 2285 | destroy_hash(clnt->ddl_contexts, free_clnt_ddl_context); |
| 2286 | clnt->ddl_contexts = NULL; |
| 2287 | |
| 2288 | /* reset the state after send_done; we use ctrl_sqlengine to know |
no test coverage detected