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

The sqlite_get_table() function now returns an error if you pass in two

or more SELECT statements that return different numbers of columns. (CVS 436)

FossilOrigin-Name: e2558c34034cf49524084ec819df58934a8af983
This commit is contained in:
drh
2002-03-23 00:52:01 +00:00
parent 1cc3d75f69
commit f1a7a13928
5 changed files with 39 additions and 11 deletions

View File

@@ -18,7 +18,7 @@
*/
#include <stdlib.h>
#include <string.h>
#include "sqlite.h"
#include "sqliteInt.h"
/*
** This structure is used to pass data from sqlite_get_table() through
@@ -26,6 +26,7 @@
*/
typedef struct TabResult {
char **azResult;
char *zErrMsg;
int nResult;
int nAlloc;
int nRow;
@@ -82,6 +83,11 @@ static int sqlite_get_table_cb(void *pArg, int nCol, char **argv, char **colv){
}
p->azResult[p->nData++] = z;
}
}else if( p->nColumn!=nCol ){
sqliteSetString(&p->zErrMsg,
"sqlite_get_table() called with two or more incompatible queries", 0);
p->rc = SQLITE_ERROR;
return 1;
}
/* Copy over the row data
@@ -129,6 +135,7 @@ int sqlite_get_table(
*pazResult = 0;
if( pnColumn ) *pnColumn = 0;
if( pnRow ) *pnRow = 0;
res.zErrMsg = 0;
res.nResult = 0;
res.nRow = 0;
res.nColumn = 0;
@@ -146,8 +153,18 @@ int sqlite_get_table(
}
if( rc==SQLITE_ABORT ){
sqlite_free_table(&res.azResult[1]);
if( res.zErrMsg ){
if( pzErrMsg ){
free(*pzErrMsg);
*pzErrMsg = res.zErrMsg;
sqliteStrRealloc(pzErrMsg);
}else{
sqliteFree(res.zErrMsg);
}
}
return res.rc;
}
sqliteFree(res.zErrMsg);
if( rc!=SQLITE_OK ){
sqlite_free_table(&res.azResult[1]);
return rc;