diff options
author | drh <drh@noemail.net> | 2008-01-23 12:52:40 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2008-01-23 12:52:40 +0000 |
commit | 01495b992158f6da5568bcc11e82d6844ffff4a8 (patch) | |
tree | 4317198de87b54f358a6515089518e65c364a860 /src/table.c | |
parent | 7e8b848a60a305231cca0b8cfc7f08be5f0429bd (diff) | |
download | sqlite-01495b992158f6da5568bcc11e82d6844ffff4a8.tar.gz sqlite-01495b992158f6da5568bcc11e82d6844ffff4a8.zip |
Improvements to test coverage in the lemon-generated parser and in the
sqlite3_get_table() interface. (CVS 4745)
FossilOrigin-Name: 9f95d79daeb5e7f6fd62f3c896dae4d332121d1c
Diffstat (limited to 'src/table.c')
-rw-r--r-- | src/table.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/table.c b/src/table.c index a79a6aca9..48782e895 100644 --- a/src/table.c +++ b/src/table.c @@ -75,12 +75,14 @@ static int sqlite3_get_table_cb(void *pArg, int nCol, char **argv, char **colv){ }else{ z = sqlite3_mprintf("%s", colv[i]); } + if( z==0 ) goto malloc_failed; p->azResult[p->nData++] = z; } }else if( p->nColumn!=nCol ){ - sqlite3SetString(&p->zErrMsg, - "sqlite3_get_table() called with two or more incompatible queries", - (char*)0); + sqlite3_free(p->zErrMsg); + p->zErrMsg = sqlite3_mprintf( + "sqlite3_get_table() called with two or more incompatible queries" + ); p->rc = SQLITE_ERROR; return 1; } @@ -139,15 +141,13 @@ int sqlite3_get_table( res.nData = 1; res.nAlloc = 20; res.rc = SQLITE_OK; - res.azResult = sqlite3_malloc( sizeof(char*)*res.nAlloc ); - if( res.azResult==0 ) return SQLITE_NOMEM; + res.azResult = sqlite3_malloc(sizeof(char*)*res.nAlloc ); + if( res.azResult==0 ){ + db->errCode = SQLITE_NOMEM; + return SQLITE_NOMEM; + } res.azResult[0] = 0; rc = sqlite3_exec(db, zSql, sqlite3_get_table_cb, &res, pzErrMsg); -#ifndef NDEBUG - sqlite3_mutex_enter(db->mutex); - assert((rc&db->errMask)==rc && (res.rc&db->errMask)==res.rc); - sqlite3_mutex_leave(db->mutex); -#endif if( res.azResult ){ assert( sizeof(res.azResult[0])>= sizeof(res.nData) ); res.azResult[0] = (char*)res.nData; @@ -161,9 +161,7 @@ int sqlite3_get_table( } sqlite3_free(res.zErrMsg); } - sqlite3_mutex_enter(db->mutex); - db->errCode = res.rc; - sqlite3_mutex_leave(db->mutex); + db->errCode = res.rc; /* Assume 32-bit assignment is atomic */ return res.rc; } sqlite3_free(res.zErrMsg); @@ -176,6 +174,7 @@ int sqlite3_get_table( azNew = sqlite3_realloc( res.azResult, sizeof(char*)*(res.nData+1) ); if( azNew==0 ){ sqlite3_free_table(&res.azResult[1]); + db->errCode = SQLITE_NOMEM; return SQLITE_NOMEM; } res.nAlloc = res.nData+1; |