Simplifications and additional comments on the sqlite3_get_table()
implementation. Changes to facilitate full branch test coverage. (CVS 6482) FossilOrigin-Name: 57e3e6b3cb54e6626bee41a084c927ee264b6d03
This commit is contained in:
parent
f7590db099
commit
73d34e92f4
14
manifest
14
manifest
@ -1,5 +1,5 @@
|
||||
C Changes\sto\sensure\sthat\swhen\srunning\sin\sshared-cache\smode\swith\sa\snon-threadsafe\sbuild,\sthe\scorrect\sbusy-handler\scallback\sis\salways\sinvoked.\s(CVS\s6481)
|
||||
D 2009-04-10T12:55:17
|
||||
C Simplifications\sand\sadditional\scomments\son\sthe\ssqlite3_get_table()\nimplementation.\s\sChanges\sto\sfacilitate\sfull\sbranch\stest\scoverage.\s(CVS\s6482)
|
||||
D 2009-04-10T14:28:00
|
||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||
F Makefile.in 583e87706abc3026960ed759aff6371faf84c211
|
||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||
@ -162,7 +162,7 @@ F src/sqlite3ext.h 1db7d63ab5de4b3e6b83dd03d1a4e64fef6d2a17
|
||||
F src/sqliteInt.h fcdad0896da9c8b6372db974131e33b7a06606ce
|
||||
F src/sqliteLimit.h ffe93f5a0c4e7bd13e70cd7bf84cfb5c3465f45d
|
||||
F src/status.c 237b193efae0cf6ac3f0817a208de6c6c6ef6d76
|
||||
F src/table.c 332ab0ea691e63862e2a8bdfe2c0617ee61062a3
|
||||
F src/table.c cc86ad3d6ad54df7c63a3e807b5783c90411a08d
|
||||
F src/tclsqlite.c d3195e0738c101a155404ecdb1cd9532a2fd34f2
|
||||
F src/test1.c c4feac6518b0523e944e9cc6a4864854d81a2216
|
||||
F src/test2.c 71c22e2974f8094fe0fd1eba8f27872dde9b2a39
|
||||
@ -717,7 +717,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
|
||||
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||
P ed6620ba589ddbb6ca86f42a7652e3b019195647
|
||||
R 59f76bf89532711f903241145d0b77ea
|
||||
U danielk1977
|
||||
Z ac75d7099ed4abde9c5f40681fcfbea3
|
||||
P 683e4bd74783e6e3f6cf75f9582008c7b7e02a01
|
||||
R 65240198d5802c3e7624e2bd2d3785c6
|
||||
U drh
|
||||
Z e03e042fa6bf5790b1eb4d8b0880d63a
|
||||
|
@ -1 +1 @@
|
||||
683e4bd74783e6e3f6cf75f9582008c7b7e02a01
|
||||
57e3e6b3cb54e6626bee41a084c927ee264b6d03
|
33
src/table.c
33
src/table.c
@ -16,7 +16,7 @@
|
||||
** These routines are in a separate files so that they will not be linked
|
||||
** if they are not used.
|
||||
**
|
||||
** $Id: table.c,v 1.39 2009/01/19 20:49:10 drh Exp $
|
||||
** $Id: table.c,v 1.40 2009/04/10 14:28:00 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include <stdlib.h>
|
||||
@ -29,14 +29,13 @@
|
||||
** to the callback function is uses to build the result.
|
||||
*/
|
||||
typedef struct TabResult {
|
||||
char **azResult;
|
||||
char *zErrMsg;
|
||||
int nResult;
|
||||
int nAlloc;
|
||||
int nRow;
|
||||
int nColumn;
|
||||
int nData;
|
||||
int rc;
|
||||
char **azResult; /* Accumulated output */
|
||||
char *zErrMsg; /* Error message text, if an error occurs */
|
||||
int nAlloc; /* Slots allocated for azResult[] */
|
||||
int nRow; /* Number of rows in the result */
|
||||
int nColumn; /* Number of columns in the result */
|
||||
int nData; /* Slots used in azResult[]. (nRow+1)*nColumn */
|
||||
int rc; /* Return code from sqlite3_exec() */
|
||||
} TabResult;
|
||||
|
||||
/*
|
||||
@ -45,10 +44,10 @@ typedef struct TabResult {
|
||||
** memory as necessary.
|
||||
*/
|
||||
static int sqlite3_get_table_cb(void *pArg, int nCol, char **argv, char **colv){
|
||||
TabResult *p = (TabResult*)pArg;
|
||||
int need;
|
||||
int i;
|
||||
char *z;
|
||||
TabResult *p = (TabResult*)pArg; /* Result accumulator */
|
||||
int need; /* Slots needed in p->azResult[] */
|
||||
int i; /* Loop counter */
|
||||
char *z; /* A single column of result */
|
||||
|
||||
/* Make sure there is enough space in p->azResult to hold everything
|
||||
** we need to remember from this invocation of the callback.
|
||||
@ -58,9 +57,9 @@ static int sqlite3_get_table_cb(void *pArg, int nCol, char **argv, char **colv){
|
||||
}else{
|
||||
need = nCol;
|
||||
}
|
||||
if( p->nData + need >= p->nAlloc ){
|
||||
if( p->nData + need > p->nAlloc ){
|
||||
char **azNew;
|
||||
p->nAlloc = p->nAlloc*2 + need + 1;
|
||||
p->nAlloc = p->nAlloc*2 + need;
|
||||
azNew = sqlite3_realloc( p->azResult, sizeof(char*)*p->nAlloc );
|
||||
if( azNew==0 ) goto malloc_failed;
|
||||
p->azResult = azNew;
|
||||
@ -134,7 +133,6 @@ int sqlite3_get_table(
|
||||
if( pnRow ) *pnRow = 0;
|
||||
if( pzErrMsg ) *pzErrMsg = 0;
|
||||
res.zErrMsg = 0;
|
||||
res.nResult = 0;
|
||||
res.nRow = 0;
|
||||
res.nColumn = 0;
|
||||
res.nData = 1;
|
||||
@ -168,13 +166,12 @@ int sqlite3_get_table(
|
||||
}
|
||||
if( res.nAlloc>res.nData ){
|
||||
char **azNew;
|
||||
azNew = sqlite3_realloc( res.azResult, sizeof(char*)*(res.nData+1) );
|
||||
azNew = sqlite3_realloc( res.azResult, sizeof(char*)*res.nData );
|
||||
if( azNew==0 ){
|
||||
sqlite3_free_table(&res.azResult[1]);
|
||||
db->errCode = SQLITE_NOMEM;
|
||||
return SQLITE_NOMEM;
|
||||
}
|
||||
res.nAlloc = res.nData+1;
|
||||
res.azResult = azNew;
|
||||
}
|
||||
*pazResult = &res.azResult[1];
|
||||
|
Loading…
x
Reference in New Issue
Block a user