]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
The valueFromFunction() routine is better able to handle OOM errors.
authordrh <drh@noemail.net>
Thu, 12 Mar 2015 06:46:52 +0000 (06:46 +0000)
committerdrh <drh@noemail.net>
Thu, 12 Mar 2015 06:46:52 +0000 (06:46 +0000)
Omit unreachable branches.

FossilOrigin-Name: 8fb6bd9be59d6b04e922d7b246aaefd4851539b6

manifest
manifest.uuid
src/func.c
src/vdbeapi.c
src/vdbemem.c

index 421022d674cbb6ce615f4657dffd884a1e573f40..1dc1a5dfbc4df192a559009dafa2eca8aecef1a1 100644 (file)
--- a/manifest
+++ b/manifest
@@ -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.
-D 2015-03-11T20:59:42.115
+C The\svalueFromFunction()\sroutine\sis\sbetter\sable\sto\shandle\sOOM\serrors.\nOmit\sunreachable\sbranches.
+D 2015-03-12T06:46:52.204
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 88a3e6261286db378fdffa1124cad11b3c05f5bb
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -185,7 +185,7 @@ F src/delete.c 37964e6c1d73ff49cbea9ff690c9605fb15f600e
 F src/expr.c 3ef111b88ae2941b84b6b6ea4be8d501ba1af0cb
 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
 F src/fkey.c e0444b61bed271a76840cbe6182df93a9baa3f12
-F src/func.c 44512c557d6d4a40e51f3980c5854ae3e92862d6
+F src/func.c 1414c24c873c48796ad45942257a179a423ba42f
 F src/global.c 4f77cadbc5427d00139ba43d0f3979804cbb700e
 F src/hash.c 4263fbc955f26c2e8cdc0cf214bc42435aa4e4f5
 F src/hash.h c8f3c31722cf3277d03713909761e152a5b81094
@@ -296,10 +296,10 @@ F src/vacuum.c 9460b9de7b2d4e34b0d374894aa6c8a0632be8ec
 F src/vdbe.c 94cbc2115075b1a562a2a702c29ba48e74f85d34
 F src/vdbe.h 6fc69d9c5e146302c56e163cb4b31d1ee64a18c3
 F src/vdbeInt.h bb56fd199d8af1a2c1b9639ee2f70724b4338e3a
-F src/vdbeapi.c 5c207659c8a57c12c3f77a8fb97544e032fc2f14
+F src/vdbeapi.c da6551c9a9b9272f9cf7c776a09302ce9ca691d3
 F src/vdbeaux.c 97911edb61074b871ec4aa2d6bb779071643dee5
 F src/vdbeblob.c 4f2e8e075d238392df98c5e03a64342465b03f90
-F src/vdbemem.c 85dd9cb7a98717ad821d388c10053da2fe66f0f7
+F src/vdbemem.c ba461e1aa9a3b2ef0507748057dd1ab9b850ea45
 F src/vdbesort.c 6d64c5448b64851b99931ede980addc3af70d5e2
 F src/vdbetrace.c 7e4222955e07dd707a2f360c0eb73452be1cb010
 F src/vtab.c 699f2b8d509cfe379c33dde33827875d5b030e01
@@ -1242,7 +1242,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P b7f1fc26d24012e1e7c7f6b3cc0b84ad2b02b8ad
-R 3e606265a1ac491b0b1ab16052f58807
-U dan
-Z 8153e0e591b223bdb869dacd2f48bbd5
+P ff868e22ca0393eaac417872a4c10738f0d7d970
+R 116c507ff65f2736c7022117ecad1fa2
+U drh
+Z e8a2ef91ffc822055ee072f19f53dce6
index 906c7ad764a3c79349717910b7fa46fb597643e2..83d9b81077f659c981a87695fbf1792f70daf647 100644 (file)
@@ -1 +1 @@
-ff868e22ca0393eaac417872a4c10738f0d7d970
\ No newline at end of file
+8fb6bd9be59d6b04e922d7b246aaefd4851539b6
\ No newline at end of file
index d917bdbec3bb4b169d86f26fe75483f61d31c115..782a2408840f16e968bc316cdccea9500bf91176 100644 (file)
@@ -22,7 +22,9 @@
 ** Return the collating function associated with a function.
 */
 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->p4type==P4_COLLSEQ );
   return pOp->p4.pColl;
index fc3d60f20bae439d6be1d38c8d729cdc966c2124..42cc715d7ce3c517f633ac74f022e279df823f30 100644 (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){
-  Vdbe *v = p->pVdbe;
-  sqlite3_int64 iTime = 0;
   int rc;
-  if( v && v->iCurrentTime ) return v->iCurrentTime;
-  rc = sqlite3OsCurrentTimeInt64(p->pOut->db->pVfs, &iTime);
-  if( rc ) return 0;
-  if( v ) v->iCurrentTime = iTime;
-  return iTime;
+  sqlite3_int64 iTime = 0;
+#ifndef SQLITE_ENABLE_STAT3_OR_STAT4
+  sqlite3_int64 *piTime = &iTime;
+  assert( p->pVdbe!=0 );
+#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;
 
   assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
+#if SQLITE_ENABLE_STAT3_OR_STAT4
   if( pCtx->pVdbe==0 ) return 0;
+#else
+  assert( pCtx->pVdbe!=0 );
+#endif
   for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
     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) );
   if( iArg<0 ) goto failed;
+#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
   if( pVdbe==0 ) goto failed;
+#else
+  assert( pVdbe!=0 );
+#endif
 
   for(pAuxData=pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
     if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
index 269afe148c2dca0dcc89762ac8e551c93f77045b..8b23d678ea04e9aced8623510a69ee29fed5c3ed 100644 (file)
@@ -1194,8 +1194,7 @@ static int valueFromFunction(
     }
     for(i=0; i<nVal; i++){
       rc = sqlite3ValueFromExpr(db, pList->a[i].pExpr, enc, aff, &apVal[i]);
-      if( apVal[i]==0 ) goto value_from_function_out;
-      assert( rc==SQLITE_OK );
+      if( apVal[i]==0 || rc!=SQLITE_OK ) goto value_from_function_out;
     }
   }
 
@@ -1227,10 +1226,12 @@ static int valueFromFunction(
     if( pCtx==0 ) sqlite3ValueFree(pVal);
     pVal = 0;
   }
-  for(i=0; i<nVal; i++){
-    sqlite3ValueFree(apVal[i]);
+  if( apVal ){
+    for(i=0; i<nVal; i++){
+      sqlite3ValueFree(apVal[i]);
+    }
+    sqlite3DbFree(db, apVal);
   }
-  sqlite3DbFree(db, apVal);
 
   *ppVal = pVal;
   return rc;