Lines Matching refs:pMem

13726     Mem *pMem;             /* Used when p4type is P4_MEM */  member
18950 Mem *pMem; /* Memory cell used to store aggregate context */ member
19133 SQLITE_PRIVATE int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve);
19134 SQLITE_PRIVATE int sqlite3VdbeMemClearAndResize(Mem *pMem, int n);
19177 SQLITE_PRIVATE void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf);
19181 SQLITE_PRIVATE int sqlite3VdbeMemHandleBom(Mem *pMem);
28135 SQLITE_PRIVATE SQLITE_NOINLINE int sqlite3VdbeMemTranslate(Mem *pMem, u8 desiredEnc){
28143 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
28144 assert( pMem->flags&MEM_Str );
28145 assert( pMem->enc!=desiredEnc );
28146 assert( pMem->enc!=0 );
28147 assert( pMem->n>=0 );
28152 sqlite3VdbeMemPrettyPrint(pMem, zBuf);
28161 if( pMem->enc!=SQLITE_UTF8 && desiredEnc!=SQLITE_UTF8 ){
28164 rc = sqlite3VdbeMemMakeWriteable(pMem);
28169 zIn = (u8*)pMem->z;
28170 zTerm = &zIn[pMem->n&~1];
28177 pMem->enc = desiredEnc;
28188 pMem->n &= ~1;
28189 len = pMem->n * 2 + 1;
28196 len = pMem->n * 2 + 2;
28205 zIn = (u8*)pMem->z;
28206 zTerm = &zIn[pMem->n];
28207 zOut = sqlite3DbMallocRaw(pMem->db, len);
28213 if( pMem->enc==SQLITE_UTF8 ){
28228 pMem->n = (int)(z - zOut);
28232 if( pMem->enc==SQLITE_UTF16LE ){
28245 pMem->n = (int)(z - zOut);
28248 assert( (pMem->n+(desiredEnc==SQLITE_UTF8?1:2))<=len );
28250 c = pMem->flags;
28251 sqlite3VdbeMemRelease(pMem);
28252 pMem->flags = MEM_Str|MEM_Term|(c&(MEM_AffMask|MEM_Subtype));
28253 pMem->enc = desiredEnc;
28254 pMem->z = (char*)zOut;
28255 pMem->zMalloc = pMem->z;
28256 pMem->szMalloc = sqlite3DbMallocSize(pMem->db, pMem->z);
28262 sqlite3VdbeMemPrettyPrint(pMem, zBuf);
28280 SQLITE_PRIVATE int sqlite3VdbeMemHandleBom(Mem *pMem){
28284 assert( pMem->n>=0 );
28285 if( pMem->n>1 ){
28286 u8 b1 = *(u8 *)pMem->z;
28287 u8 b2 = *(((u8 *)pMem->z) + 1);
28297 rc = sqlite3VdbeMemMakeWriteable(pMem);
28299 pMem->n -= 2;
28300 memmove(pMem->z, &pMem->z[2], pMem->n);
28301 pMem->z[pMem->n] = '\0';
28302 pMem->z[pMem->n+1] = '\0';
28303 pMem->flags |= MEM_Term;
28304 pMem->enc = bom;
35364 void *pMem;
35366 pMem = osMmap(0, nMap,
35370 if( pMem==MAP_FAILED ){
35375 pMem = sqlite3_malloc64(szRegion);
35376 if( pMem==0 ){
35380 memset(pMem, 0, szRegion);
35384 pShmNode->apRegion[pShmNode->nRegion+i] = &((char*)pMem)[szRegion*i];
40010 MUTEX_LOGIC( sqlite3_mutex *pMem; ) /* The memsys static mutex */
40012 MUTEX_LOGIC( pMem = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM); )
40014 sqlite3_mutex_enter(pMem);
40041 sqlite3_mutex_leave(pMem);
71316 SQLITE_PRIVATE int sqlite3VdbeChangeEncoding(Mem *pMem, int desiredEnc){
71320 assert( (pMem->flags&MEM_RowSet)==0 );
71323 if( !(pMem->flags&MEM_Str) || pMem->enc==desiredEnc ){
71326 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
71334 rc = sqlite3VdbeMemTranslate(pMem, (u8)desiredEnc);
71336 assert(rc==SQLITE_OK || pMem->enc!=desiredEnc);
71337 assert(rc==SQLITE_NOMEM || pMem->enc==desiredEnc);
71351 SQLITE_PRIVATE SQLITE_NOINLINE int sqlite3VdbeMemGrow(Mem *pMem, int n, int bPreserve){
71352 assert( sqlite3VdbeCheckMemInvariants(pMem) );
71353 assert( (pMem->flags&MEM_RowSet)==0 );
71354 testcase( pMem->db==0 );
71358 assert( bPreserve==0 || pMem->flags&(MEM_Blob|MEM_Str) );
71359 testcase( bPreserve && pMem->z==0 );
71361 assert( pMem->szMalloc==0
71362 || pMem->szMalloc==sqlite3DbMallocSize(pMem->db, pMem->zMalloc) );
71364 if( pMem->szMalloc>0 && bPreserve && pMem->z==pMem->zMalloc ){
71365 pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n);
71368 if( pMem->szMalloc>0 ) sqlite3DbFreeNN(pMem->db, pMem->zMalloc);
71369 pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, n);
71371 if( pMem->zMalloc==0 ){
71372 sqlite3VdbeMemSetNull(pMem);
71373 pMem->z = 0;
71374 pMem->szMalloc = 0;
71377 pMem->szMalloc = sqlite3DbMallocSize(pMem->db, pMem->zMalloc);
71380 if( bPreserve && pMem->z ){
71381 assert( pMem->z!=pMem->zMalloc );
71382 memcpy(pMem->zMalloc, pMem->z, pMem->n);
71384 if( (pMem->flags&MEM_Dyn)!=0 ){
71385 assert( pMem->xDel!=0 && pMem->xDel!=SQLITE_DYNAMIC );
71386 pMem->xDel((void *)(pMem->z));
71389 pMem->z = pMem->zMalloc;
71390 pMem->flags &= ~(MEM_Dyn|MEM_Ephem|MEM_Static);
71407 SQLITE_PRIVATE int sqlite3VdbeMemClearAndResize(Mem *pMem, int szNew){
71409 assert( (pMem->flags & MEM_Dyn)==0 || pMem->szMalloc==0 );
71410 if( pMem->szMalloc<szNew ){
71411 return sqlite3VdbeMemGrow(pMem, szNew, 0);
71413 assert( (pMem->flags & MEM_Dyn)==0 );
71414 pMem->z = pMem->zMalloc;
71415 pMem->flags &= (MEM_Null|MEM_Int|MEM_Real);
71423 static SQLITE_NOINLINE int vdbeMemAddTerminator(Mem *pMem){
71424 if( sqlite3VdbeMemGrow(pMem, pMem->n+2, 1) ){
71427 pMem->z[pMem->n] = 0;
71428 pMem->z[pMem->n+1] = 0;
71429 pMem->flags |= MEM_Term;
71439 SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem *pMem){
71440 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
71441 assert( (pMem->flags&MEM_RowSet)==0 );
71442 if( (pMem->flags & (MEM_Str|MEM_Blob))!=0 ){
71443 if( ExpandBlob(pMem) ) return SQLITE_NOMEM;
71444 if( pMem->szMalloc==0 || pMem->z!=pMem->zMalloc ){
71445 int rc = vdbeMemAddTerminator(pMem);
71449 pMem->flags &= ~MEM_Ephem;
71451 pMem->pScopyFrom = 0;
71462 SQLITE_PRIVATE int sqlite3VdbeMemExpandBlob(Mem *pMem){
71464 assert( pMem->flags & MEM_Zero );
71465 assert( pMem->flags&MEM_Blob );
71466 assert( (pMem->flags&MEM_RowSet)==0 );
71467 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
71470 nByte = pMem->n + pMem->u.nZero;
71474 if( sqlite3VdbeMemGrow(pMem, nByte, 1) ){
71478 memset(&pMem->z[pMem->n], 0, pMem->u.nZero);
71479 pMem->n += pMem->u.nZero;
71480 pMem->flags &= ~(MEM_Zero|MEM_Term);
71488 SQLITE_PRIVATE int sqlite3VdbeMemNulTerminate(Mem *pMem){
71489 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
71490 testcase( (pMem->flags & (MEM_Term|MEM_Str))==(MEM_Term|MEM_Str) );
71491 testcase( (pMem->flags & (MEM_Term|MEM_Str))==0 );
71492 if( (pMem->flags & (MEM_Term|MEM_Str))!=MEM_Str ){
71495 return vdbeMemAddTerminator(pMem);
71513 SQLITE_PRIVATE int sqlite3VdbeMemStringify(Mem *pMem, u8 enc, u8 bForce){
71514 int fg = pMem->flags;
71517 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
71521 assert( (pMem->flags&MEM_RowSet)==0 );
71522 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
71525 if( sqlite3VdbeMemClearAndResize(pMem, nByte) ){
71526 pMem->enc = 0;
71537 sqlite3_snprintf(nByte, pMem->z, "%lld", pMem->u.i);
71540 sqlite3_snprintf(nByte, pMem->z, "%!.15g", pMem->u.r);
71542 pMem->n = sqlite3Strlen30(pMem->z);
71543 pMem->enc = SQLITE_UTF8;
71544 pMem->flags |= MEM_Str|MEM_Term;
71545 if( bForce ) pMem->flags &= ~(MEM_Int|MEM_Real);
71546 sqlite3VdbeChangeEncoding(pMem, enc);
71558 SQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem *pMem, FuncDef *pFunc){
71563 assert( (pMem->flags & MEM_Null)!=0 || pFunc==pMem->u.pDef );
71564 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
71568 t.db = pMem->db;
71570 ctx.pMem = pMem;
71573 assert( (pMem->flags & MEM_Dyn)==0 );
71574 if( pMem->szMalloc>0 ) sqlite3DbFreeNN(pMem->db, pMem->zMalloc);
71575 memcpy(pMem, &t, sizeof(t));
71687 static SQLITE_NOINLINE i64 memIntValue(Mem *pMem){
71689 sqlite3Atoi64(pMem->z, &value, pMem->n, pMem->enc);
71692 SQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem *pMem){
71694 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
71695 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
71696 flags = pMem->flags;
71698 return pMem->u.i;
71700 return doubleToInt64(pMem->u.r);
71702 assert( pMem->z || pMem->n==0 );
71703 return memIntValue(pMem);
71715 static SQLITE_NOINLINE double memRealValue(Mem *pMem){
71718 sqlite3AtoF(pMem->z, &val, pMem->n, pMem->enc);
71721 SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem *pMem){
71722 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
71723 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
71724 if( pMem->flags & MEM_Real ){
71725 return pMem->u.r;
71726 }else if( pMem->flags & MEM_Int ){
71727 return (double)pMem->u.i;
71728 }else if( pMem->flags & (MEM_Str|MEM_Blob) ){
71729 return memRealValue(pMem);
71740 SQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem *pMem){
71742 assert( pMem->flags & MEM_Real );
71743 assert( (pMem->flags & MEM_RowSet)==0 );
71744 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
71745 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
71747 ix = doubleToInt64(pMem->u.r);
71759 if( pMem->u.r==ix && ix>SMALLEST_INT64 && ix<LARGEST_INT64 ){
71760 pMem->u.i = ix;
71761 MemSetTypeFlag(pMem, MEM_Int);
71768 SQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem *pMem){
71769 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
71770 assert( (pMem->flags & MEM_RowSet)==0 );
71771 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
71773 pMem->u.i = sqlite3VdbeIntValue(pMem);
71774 MemSetTypeFlag(pMem, MEM_Int);
71782 SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem *pMem){
71783 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
71784 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
71786 pMem->u.r = sqlite3VdbeRealValue(pMem);
71787 MemSetTypeFlag(pMem, MEM_Real);
71799 SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem *pMem){
71800 if( (pMem->flags & (MEM_Int|MEM_Real|MEM_Null))==0 ){
71802 assert( (pMem->flags & (MEM_Blob|MEM_Str))!=0 );
71803 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
71804 rc = sqlite3Atoi64(pMem->z, &pMem->u.i, pMem->n, pMem->enc);
71806 MemSetTypeFlag(pMem, MEM_Int);
71808 i64 i = pMem->u.i;
71809 sqlite3AtoF(pMem->z, &pMem->u.r, pMem->n, pMem->enc);
71810 if( rc==1 && pMem->u.r==(double)i ){
71811 pMem->u.i = i;
71812 MemSetTypeFlag(pMem, MEM_Int);
71814 MemSetTypeFlag(pMem, MEM_Real);
71818 assert( (pMem->flags & (MEM_Int|MEM_Real|MEM_Null))!=0 );
71819 pMem->flags &= ~(MEM_Str|MEM_Blob|MEM_Zero);
71830 SQLITE_PRIVATE void sqlite3VdbeMemCast(Mem *pMem, u8 aff, u8 encoding){
71831 if( pMem->flags & MEM_Null ) return;
71834 if( (pMem->flags & MEM_Blob)==0 ){
71835 sqlite3ValueApplyAffinity(pMem, SQLITE_AFF_TEXT, encoding);
71836 assert( pMem->flags & MEM_Str || pMem->db->mallocFailed );
71837 if( pMem->flags & MEM_Str ) MemSetTypeFlag(pMem, MEM_Blob);
71839 pMem->flags &= ~(MEM_TypeMask&~MEM_Blob);
71844 sqlite3VdbeMemNumerify(pMem);
71848 sqlite3VdbeMemIntegerify(pMem);
71852 sqlite3VdbeMemRealify(pMem);
71858 pMem->flags |= (pMem->flags&MEM_Blob)>>3;
71859 sqlite3ValueApplyAffinity(pMem, SQLITE_AFF_TEXT, encoding);
71860 assert( pMem->flags & MEM_Str || pMem->db->mallocFailed );
71861 pMem->flags &= ~(MEM_Int|MEM_Real|MEM_Blob|MEM_Zero);
71872 SQLITE_PRIVATE void sqlite3VdbeMemInit(Mem *pMem, sqlite3 *db, u16 flags){
71874 pMem->flags = flags;
71875 pMem->db = db;
71876 pMem->szMalloc = 0;
71892 SQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem *pMem){
71893 if( VdbeMemDynamic(pMem) ){
71894 vdbeMemClearExternAndSetNull(pMem);
71896 pMem->flags = MEM_Null;
71907 SQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem *pMem, int n){
71908 sqlite3VdbeMemRelease(pMem);
71909 pMem->flags = MEM_Blob|MEM_Zero;
71910 pMem->n = 0;
71912 pMem->u.nZero = n;
71913 pMem->enc = SQLITE_UTF8;
71914 pMem->z = 0;
71922 static SQLITE_NOINLINE void vdbeReleaseAndSetInt64(Mem *pMem, i64 val){
71923 sqlite3VdbeMemSetNull(pMem);
71924 pMem->u.i = val;
71925 pMem->flags = MEM_Int;
71932 SQLITE_PRIVATE void sqlite3VdbeMemSetInt64(Mem *pMem, i64 val){
71933 if( VdbeMemDynamic(pMem) ){
71934 vdbeReleaseAndSetInt64(pMem, val);
71936 pMem->u.i = val;
71937 pMem->flags = MEM_Int;
71949 Mem *pMem,
71954 assert( pMem->flags==MEM_Null );
71955 pMem->u.zPType = zPType ? zPType : "";
71956 pMem->z = pPtr;
71957 pMem->flags = MEM_Null|MEM_Dyn|MEM_Subtype|MEM_Term;
71958 pMem->eSubtype = 'p';
71959 pMem->xDel = xDestructor ? xDestructor : sqlite3NoopDestructor;
71967 SQLITE_PRIVATE void sqlite3VdbeMemSetDouble(Mem *pMem, double val){
71968 sqlite3VdbeMemSetNull(pMem);
71970 pMem->u.r = val;
71971 pMem->flags = MEM_Real;
71980 SQLITE_PRIVATE void sqlite3VdbeMemSetRowSet(Mem *pMem){
71981 sqlite3 *db = pMem->db;
71983 assert( (pMem->flags & MEM_RowSet)==0 );
71984 sqlite3VdbeMemRelease(pMem);
71985 pMem->zMalloc = sqlite3DbMallocRawNN(db, 64);
71987 pMem->flags = MEM_Null;
71988 pMem->szMalloc = 0;
71990 assert( pMem->zMalloc );
71991 pMem->szMalloc = sqlite3DbMallocSize(db, pMem->zMalloc);
71992 pMem->u.pRowSet = sqlite3RowSetInit(db, pMem->zMalloc, pMem->szMalloc);
71993 assert( pMem->u.pRowSet!=0 );
71994 pMem->flags = MEM_RowSet;
72023 SQLITE_PRIVATE void sqlite3VdbeMemAboutToChange(Vdbe *pVdbe, Mem *pMem){
72027 if( pX->pScopyFrom==pMem ){
72032 pMem->pScopyFrom = 0;
72114 Mem *pMem, /* Memory cell to set to string value */
72124 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
72125 assert( (pMem->flags & MEM_RowSet)==0 );
72129 sqlite3VdbeMemSetNull(pMem);
72133 if( pMem->db ){
72134 iLimit = pMem->db->aLimit[SQLITE_LIMIT_LENGTH];
72165 if( sqlite3VdbeMemClearAndResize(pMem, MAX(nAlloc,32)) ){
72168 memcpy(pMem->z, z, nAlloc);
72170 sqlite3VdbeMemRelease(pMem);
72171 pMem->zMalloc = pMem->z = (char *)z;
72172 pMem->szMalloc = sqlite3DbMallocSize(pMem->db, pMem->zMalloc);
72174 sqlite3VdbeMemRelease(pMem);
72175 pMem->z = (char *)z;
72176 pMem->xDel = xDel;
72180 pMem->n = nByte;
72181 pMem->flags = flags;
72182 pMem->enc = (enc==0 ? SQLITE_UTF8 : enc);
72185 if( pMem->enc!=SQLITE_UTF8 && sqlite3VdbeMemHandleBom(pMem) ){
72216 Mem *pMem /* OUT: Return data in this Mem structure. */
72219 pMem->flags = MEM_Null;
72220 if( SQLITE_OK==(rc = sqlite3VdbeMemClearAndResize(pMem, amt+1)) ){
72221 rc = sqlite3BtreePayload(pCur, offset, amt, pMem->z);
72223 pMem->z[amt] = 0; /* Overrun area used when reading malformed records */
72224 pMem->flags = MEM_Blob;
72225 pMem->n = (int)amt;
72227 sqlite3VdbeMemRelease(pMem);
72236 Mem *pMem /* OUT: Return data in this Mem structure. */
72243 assert( !VdbeMemDynamic(pMem) );
72247 assert( (pMem->flags & MEM_RowSet)==0 );
72252 pMem->z = &zData[offset];
72253 pMem->flags = MEM_Blob|MEM_Ephem;
72254 pMem->n = (int)amt;
72256 rc = vdbeMemFromBtreeResize(pCur, offset, amt, pMem);
72882 Mem *pMem = *ppVal; /* Write result into this Mem object */
72899 if( pMem==0 ){
72900 pMem = *ppVal = sqlite3ValueNew(db);
72901 if( pMem==0 ) return SQLITE_NOMEM_BKPT;
72903 sqlite3VdbeSerialGet(&a[iField-szField], t, pMem);
72904 pMem->enc = ENC(db);
74349 Mem *pMem = pOp->p4.pMem;
74350 if( pMem->flags & MEM_Str ){
74351 zP4 = pMem->z;
74352 }else if( pMem->flags & MEM_Int ){
74353 sqlite3XPrintf(&x, "%lld", pMem->u.i);
74354 }else if( pMem->flags & MEM_Real ){
74355 sqlite3XPrintf(&x, "%.16g", pMem->u.r);
74356 }else if( pMem->flags & MEM_Null ){
74359 assert( pMem->flags & MEM_Blob );
74619 Mem *pMem = &p->aMem[1]; /* First Mem of result set */
74631 releaseMemArray(pMem, 8);
74723 pMem->flags = MEM_Int;
74724 pMem->u.i = i; /* Program counter */
74725 pMem++;
74727 pMem->flags = MEM_Static|MEM_Str|MEM_Term;
74728 pMem->z = (char*)sqlite3OpcodeName(pOp->opcode); /* Opcode */
74729 assert( pMem->z!=0 );
74730 pMem->n = sqlite3Strlen30(pMem->z);
74731 pMem->enc = SQLITE_UTF8;
74732 pMem++;
74735 pMem->flags = MEM_Int;
74736 pMem->u.i = pOp->p1; /* P1 */
74737 pMem++;
74739 pMem->flags = MEM_Int;
74740 pMem->u.i = pOp->p2; /* P2 */
74741 pMem++;
74743 pMem->flags = MEM_Int;
74744 pMem->u.i = pOp->p3; /* P3 */
74745 pMem++;
74747 if( sqlite3VdbeMemClearAndResize(pMem, 100) ){ /* P4 */
74751 pMem->flags = MEM_Str|MEM_Term;
74752 zP4 = displayP4(pOp, pMem->z, pMem->szMalloc);
74753 if( zP4!=pMem->z ){
74754 pMem->n = 0;
74755 sqlite3VdbeMemSetStr(pMem, zP4, -1, SQLITE_UTF8, 0);
74757 assert( pMem->z!=0 );
74758 pMem->n = sqlite3Strlen30(pMem->z);
74759 pMem->enc = SQLITE_UTF8;
74761 pMem++;
74764 if( sqlite3VdbeMemClearAndResize(pMem, 4) ){
74768 pMem->flags = MEM_Str|MEM_Term;
74769 pMem->n = 2;
74770 sqlite3_snprintf(3, pMem->z, "%.2x", pOp->p5); /* P5 */
74771 pMem->enc = SQLITE_UTF8;
74772 pMem++;
74775 if( sqlite3VdbeMemClearAndResize(pMem, 500) ){
74779 pMem->flags = MEM_Str|MEM_Term;
74780 pMem->n = displayComment(pOp, zP4, pMem->z, 500);
74781 pMem->enc = SQLITE_UTF8;
74783 pMem->flags = MEM_Null; /* Comment */
76185 SQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem *pMem, int file_format, u32 *pLen){
76186 int flags = pMem->flags;
76197 i64 i = pMem->u.i;
76224 assert( pMem->db->mallocFailed || flags&(MEM_Str|MEM_Blob) );
76225 assert( pMem->n>=0 );
76226 n = (u32)pMem->n;
76228 n += pMem->u.nZero;
76337 SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(u8 *buf, Mem *pMem, u32 serial_type){
76345 assert( sizeof(v)==sizeof(pMem->u.r) );
76346 memcpy(&v, &pMem->u.r, sizeof(v));
76349 v = pMem->u.i;
76362 assert( pMem->n + ((pMem->flags & MEM_Zero)?pMem->u.nZero:0)
76364 len = pMem->n;
76365 if( len>0 ) memcpy(buf, pMem->z, len);
76394 Mem *pMem /* Memory cell to write value into */
76402 pMem->u.i = *(i64*)&x;
76403 pMem->flags = MEM_Int;
76404 testcase( pMem->u.i<0 );
76420 assert( sizeof(x)==8 && sizeof(pMem->u.r)==8 );
76422 memcpy(&pMem->u.r, &x, sizeof(x));
76423 pMem->flags = sqlite3IsNaN(pMem->u.r) ? MEM_Null : MEM_Real;
76430 Mem *pMem /* Memory cell to write value into */
76435 pMem->flags = MEM_Null|MEM_Zero;
76436 pMem->n = 0;
76437 pMem->u.nZero = 0;
76443 pMem->flags = MEM_Null;
76449 pMem->u.i = ONE_BYTE_INT(buf);
76450 pMem->flags = MEM_Int;
76451 testcase( pMem->u.i<0 );
76457 pMem->u.i = TWO_BYTE_INT(buf);
76458 pMem->flags = MEM_Int;
76459 testcase( pMem->u.i<0 );
76465 pMem->u.i = THREE_BYTE_INT(buf);
76466 pMem->flags = MEM_Int;
76467 testcase( pMem->u.i<0 );
76473 pMem->u.i = FOUR_BYTE_INT(buf);
76476 if( buf[0]&0x80 ) pMem->u.i |= 0xffffffff80000000LL;
76478 pMem->flags = MEM_Int;
76479 testcase( pMem->u.i<0 );
76485 pMem->u.i = FOUR_BYTE_UINT(buf+2) + (((i64)1)<<32)*TWO_BYTE_INT(buf);
76486 pMem->flags = MEM_Int;
76487 testcase( pMem->u.i<0 );
76494 return serialGet(buf,serial_type,pMem);
76500 pMem->u.i = serial_type-8;
76501 pMem->flags = MEM_Int;
76510 pMem->z = (char *)buf;
76511 pMem->n = (serial_type-12)/2;
76512 pMem->flags = aFlag[serial_type&1];
76513 return pMem->n;
76563 Mem *pMem = p->aMem;
76566 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
76574 pMem->enc = pKeyInfo->enc;
76575 pMem->db = pKeyInfo->db;
76577 pMem->szMalloc = 0;
76578 pMem->z = 0;
76579 d += sqlite3VdbeSerialGet(&aKey[d], serial_type, pMem);
76580 pMem++;
77563 Mem *pMem = &v->aVar[iVar-1];
77565 if( 0==(pMem->flags & MEM_Null) ){
77568 sqlite3VdbeMemCopy((Mem *)pRet, pMem);
77645 Mem *pMem = &p->aMem[i];
77646 if( pMem->zMalloc ) sqlite3VdbeMemRelease(pMem);
77920 Mem *pMem = (Mem*)pVal;
77921 return ((pMem->flags & MEM_Subtype) ? pMem->eSubtype : 0);
78543 Mem *pMem = p->pMem;
78544 assert( (pMem->flags & MEM_Agg)==0 );
78546 sqlite3VdbeMemSetNull(pMem);
78547 pMem->z = 0;
78549 sqlite3VdbeMemClearAndResize(pMem, nByte);
78550 pMem->flags = MEM_Agg;
78551 pMem->u.pDef = p->pFunc;
78552 if( pMem->z ){
78553 memset(pMem->z, 0, nByte);
78556 return (void*)pMem->z;
78568 if( (p->pMem->flags & MEM_Agg)==0 ){
78571 return (void*)p->pMem->z;
78670 assert( p && p->pMem && p->pFunc && p->pFunc->xFinalize );
78671 return p->pMem->n;
79481 Mem *pMem;
79518 pMem = *ppValue = &p->pUnpacked->aMem[iIdx];
79520 sqlite3VdbeMemSetInt64(pMem, p->iKey1);
79524 if( pMem->flags & MEM_Int ){
79525 sqlite3VdbeMemRealify(pMem);
79572 Mem *pMem;
79601 pMem = &pUnpack->aMem[iIdx];
79603 sqlite3VdbeMemSetInt64(pMem, p->iKey2);
79605 pMem = (sqlite3_value *)columnNullValue();
79622 pMem = &p->aNew[iIdx];
79623 if( pMem->flags==0 ){
79625 sqlite3VdbeMemSetInt64(pMem, p->iKey2);
79627 rc = sqlite3VdbeMemCopy(pMem, &p->v->aMem[p->iNewReg+1+iIdx]);
79632 *ppValue = pMem;
80116 Mem *pMem = iCur>0 ? &p->aMem[p->nMem-iCur] : p->aMem;
80129 if( SQLITE_OK==sqlite3VdbeMemClearAndResize(pMem, nByte) ){
80130 p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->z;
80138 &pMem->z[ROUND8(sizeof(VdbeCursor))+2*sizeof(u32)*nField];
80233 Mem *pMem = (Mem*)pVal;
80234 applyNumericAffinity(pMem, 0);
80258 static u16 SQLITE_NOINLINE computeNumericType(Mem *pMem){
80259 assert( (pMem->flags & (MEM_Int|MEM_Real))==0 );
80260 assert( (pMem->flags & (MEM_Str|MEM_Blob))!=0 );
80261 if( sqlite3AtoF(pMem->z, &pMem->u.r, pMem->n, pMem->enc)==0 ){
80264 if( sqlite3Atoi64(pMem->z, &pMem->u.i, pMem->n, pMem->enc)==0 ){
80277 static u16 numericType(Mem *pMem){
80278 if( pMem->flags & (MEM_Int|MEM_Real) ){
80279 return pMem->flags & (MEM_Int|MEM_Real);
80281 if( pMem->flags & (MEM_Str|MEM_Blob) ){
80282 return computeNumericType(pMem);
80292 SQLITE_PRIVATE void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf){
80294 int f = pMem->flags;
80314 sqlite3_snprintf(100, zCsr, "%d[", pMem->n);
80316 for(i=0; i<16 && i<pMem->n; i++){
80317 sqlite3_snprintf(100, zCsr, "%02X", ((int)pMem->z[i] & 0xFF));
80320 for(i=0; i<16 && i<pMem->n; i++){
80321 char z = pMem->z[i];
80327 sqlite3_snprintf(100, zCsr,"+%dz",pMem->u.nZero);
80347 sqlite3_snprintf(100, &zBuf[k], "%d", pMem->n);
80350 for(j=0; j<15 && j<pMem->n; j++){
80351 u8 c = pMem->z[j];
80359 sqlite3_snprintf(100,&zBuf[k], encnames[pMem->enc]);
81315 Mem *pMem;
81368 pMem = p->pResultSet = &aMem[pOp->p1];
81370 assert( memIsValid(&pMem[i]) );
81371 Deephemeralize(&pMem[i]);
81372 assert( (pMem[i].flags & MEM_Ephem)==0
81373 || (pMem[i].flags & (MEM_Str|MEM_Blob))==0 );
81374 sqlite3VdbeMemNulTerminate(&pMem[i]);
81375 REGISTER_TRACE(pOp->p1+i, &pMem[i]);
82580 sqlite3VdbeMemShallowCopy(pDest, pOp->p4.pMem, MEM_Static);
84259 Mem *pMem; /* Register holding largest rowid for AUTOINCREMENT */
84322 pMem = &pFrame->aMem[pOp->p3];
84326 pMem = &aMem[pOp->p3];
84327 memAboutToChange(p, pMem);
84329 assert( memIsValid(pMem) );
84331 REGISTER_TRACE(pOp->p3, pMem);
84332 sqlite3VdbeMemIntegerify(pMem);
84333 assert( (pMem->flags & MEM_Int)!=0 ); /* mem(P3) holds an integer */
84334 if( pMem->u.i==MAX_ROWID || pC->useRandomRowid ){
84338 if( v<pMem->u.i+1 ){
84339 v = pMem->u.i + 1;
84341 pMem->u.i = v;
85858 Mem *pMem; /* Used to iterate through memory cells */
85932 for(pMem=VdbeFrameMem(pFrame); pMem!=pEnd; pMem++){
85933 pMem->flags = MEM_Undefined;
85934 pMem->db = db;
86205 pCtx->pMem = 0;
86218 Mem *pMem;
86223 pMem = &aMem[pOp->p3];
86229 if( pCtx->pMem != pMem ){
86230 pCtx->pMem = pMem;
86241 pMem->n++;
86279 Mem *pMem;
86281 pMem = &aMem[pOp->p1];
86282 assert( (pMem->flags & ~(MEM_Null|MEM_Agg))==0 );
86283 rc = sqlite3VdbeMemFinalize(pMem, pOp->p4.pFunc);
86285 sqlite3VdbeError(p, "%s", sqlite3_value_text(pMem));
86288 sqlite3VdbeChangeEncoding(pMem, encoding);
86289 UPDATE_MAX_BLOBSIZE(pMem);
86290 if( sqlite3VdbeMemTooBig(pMem) ){
86311 Mem *pMem; /* Write results here */
86327 for(i=0, pMem = &aMem[pOp->p3]; i<3; i++, pMem++){
86328 sqlite3VdbeMemSetInt64(pMem, (i64)aRes[i]);