1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

The valueFromFunction() routine is better able to handle OOM errors.

Omit unreachable branches.

FossilOrigin-Name: 8fb6bd9be59d6b04e922d7b246aaefd4851539b6
This commit is contained in:
drh
2015-03-12 06:46:52 +00:00
parent cdcc11d7d4
commit a9e03b1b82
5 changed files with 45 additions and 24 deletions

View File

@@ -1,5 +1,5 @@
C Allow\sthe\sdefault\svalue\sfor\scolumns\sadded\susing\sALTER\sTABLE\sADD\sCOLUMN\sto\sbe\sa\sfunction\sin\sexisting\sschemas\sloaded\sfrom\sdisk.\sBut\sprevent\sthis\sversion\sof\sSQLite\sfrom\sbeing\sused\sto\screate\ssuch\sa\scolumn. C The\svalueFromFunction()\sroutine\sis\sbetter\sable\sto\shandle\sOOM\serrors.\nOmit\sunreachable\sbranches.
D 2015-03-11T20:59:42.115 D 2015-03-12T06:46:52.204
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 88a3e6261286db378fdffa1124cad11b3c05f5bb F Makefile.in 88a3e6261286db378fdffa1124cad11b3c05f5bb
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -185,7 +185,7 @@ F src/delete.c 37964e6c1d73ff49cbea9ff690c9605fb15f600e
F src/expr.c 3ef111b88ae2941b84b6b6ea4be8d501ba1af0cb F src/expr.c 3ef111b88ae2941b84b6b6ea4be8d501ba1af0cb
F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
F src/fkey.c e0444b61bed271a76840cbe6182df93a9baa3f12 F src/fkey.c e0444b61bed271a76840cbe6182df93a9baa3f12
F src/func.c 44512c557d6d4a40e51f3980c5854ae3e92862d6 F src/func.c 1414c24c873c48796ad45942257a179a423ba42f
F src/global.c 4f77cadbc5427d00139ba43d0f3979804cbb700e F src/global.c 4f77cadbc5427d00139ba43d0f3979804cbb700e
F src/hash.c 4263fbc955f26c2e8cdc0cf214bc42435aa4e4f5 F src/hash.c 4263fbc955f26c2e8cdc0cf214bc42435aa4e4f5
F src/hash.h c8f3c31722cf3277d03713909761e152a5b81094 F src/hash.h c8f3c31722cf3277d03713909761e152a5b81094
@@ -296,10 +296,10 @@ F src/vacuum.c 9460b9de7b2d4e34b0d374894aa6c8a0632be8ec
F src/vdbe.c 94cbc2115075b1a562a2a702c29ba48e74f85d34 F src/vdbe.c 94cbc2115075b1a562a2a702c29ba48e74f85d34
F src/vdbe.h 6fc69d9c5e146302c56e163cb4b31d1ee64a18c3 F src/vdbe.h 6fc69d9c5e146302c56e163cb4b31d1ee64a18c3
F src/vdbeInt.h bb56fd199d8af1a2c1b9639ee2f70724b4338e3a F src/vdbeInt.h bb56fd199d8af1a2c1b9639ee2f70724b4338e3a
F src/vdbeapi.c 5c207659c8a57c12c3f77a8fb97544e032fc2f14 F src/vdbeapi.c da6551c9a9b9272f9cf7c776a09302ce9ca691d3
F src/vdbeaux.c 97911edb61074b871ec4aa2d6bb779071643dee5 F src/vdbeaux.c 97911edb61074b871ec4aa2d6bb779071643dee5
F src/vdbeblob.c 4f2e8e075d238392df98c5e03a64342465b03f90 F src/vdbeblob.c 4f2e8e075d238392df98c5e03a64342465b03f90
F src/vdbemem.c 85dd9cb7a98717ad821d388c10053da2fe66f0f7 F src/vdbemem.c ba461e1aa9a3b2ef0507748057dd1ab9b850ea45
F src/vdbesort.c 6d64c5448b64851b99931ede980addc3af70d5e2 F src/vdbesort.c 6d64c5448b64851b99931ede980addc3af70d5e2
F src/vdbetrace.c 7e4222955e07dd707a2f360c0eb73452be1cb010 F src/vdbetrace.c 7e4222955e07dd707a2f360c0eb73452be1cb010
F src/vtab.c 699f2b8d509cfe379c33dde33827875d5b030e01 F src/vtab.c 699f2b8d509cfe379c33dde33827875d5b030e01
@@ -1242,7 +1242,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P b7f1fc26d24012e1e7c7f6b3cc0b84ad2b02b8ad P ff868e22ca0393eaac417872a4c10738f0d7d970
R 3e606265a1ac491b0b1ab16052f58807 R 116c507ff65f2736c7022117ecad1fa2
U dan U drh
Z 8153e0e591b223bdb869dacd2f48bbd5 Z e8a2ef91ffc822055ee072f19f53dce6

