diff --git a/src/box/sql/main.c b/src/box/sql/main.c index ba7bf558022c53619f55a8b286d17a9c9fa9fa03..5c3df65c6b554adf1fd2f44e731642484e208668 100644 --- a/src/box/sql/main.c +++ b/src/box/sql/main.c @@ -359,7 +359,6 @@ sqlErrStr(int rc) /* SQL_BUSY */ "database is locked", /* SQL_LOCKED */ "database table is locked", /* SQL_NOMEM */ "out of memory", - /* SQL_INTERRUPT */ "interrupted", /* SQL_IOERR */ "disk I/O error", /* SQL_NOTFOUND */ "unknown operation", /* SQL_FULL */ "database or disk is full", diff --git a/src/box/sql/malloc.c b/src/box/sql/malloc.c index 831be177e6b7efa51b78f261f2d787ebf8ab261c..a328c18fc1ec007b09083db6e2f5eb9686779c95 100644 --- a/src/box/sql/malloc.c +++ b/src/box/sql/malloc.c @@ -728,9 +728,6 @@ sqlOomFault(sql * db) { if (db->mallocFailed == 0 && db->bBenignMalloc == 0) { db->mallocFailed = 1; - if (db->nVdbeExec > 0) { - db->u1.isInterrupted = 1; - } db->lookaside.bDisable++; } } @@ -747,7 +744,6 @@ sqlOomClear(sql * db) { if (db->mallocFailed && db->nVdbeExec == 0) { db->mallocFailed = 0; - db->u1.isInterrupted = 0; assert(db->lookaside.bDisable > 0); db->lookaside.bDisable--; } diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h index 9b1d7f3eea6ab219c54695d3780c8bf57620ee2e..ed64f4297eab9f90e434df4e4fbad74eb7acec5f 100644 --- a/src/box/sql/sqlInt.h +++ b/src/box/sql/sqlInt.h @@ -343,8 +343,6 @@ enum sql_ret_code { SQL_LOCKED, /** A malloc() failed. */ SQL_NOMEM, - /** Operation terminated by sql_interrupt(). */ - SQL_INTERRUPT, /** Some kind of disk I/O error occurred. */ SQL_IOERR, /** Unknown opcode in sql_file_control(). */ @@ -1309,14 +1307,7 @@ struct sql { void (*xUpdateCallback) (void *, int, const char *, const char *, sql_int64); sql_value *pErr; /* Most recent error message */ - union { - volatile int isInterrupted; /* True if sql_interrupt has been called */ - double notUsed1; /* Spacer */ - } u1; Lookaside lookaside; /* Lookaside malloc configuration */ - int (*xProgress) (void *); /* The progress callback */ - void *pProgressArg; /* Argument to the progress callback */ - unsigned nProgressOps; /* Number of opcodes for progress callback */ Hash aFunc; /* Hash table of connection functions */ int *pnBytesFreed; /* If not NULL, increment this in DbFree() */ }; diff --git a/src/box/sql/tokenize.c b/src/box/sql/tokenize.c index 902b69f9d2fc7f110a8af40e16102693da06b895..ea364de5be0f9e020a9d480b3b0d8598944fd5d6 100644 --- a/src/box/sql/tokenize.c +++ b/src/box/sql/tokenize.c @@ -457,9 +457,6 @@ sqlRunParser(Parse * pParse, const char *zSql) assert(zSql != 0); mxSqlLen = db->aLimit[SQL_LIMIT_SQL_LENGTH]; - if (db->nVdbeActive == 0) { - db->u1.isInterrupted = 0; - } pParse->zTail = zSql; i = 0; /* sqlParserTrace(stdout, "parser: "); */ diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c index 15a2692fc10acdc8a1e638b8c16fe6eac4cec1a8..a89259f2416cc7fbd71020439871fc133eb04eea 100644 --- a/src/box/sql/vdbe.c +++ b/src/box/sql/vdbe.c @@ -91,18 +91,6 @@ int sql_search_count = 0; int sql_xfer_count = 0; #endif -/* - * When this global variable is positive, it gets decremented once before - * each instruction in the VDBE. When it reaches zero, the u1.isInterrupted - * field of the sql structure is set in order to simulate an interrupt. - * - * This facility is used for testing purposes only. It does not function - * in an ordinary build. - */ -#ifdef SQL_TEST -int sql_interrupt_count = 0; -#endif - /* * The next global variable is incremented each type the OP_Sort opcode * is executed. The test procedures use this information to make sure that @@ -746,7 +734,6 @@ int sqlVdbeExec(Vdbe *p) sql *db = p->db; /* The database */ int iCompare = 0; /* Result of last comparison */ unsigned nVmStep = 0; /* Number of virtual machine steps */ - unsigned nProgressLimit = 0;/* Invoke xProgress() when nVmStep reaches this */ Mem *aMem = p->aMem; /* Copy of p->aMem */ Mem *pIn1 = 0; /* 1st input operand */ Mem *pIn2 = 0; /* 2nd input operand */ @@ -770,14 +757,6 @@ int sqlVdbeExec(Vdbe *p) p->iCurrentTime = 0; assert(p->explain==0); p->pResultSet = 0; - if (db->u1.isInterrupted) goto abort_due_to_interrupt; - - if (db->xProgress) { - u32 iPrior = p->aCounter[SQL_STMTSTATUS_VM_STEP]; - assert(0 < db->nProgressOps); - nProgressLimit = db->nProgressOps - (iPrior % db->nProgressOps); - } - #ifdef SQL_DEBUG sqlBeginBenignMalloc(); if (p->pc == 0 && @@ -916,39 +895,7 @@ int sqlVdbeExec(Vdbe *p) * to the current line should be indented for EXPLAIN output. */ case OP_Goto: { /* jump */ - jump_to_p2_and_check_for_interrupt: - pOp = &aOp[pOp->p2 - 1]; - - /* Opcodes that are used as the bottom of a loop (OP_Next, OP_Prev, - * OP_RowSetNext, or OP_SorterNext) all jump here upon - * completion. Check to see if sql_interrupt() has been called - * or if the progress callback needs to be invoked. - * - * This code uses unstructured "goto" statements and does not look clean. - * But that is not due to sloppy coding habits. The code is written this - * way for performance, to avoid having to run the interrupt and progress - * checks on every opcode. This helps sql_step() to run about 1.5% - * faster according to "valgrind --tool=cachegrind" - */ - check_for_interrupt: - if (db->u1.isInterrupted) goto abort_due_to_interrupt; - - /* Call the progress callback if it is configured and the required number - * of VDBE ops have been executed (either since this invocation of - * sqlVdbeExec() or since last time the progress callback was called). - * If the progress callback returns non-zero, exit the virtual machine with - * a return code SQL_ABORT. - */ - if (db->xProgress!=0 && nVmStep>=nProgressLimit) { - assert(db->nProgressOps!=0); - nProgressLimit = nVmStep + db->nProgressOps - (nVmStep%db->nProgressOps); - if (db->xProgress(db->pProgressArg)) { - rc = SQL_INTERRUPT; - goto abort_due_to_error; - } - } - - break; + goto jump_to_p2; } /* Opcode: Gosub P1 P2 * * * @@ -1467,16 +1414,6 @@ case OP_ResultRow: { assert(pOp->p1>0); assert(pOp->p1+pOp->p2<=(p->nMem+1 - p->nCursor)+1); - /* Run the progress counter just before returning. - */ - if (db->xProgress!=0 - && nVmStep>=nProgressLimit - && db->xProgress(db->pProgressArg)!=0 - ) { - rc = SQL_INTERRUPT; - goto abort_due_to_error; - } - /* If this statement has violated immediate foreign key constraints, do * not return the number of rows modified. And do not RELEASE the statement * transaction. It needs to be rolled back. @@ -4306,11 +4243,11 @@ case OP_Next: /* jump */ #ifdef SQL_TEST sql_search_count++; #endif - goto jump_to_p2_and_check_for_interrupt; + goto jump_to_p2; } else { pC->nullRow = 1; } - goto check_for_interrupt; + break; } /* Opcode: SorterInsert P1 P2 * * * @@ -5447,14 +5384,4 @@ default: { /* This is really OP_Noop and OP_Explain */ sqlVdbeError(p, "out of memory"); rc = SQL_NOMEM; goto abort_due_to_error; - - /* Jump to here if the sql_interrupt() API sets the interrupt - * flag. - */ -abort_due_to_interrupt: - assert(db->u1.isInterrupted); - rc = db->mallocFailed ? SQL_NOMEM : SQL_INTERRUPT; - p->rc = rc; - sqlVdbeError(p, "%s", sqlErrStr(rc)); - goto abort_due_to_error; } diff --git a/src/box/sql/vdbeapi.c b/src/box/sql/vdbeapi.c index cd8d3527b6848c4192c92909a9800612f6e6ff25..d59c0a16ea69baac66468379fa38debcd6d10fe8 100644 --- a/src/box/sql/vdbeapi.c +++ b/src/box/sql/vdbeapi.c @@ -510,13 +510,6 @@ sqlStep(Vdbe * p) goto end_of_step; } if (p->pc < 0) { - /* If there are no other statements currently running, then - * reset the interrupt flag. This prevents a call to sql_interrupt - * from interrupting a statement that has not yet started. - */ - if (db->nVdbeActive == 0) { - db->u1.isInterrupted = 0; - } if ((db->xProfile || (db->mTrace & SQL_TRACE_PROFILE) != 0) && !db->init.busy && p->zSql) { diff --git a/src/box/sql/vdbeaux.c b/src/box/sql/vdbeaux.c index d8018ba52a0cabf9594e7d2a0bae7be37b019550..4bbe6768d54b0b59c9c319124e826e6ef9100c32 100644 --- a/src/box/sql/vdbeaux.c +++ b/src/box/sql/vdbeaux.c @@ -1455,10 +1455,6 @@ sqlVdbeList(Vdbe * p) if (i >= nRow) { p->rc = SQL_OK; rc = SQL_DONE; - } else if (db->u1.isInterrupted) { - p->rc = SQL_INTERRUPT; - rc = SQL_ERROR; - sqlVdbeError(p, sqlErrStr(p->rc)); } else { char *zP4; Op *pOp; @@ -2134,7 +2130,6 @@ sqlVdbeHalt(Vdbe * p) * SQL_NOMEM * SQL_IOERR * SQL_FULL - * SQL_INTERRUPT * * Then the internal cache might have been left in an inconsistent * state. We need to rollback the statement transaction, if there is @@ -2160,13 +2155,11 @@ sqlVdbeHalt(Vdbe * p) /* Check for one of the special errors */ mrc = p->rc & 0xff; - isSpecialError = mrc == SQL_NOMEM || mrc == SQL_IOERR - || mrc == SQL_INTERRUPT || mrc == SQL_FULL; + isSpecialError = mrc == SQL_NOMEM || mrc == SQL_IOERR || + mrc == SQL_FULL; if (isSpecialError) { - /* If the query was read-only and the error code is SQL_INTERRUPT, - * no rollback is necessary. Otherwise, at least a savepoint - * transaction must be rolled back to restore the database to a - * consistent state. + /* At least a savepoint transaction must be rolled back + * to restore the database to a consistent state. * * Even if the statement is read-only, it is important to perform * a statement or transaction rollback operation. If the error @@ -2175,20 +2168,18 @@ sqlVdbeHalt(Vdbe * p) * pagerStress() in pager.c), the rollback is required to restore * the pager to a consistent state. */ - if (mrc != SQL_INTERRUPT) { - if ((mrc == SQL_NOMEM || mrc == SQL_FULL) - && box_txn()) { - eStatementOp = SAVEPOINT_ROLLBACK; - } else { - /* We are forced to roll back the active transaction. Before doing - * so, abort any other statements this handle currently has active. - */ - box_txn_rollback(); - closeCursorsAndFree(p); - sqlRollbackAll(p); - sqlCloseSavepoints(p); - p->nChange = 0; - } + if ((mrc == SQL_NOMEM || mrc == SQL_FULL) + && box_txn()) { + eStatementOp = SAVEPOINT_ROLLBACK; + } else { + /* We are forced to roll back the active transaction. Before doing + * so, abort any other statements this handle currently has active. + */ + box_txn_rollback(); + closeCursorsAndFree(p); + sqlRollbackAll(p); + sqlCloseSavepoints(p); + p->nChange = 0; } }