**
** Various scripts scan this source file in order to generate HTML
** documentation, headers files, or other derived files. The formatting
** of the code in this file is, therefore, important. See other comments
** in this file for details. If in doubt, do not deviate from existing
** commenting and indentation practices when changing or adding code.
**
** $Id: vdbe.c,v 1.305 2004/05/19 20:41:03 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
#include <ctype.h>
#include "vdbeInt.h"
/*
................................................................................
HashElem *pElem = sqliteHashFirst(&p->hash);
if( pElem==0 ){
AggInsert(p,"",1);
pElem = sqliteHashFirst(&p->hash);
}
return pElem ? sqliteHashData(pElem) : 0;
}
/*
** Convert the given stack entity into a string if it isn't one
** already.
*/
#define Stringify(P) if(((P)->flags & MEM_Str)==0){hardStringify(P);}
static int hardStringify(Mem *pStack){
................................................................................
}else if( fg & MEM_Int ){
sqlite3_snprintf(sizeof(pStack->zShort),pStack->zShort,"%lld",pStack->i);
}else{
pStack->zShort[0] = 0;
}
pStack->z = pStack->zShort;
pStack->n = strlen(pStack->zShort)+1;
pStack->flags = MEM_Str | MEM_Short;
return 0;
}
/*
** Convert the given stack entity into a string that has been obtained
** from sqliteMalloc(). This is different from Stringify() above in that
** Stringify() will use the NBFS bytes of static string space if the string
................................................................................
assert( j>=0 && j<p->nVar );
/* If we need to translate between text encodings, do it now. If this is
** required, then put the new string in p->apVar. This way, if the
** variable is used again, even after the virtual machine is reset, the
** conversion won't have to be done again.
**
** TODO: This is where we need to support databases that use other than
** UTF-8 on disk.
*/
pVar = &p->apVar[j];
if( pVar->flags&MEM_Str && !(pVar->flags&MEM_Utf8) ){
char *zUtf8;
assert( pVar->flags&(MEM_Utf16le|MEM_Utf16be) );
zUtf8 = sqlite3utf16to8(pVar->z, pVar->n);
if( !zUtf8 ){
goto no_mem;
}
Release(pVar);
pVar->z = zUtf8;
pVar->n = strlen(zUtf8)+1;
pVar->flags = MEM_Str|MEM_Dyn;
}
/* Copy the value in pVar to the top of the stack. If pVar is a string or
** a blob just store a pointer to the same memory, do not make a copy.
*/
pTos++;
memcpy(pTos, pVar, sizeof(*pVar)-NBFS);