@@ -223,24 +223,31 @@ static int rese_commit(struct sqlclntstate *clnt, struct sql_thread *thd,
223223 int sentops = 0 ;
224224 int bdberr = 0 ;
225225 int rc = 0 ;
226+ int serial_rc = 0 ;
226227 int usedb_only = 0 ;
227228 int force_master = gbl_serialize_reads_like_writes ;
229+ bdb_state_type * bdb_state = thedb -> bdb_env ;
230+
231+ /* get_rep_gen & serial_check call into berkley */
232+ BDB_READLOCK ("rese_commit" );
228233
229234 if (gbl_early_verify && !clnt -> early_retry && gbl_osql_send_startgen &&
230235 clnt -> start_gen ) {
231236 if (clnt -> start_gen != bdb_get_rep_gen (thedb -> bdb_env ))
232237 clnt -> early_retry = EARLY_ERR_GENCHANGE ;
233238 }
234- if (clnt -> selectv_arr )
239+ /* selectv pre-check optimization */
240+ if (clnt -> early_retry == 0 && clnt -> selectv_arr && (force_master || !osql_shadtbl_empty (clnt ))) {
235241 currangearr_build_hash (clnt -> selectv_arr );
236- if (clnt -> selectv_arr &&
237- bdb_osql_serial_check (thedb -> bdb_env , clnt -> selectv_arr ,
238- & (clnt -> selectv_arr -> file ),
239- & (clnt -> selectv_arr -> offset ), 0 )) {
240- clnt -> osql .xerr .errval = ERR_CONSTR ;
241- errstat_cat_str (& (clnt -> osql .xerr ), "selectv constraints" );
242- rc = SQLITE_ABORT ;
243- } else if (clnt -> early_retry == EARLY_ERR_VERIFY ) {
242+ if ((serial_rc = bdb_osql_serial_check (thedb -> bdb_env , clnt -> selectv_arr , & (clnt -> selectv_arr -> file ),
243+ & (clnt -> selectv_arr -> offset ), 0 )) != 0 ) {
244+ clnt -> early_retry = (serial_rc == -99 ) ? EARLY_ERR_GENCHANGE : EARLY_ERR_SELECTV ;
245+ }
246+ }
247+
248+ BDB_RELLOCK ();
249+
250+ if (clnt -> early_retry == EARLY_ERR_VERIFY ) {
244251 if (clnt -> dbtran .mode == TRANLEVEL_SERIAL ) {
245252 clnt -> osql .xerr .errval = ERR_NOTSERIAL ;
246253 errstat_cat_str (& (clnt -> osql .xerr ),
@@ -253,7 +260,7 @@ static int rese_commit(struct sqlclntstate *clnt, struct sql_thread *thd,
253260 rc = SQLITE_ABORT ;
254261 } else if (clnt -> early_retry == EARLY_ERR_SELECTV ) {
255262 clnt -> osql .xerr .errval = ERR_CONSTR ;
256- errstat_cat_str (& (clnt -> osql .xerr ), "constraints error, no genid " );
263+ errstat_cat_str (& (clnt -> osql .xerr ), "constraints error" );
257264 rc = SQLITE_ABORT ;
258265 } else if (clnt -> early_retry == EARLY_ERR_GENCHANGE ) {
259266 clnt -> osql .xerr .errval = ERR_BLOCK_FAILED + ERR_VERIFY ;
0 commit comments