| 4921 | void abort_dbtran(struct sqlclntstate *clnt); |
| 4922 | |
| 4923 | int sqlite3BtreeCommit(Btree *pBt) |
| 4924 | { |
| 4925 | struct sql_thread *thd = pthread_getspecific(query_info_key); |
| 4926 | struct sqlclntstate *clnt = thd->clnt; |
| 4927 | int rc = SQLITE_OK; |
| 4928 | int irc = 0; |
| 4929 | int bdberr = 0; |
| 4930 | |
| 4931 | #ifdef DEBUG_TRAN |
| 4932 | if (gbl_debug_sql_opcodes) { |
| 4933 | uuidstr_t us; |
| 4934 | fprintf( |
| 4935 | stderr, |
| 4936 | "sqlite3BtreeCommit intrans=%d sqleng=%d openeng=%d rqid=%llx %s\n", |
| 4937 | clnt->intrans, clnt->ctrl_sqlengine, clnt->in_sqlite_init, |
| 4938 | clnt->osql.rqid, comdb2uuidstr(clnt->osql.uuid, us)); |
| 4939 | } |
| 4940 | #endif |
| 4941 | |
| 4942 | if (clnt->arr) |
| 4943 | currangearr_coalesce(clnt->arr); |
| 4944 | if (clnt->selectv_arr) |
| 4945 | currangearr_coalesce(clnt->selectv_arr); |
| 4946 | |
| 4947 | if (!clnt->intrans || clnt->in_sqlite_init || |
| 4948 | (!clnt->in_sqlite_init && clnt->ctrl_sqlengine != SQLENG_FNSH_STATE && |
| 4949 | clnt->ctrl_sqlengine != SQLENG_NORMAL_PROCESS && |
| 4950 | clnt->ctrl_sqlengine != SQLENG_FNSH_ABORTED_STATE)) { |
| 4951 | rc = SQLITE_OK; |
| 4952 | goto done; |
| 4953 | } |
| 4954 | |
| 4955 | clnt->recno = 0; |
| 4956 | |
| 4957 | /* reset the state of the sqlengine */ |
| 4958 | if (clnt->ctrl_sqlengine == SQLENG_FNSH_STATE || |
| 4959 | clnt->ctrl_sqlengine == SQLENG_FNSH_ABORTED_STATE) |
| 4960 | sql_set_sqlengine_state(clnt, __FILE__, __LINE__, |
| 4961 | SQLENG_NORMAL_PROCESS); |
| 4962 | |
| 4963 | int64_t rows = clnt->log_effects.num_updated + |
| 4964 | clnt->log_effects.num_deleted + |
| 4965 | clnt->log_effects.num_inserted; |
| 4966 | if (rows && gbl_forbid_incoherent_writes && !clnt->had_lease_at_begin) { |
| 4967 | abort_dbtran(clnt); |
| 4968 | errstat_cat_str(&clnt->osql.xerr, "failed write from incoherent node"); |
| 4969 | clnt->osql.xerr.errval = ERR_BLOCK_FAILED + ERR_VERIFY; |
| 4970 | return SQLITE_ABORT; |
| 4971 | } |
| 4972 | clnt->intrans = 0; |
| 4973 | /* This is the last chunk; count it in. */ |
| 4974 | if (clnt->dbtran.maxchunksize > 0 && clnt->dbtran.mode == TRANLEVEL_SOSQL) |
| 4975 | ++clnt->dbtran.nchunks; |
| 4976 | clnt->dbtran.crtchunksize = clnt->dbtran.maxchunksize = 0; |
| 4977 | |
| 4978 | #ifdef DEBUG_TRAN |
| 4979 | if (gbl_debug_sql_opcodes) { |
| 4980 | uuidstr_t us; |
no test coverage detected