View File

@@ -1 +1 @@
ff868e22ca0393eaac417872a4c10738f0d7d970 8fb6bd9be59d6b04e922d7b246aaefd4851539b6

View File

@@ -22,7 +22,9 @@
** Return the collating function associated with a function. ** Return the collating function associated with a function.
*/ */
static CollSeq *sqlite3GetFuncCollSeq(sqlite3_context *context){ static CollSeq *sqlite3GetFuncCollSeq(sqlite3_context *context){
VdbeOp *pOp = &context->pVdbe->aOp[context->iOp-1]; VdbeOp *pOp;
assert( context->pVdbe!=0 );
pOp = &context->pVdbe->aOp[context->iOp-1];
assert( pOp->opcode==OP_CollSeq ); assert( pOp->opcode==OP_CollSeq );
assert( pOp->p4type==P4_COLLSEQ ); assert( pOp->p4type==P4_COLLSEQ );
return pOp->p4.pColl; return pOp->p4.pColl;

View File

@@ -633,17 +633,27 @@ sqlite3 *sqlite3_context_db_handle(sqlite3_context *p){
} }
/* /*
** Return the current time for a statement ** Return the current time for a statement. If the current time
** is requested more than once within the same run of a single prepared
** statement, the exact same time is returned for each invocation regardless
** of the amount of time that elapses between invocations. In other words,
** the time returned is always the time of the first call.
*/ */
sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context *p){ sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context *p){
Vdbe *v = p->pVdbe;
sqlite3_int64 iTime = 0;
int rc; int rc;
if( v && v->iCurrentTime ) return v->iCurrentTime; sqlite3_int64 iTime = 0;
rc = sqlite3OsCurrentTimeInt64(p->pOut->db->pVfs, &iTime); #ifndef SQLITE_ENABLE_STAT3_OR_STAT4
if( rc ) return 0; sqlite3_int64 *piTime = &iTime;
if( v ) v->iCurrentTime = iTime; assert( p->pVdbe!=0 );
return iTime; #else
sqlite3_int64 *piTime = p->pVdbe!=0 ? &p->pVdbe->iCurrentTime : &iTime;
if( *piTime==0 )
#endif
{
rc = sqlite3OsCurrentTimeInt64(p->pOut->db->pVfs, piTime);
if( rc ) *piTime = 0;
}
return *piTime;
} }
/* /*
@@ -713,7 +723,11 @@ void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
AuxData *pAuxData; AuxData *pAuxData;
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
#if SQLITE_ENABLE_STAT3_OR_STAT4
if( pCtx->pVdbe==0 ) return 0; if( pCtx->pVdbe==0 ) return 0;
#else
assert( pCtx->pVdbe!=0 );
#endif
for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){ for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break; if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
} }
@@ -737,7 +751,11 @@ void sqlite3_set_auxdata(
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
if( iArg<0 ) goto failed; if( iArg<0 ) goto failed;
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
if( pVdbe==0 ) goto failed; if( pVdbe==0 ) goto failed;
#else
assert( pVdbe!=0 );
#endif
for(pAuxData=pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){ for(pAuxData=pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break; if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;

View File

@@ -1194,8 +1194,7 @@ static int valueFromFunction(
} }
for(i=0; i<nVal; i++){ for(i=0; i<nVal; i++){
rc = sqlite3ValueFromExpr(db, pList->a[i].pExpr, enc, aff, &apVal[i]); rc = sqlite3ValueFromExpr(db, pList->a[i].pExpr, enc, aff, &apVal[i]);
if( apVal[i]==0 ) goto value_from_function_out; if( apVal[i]==0 || rc!=SQLITE_OK ) goto value_from_function_out;
assert( rc==SQLITE_OK );
} }
} }
@@ -1227,10 +1226,12 @@ static int valueFromFunction(
if( pCtx==0 ) sqlite3ValueFree(pVal); if( pCtx==0 ) sqlite3ValueFree(pVal);
pVal = 0; pVal = 0;
} }
if( apVal ){
for(i=0; i<nVal; i++){ for(i=0; i<nVal; i++){
sqlite3ValueFree(apVal[i]); sqlite3ValueFree(apVal[i]);
} }
sqlite3DbFree(db, apVal); sqlite3DbFree(db, apVal);
}
*ppVal = pVal; *ppVal = pVal;
return rc; return rc;