1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-15 11:41:13 +03:00

Add some tests for the new API. Many more to come. (CVS 1462)

FossilOrigin-Name: d5659f2ee6788e0205fb5e03eeaf64e6c0aa9bed
This commit is contained in:
danielk1977
2004-05-26 10:11:05 +00:00
parent 398eae781e
commit 3cf8606395
18 changed files with 428 additions and 156 deletions

View File

@@ -873,9 +873,49 @@ static void Cleanup(Vdbe *p){
** be called on an SQL statement before sqlite3_step().
*/
void sqlite3VdbeSetNumCols(Vdbe *p, int nResColumn){
assert( 0==p->nResColumn );
p->nResColumn = nResColumn;
}
/*
** Set the name of the idx'th column to be returned by the SQL statement.
** zName must be a pointer to a nul terminated string.
**
** This call must be made after a call to sqlite3VdbeSetNumCols().
**
** Parameter N may be either P3_DYNAMIC or P3_STATIC.
*/
int sqlite3VdbeSetColName(Vdbe *p, int idx, const char *zName, int N){
int rc;
Mem *pColName;
assert( idx<p->nResColumn );
/* If the Vdbe.aColName array has not yet been allocated, allocate
** it now.
*/
if( !p->aColName ){
int i;
p->aColName = (Mem *)sqliteMalloc(sizeof(Mem)*p->nResColumn);
if( !p->aColName ){
return SQLITE_NOMEM;
}
for(i=0; i<p->nResColumn; i++){
p->aColName[i].flags = MEM_Null;
}
}
pColName = &(p->aColName[idx]);
if( N==0 ){
rc = MemSetStr(pColName, zName, -1, TEXT_Utf8, 1);
}else{
rc = MemSetStr(pColName, zName, N, TEXT_Utf8, N>0);
}
if( rc==SQLITE_OK && N==P3_DYNAMIC ){
pColName->flags = (pColName->flags&(~MEM_Static))|MEM_Dyn;
}
return rc;
}
/*
** Clean up a VDBE after execution but do not delete the VDBE just yet.
** Write any error messages into *pzErrMsg. Return the result code.