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;
35348 void *pMem;
35350 pMem = osMmap(0, nMap,
35354 if( pMem==MAP_FAILED ){
35359 pMem = sqlite3_malloc64(szRegion);
35360 if( pMem==0 ){
35364 memset(pMem, 0, szRegion);
35368 pShmNode->apRegion[pShmNode->nRegion+i] = &((char*)pMem)[szRegion*i];
39994 MUTEX_LOGIC( sqlite3_mutex *pMem; ) /* The memsys static mutex */
39996 MUTEX_LOGIC( pMem = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM); )
39998 sqlite3_mutex_enter(pMem);
40025 sqlite3_mutex_leave(pMem);
71300 SQLITE_PRIVATE int sqlite3VdbeChangeEncoding(Mem *pMem, int desiredEnc){
71304 assert( (pMem->flags&MEM_RowSet)==0 );
71307 if( !(pMem->flags&MEM_Str) || pMem->enc==desiredEnc ){
71310 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
71318 rc = sqlite3VdbeMemTranslate(pMem, (u8)desiredEnc);
71320 assert(rc==SQLITE_OK || pMem->enc!=desiredEnc);
71321 assert(rc==SQLITE_NOMEM || pMem->enc==desiredEnc);
71335 SQLITE_PRIVATE SQLITE_NOINLINE int sqlite3VdbeMemGrow(Mem *pMem, int n, int bPreserve){
71336 assert( sqlite3VdbeCheckMemInvariants(pMem) );
71337 assert( (pMem->flags&MEM_RowSet)==0 );
71338 testcase( pMem->db==0 );
71342 assert( bPreserve==0 || pMem->flags&(MEM_Blob|MEM_Str) );
71343 testcase( bPreserve && pMem->z==0 );
71345 assert( pMem->szMalloc==0
71346 || pMem->szMalloc==sqlite3DbMallocSize(pMem->db, pMem->zMalloc) );
71348 if( pMem->szMalloc>0 && bPreserve && pMem->z==pMem->zMalloc ){
71349 pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n);
71352 if( pMem->szMalloc>0 ) sqlite3DbFreeNN(pMem->db, pMem->zMalloc);
71353 pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, n);
71355 if( pMem->zMalloc==0 ){
71356 sqlite3VdbeMemSetNull(pMem);
71357 pMem->z = 0;
71358 pMem->szMalloc = 0;
71361 pMem->szMalloc = sqlite3DbMallocSize(pMem->db, pMem->zMalloc);
71364 if( bPreserve && pMem->z ){
71365 assert( pMem->z!=pMem->zMalloc );
71366 memcpy(pMem->zMalloc, pMem->z, pMem->n);
71368 if( (pMem->flags&MEM_Dyn)!=0 ){
71369 assert( pMem->xDel!=0 && pMem->xDel!=SQLITE_DYNAMIC );
71370 pMem->xDel((void *)(pMem->z));
71373 pMem->z = pMem->zMalloc;
71374 pMem->flags &= ~(MEM_Dyn|MEM_Ephem|MEM_Static);
71391 SQLITE_PRIVATE int sqlite3VdbeMemClearAndResize(Mem *pMem, int szNew){
71393 assert( (pMem->flags & MEM_Dyn)==0 || pMem->szMalloc==0 );
71394 if( pMem->szMalloc<szNew ){
71395 return sqlite3VdbeMemGrow(pMem, szNew, 0);
71397 assert( (pMem->flags & MEM_Dyn)==0 );
71398 pMem->z = pMem->zMalloc;
71399 pMem->flags &= (MEM_Null|MEM_Int|MEM_Real);
71407 static SQLITE_NOINLINE int vdbeMemAddTerminator(Mem *pMem){
71408 if( sqlite3VdbeMemGrow(pMem, pMem->n+2, 1) ){
71411 pMem->z[pMem->n] = 0;
71412 pMem->z[pMem->n+1] = 0;
71413 pMem->flags |= MEM_Term;
71423 SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem *pMem){
71424 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
71425 assert( (pMem->flags&MEM_RowSet)==0 );
71426 if( (pMem->flags & (MEM_Str|MEM_Blob))!=0 ){
71427 if( ExpandBlob(pMem) ) return SQLITE_NOMEM;
71428 if( pMem->szMalloc==0 || pMem->z!=pMem->zMalloc ){
71429 int rc = vdbeMemAddTerminator(pMem);
71433 pMem->flags &= ~MEM_Ephem;
71435 pMem->pScopyFrom = 0;
71446 SQLITE_PRIVATE int sqlite3VdbeMemExpandBlob(Mem *pMem){
71448 assert( pMem->flags & MEM_Zero );
71449 assert( pMem->flags&MEM_Blob );
71450 assert( (pMem->flags&MEM_RowSet)==0 );
71451 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
71454 nByte = pMem->n + pMem->u.nZero;
71458 if( sqlite3VdbeMemGrow(pMem, nByte, 1) ){
71462 memset(&pMem->z[pMem->n], 0, pMem->u.nZero);
71463 pMem->n += pMem->u.nZero;
71464 pMem->flags &= ~(MEM_Zero|MEM_Term);
71472 SQLITE_PRIVATE int sqlite3VdbeMemNulTerminate(Mem *pMem){
71473 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
71474 testcase( (pMem->flags & (MEM_Term|MEM_Str))==(MEM_Term|MEM_Str) );
71475 testcase( (pMem->flags & (MEM_Term|MEM_Str))==0 );
71476 if( (pMem->flags & (MEM_Term|MEM_Str))!=MEM_Str ){
71479 return vdbeMemAddTerminator(pMem);
71497 SQLITE_PRIVATE int sqlite3VdbeMemStringify(Mem *pMem, u8 enc, u8 bForce){
71498 int fg = pMem->flags;
71501 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
71505 assert( (pMem->flags&MEM_RowSet)==0 );
71506 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
71509 if( sqlite3VdbeMemClearAndResize(pMem, nByte) ){
71510 pMem->enc = 0;
71521 sqlite3_snprintf(nByte, pMem->z, "%lld", pMem->u.i);
71524 sqlite3_snprintf(nByte, pMem->z, "%!.15g", pMem->u.r);
71526 pMem->n = sqlite3Strlen30(pMem->z);
71527 pMem->enc = SQLITE_UTF8;
71528 pMem->flags |= MEM_Str|MEM_Term;
71529 if( bForce ) pMem->flags &= ~(MEM_Int|MEM_Real);
71530 sqlite3VdbeChangeEncoding(pMem, enc);
71542 SQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem *pMem, FuncDef *pFunc){
71547 assert( (pMem->flags & MEM_Null)!=0 || pFunc==pMem->u.pDef );
71548 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
71552 t.db = pMem->db;
71554 ctx.pMem = pMem;
71557 assert( (pMem->flags & MEM_Dyn)==0 );
71558 if( pMem->szMalloc>0 ) sqlite3DbFreeNN(pMem->db, pMem->zMalloc);
71559 memcpy(pMem, &t, sizeof(t));
71671 static SQLITE_NOINLINE i64 memIntValue(Mem *pMem){
71673 sqlite3Atoi64(pMem->z, &value, pMem->n, pMem->enc);
71676 SQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem *pMem){
71678 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
71679 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
71680 flags = pMem->flags;
71682 return pMem->u.i;
71684 return doubleToInt64(pMem->u.r);
71686 assert( pMem->z || pMem->n==0 );
71687 return memIntValue(pMem);
71699 static SQLITE_NOINLINE double memRealValue(Mem *pMem){
71702 sqlite3AtoF(pMem->z, &val, pMem->n, pMem->enc);
71705 SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem *pMem){
71706 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
71707 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
71708 if( pMem->flags & MEM_Real ){
71709 return pMem->u.r;
71710 }else if( pMem->flags & MEM_Int ){
71711 return (double)pMem->u.i;
71712 }else if( pMem->flags & (MEM_Str|MEM_Blob) ){
71713 return memRealValue(pMem);
71724 SQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem *pMem){
71726 assert( pMem->flags & MEM_Real );
71727 assert( (pMem->flags & MEM_RowSet)==0 );
71728 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
71729 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
71731 ix = doubleToInt64(pMem->u.r);
71743 if( pMem->u.r==ix && ix>SMALLEST_INT64 && ix<LARGEST_INT64 ){
71744 pMem->u.i = ix;
71745 MemSetTypeFlag(pMem, MEM_Int);
71752 SQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem *pMem){
71753 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
71754 assert( (pMem->flags & MEM_RowSet)==0 );
71755 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
71757 pMem->u.i = sqlite3VdbeIntValue(pMem);
71758 MemSetTypeFlag(pMem, MEM_Int);
71766 SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem *pMem){
71767 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
71768 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
71770 pMem->u.r = sqlite3VdbeRealValue(pMem);
71771 MemSetTypeFlag(pMem, MEM_Real);
71783 SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem *pMem){
71784 if( (pMem->flags & (MEM_Int|MEM_Real|MEM_Null))==0 ){
71786 assert( (pMem->flags & (MEM_Blob|MEM_Str))!=0 );
71787 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
71788 rc = sqlite3Atoi64(pMem->z, &pMem->u.i, pMem->n, pMem->enc);
71790 MemSetTypeFlag(pMem, MEM_Int);
71792 i64 i = pMem->u.i;
71793 sqlite3AtoF(pMem->z, &pMem->u.r, pMem->n, pMem->enc);
71794 if( rc==1 && pMem->u.r==(double)i ){
71795 pMem->u.i = i;
71796 MemSetTypeFlag(pMem, MEM_Int);
71798 MemSetTypeFlag(pMem, MEM_Real);
71802 assert( (pMem->flags & (MEM_Int|MEM_Real|MEM_Null))!=0 );
71803 pMem->flags &= ~(MEM_Str|MEM_Blob|MEM_Zero);
71814 SQLITE_PRIVATE void sqlite3VdbeMemCast(Mem *pMem, u8 aff, u8 encoding){
71815 if( pMem->flags & MEM_Null ) return;
71818 if( (pMem->flags & MEM_Blob)==0 ){
71819 sqlite3ValueApplyAffinity(pMem, SQLITE_AFF_TEXT, encoding);
71820 assert( pMem->flags & MEM_Str || pMem->db->mallocFailed );
71821 if( pMem->flags & MEM_Str ) MemSetTypeFlag(pMem, MEM_Blob);
71823 pMem->flags &= ~(MEM_TypeMask&~MEM_Blob);
71828 sqlite3VdbeMemNumerify(pMem);
71832 sqlite3VdbeMemIntegerify(pMem);
71836 sqlite3VdbeMemRealify(pMem);
71842 pMem->flags |= (pMem->flags&MEM_Blob)>>3;
71843 sqlite3ValueApplyAffinity(pMem, SQLITE_AFF_TEXT, encoding);
71844 assert( pMem->flags & MEM_Str || pMem->db->mallocFailed );
71845 pMem->flags &= ~(MEM_Int|MEM_Real|MEM_Blob|MEM_Zero);
71856 SQLITE_PRIVATE void sqlite3VdbeMemInit(Mem *pMem, sqlite3 *db, u16 flags){
71858 pMem->flags = flags;
71859 pMem->db = db;
71860 pMem->szMalloc = 0;
71876 SQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem *pMem){
71877 if( VdbeMemDynamic(pMem) ){
71878 vdbeMemClearExternAndSetNull(pMem);
71880 pMem->flags = MEM_Null;
71891 SQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem *pMem, int n){
71892 sqlite3VdbeMemRelease(pMem);
71893 pMem->flags = MEM_Blob|MEM_Zero;
71894 pMem->n = 0;
71896 pMem->u.nZero = n;
71897 pMem->enc = SQLITE_UTF8;
71898 pMem->z = 0;
71906 static SQLITE_NOINLINE void vdbeReleaseAndSetInt64(Mem *pMem, i64 val){
71907 sqlite3VdbeMemSetNull(pMem);
71908 pMem->u.i = val;
71909 pMem->flags = MEM_Int;
71916 SQLITE_PRIVATE void sqlite3VdbeMemSetInt64(Mem *pMem, i64 val){
71917 if( VdbeMemDynamic(pMem) ){
71918 vdbeReleaseAndSetInt64(pMem, val);
71920 pMem->u.i = val;
71921 pMem->flags = MEM_Int;
71933 Mem *pMem,
71938 assert( pMem->flags==MEM_Null );
71939 pMem->u.zPType = zPType ? zPType : "";
71940 pMem->z = pPtr;
71941 pMem->flags = MEM_Null|MEM_Dyn|MEM_Subtype|MEM_Term;
71942 pMem->eSubtype = 'p';
71943 pMem->xDel = xDestructor ? xDestructor : sqlite3NoopDestructor;
71951 SQLITE_PRIVATE void sqlite3VdbeMemSetDouble(Mem *pMem, double val){
71952 sqlite3VdbeMemSetNull(pMem);
71954 pMem->u.r = val;
71955 pMem->flags = MEM_Real;
71964 SQLITE_PRIVATE void sqlite3VdbeMemSetRowSet(Mem *pMem){
71965 sqlite3 *db = pMem->db;
71967 assert( (pMem->flags & MEM_RowSet)==0 );
71968 sqlite3VdbeMemRelease(pMem);
71969 pMem->zMalloc = sqlite3DbMallocRawNN(db, 64);
71971 pMem->flags = MEM_Null;
71972 pMem->szMalloc = 0;
71974 assert( pMem->zMalloc );
71975 pMem->szMalloc = sqlite3DbMallocSize(db, pMem->zMalloc);
71976 pMem->u.pRowSet = sqlite3RowSetInit(db, pMem->zMalloc, pMem->szMalloc);
71977 assert( pMem->u.pRowSet!=0 );
71978 pMem->flags = MEM_RowSet;
72007 SQLITE_PRIVATE void sqlite3VdbeMemAboutToChange(Vdbe *pVdbe, Mem *pMem){
72011 if( pX->pScopyFrom==pMem ){
72016 pMem->pScopyFrom = 0;
72098 Mem *pMem, /* Memory cell to set to string value */
72108 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
72109 assert( (pMem->flags & MEM_RowSet)==0 );
72113 sqlite3VdbeMemSetNull(pMem);
72117 if( pMem->db ){
72118 iLimit = pMem->db->aLimit[SQLITE_LIMIT_LENGTH];
72149 if( sqlite3VdbeMemClearAndResize(pMem, MAX(nAlloc,32)) ){
72152 memcpy(pMem->z, z, nAlloc);
72154 sqlite3VdbeMemRelease(pMem);
72155 pMem->zMalloc = pMem->z = (char *)z;
72156 pMem->szMalloc = sqlite3DbMallocSize(pMem->db, pMem->zMalloc);
72158 sqlite3VdbeMemRelease(pMem);
72159 pMem->z = (char *)z;
72160 pMem->xDel = xDel;
72164 pMem->n = nByte;
72165 pMem->flags = flags;
72166 pMem->enc = (enc==0 ? SQLITE_UTF8 : enc);
72169 if( pMem->enc!=SQLITE_UTF8 && sqlite3VdbeMemHandleBom(pMem) ){
72200 Mem *pMem /* OUT: Return data in this Mem structure. */
72203 pMem->flags = MEM_Null;
72204 if( SQLITE_OK==(rc = sqlite3VdbeMemClearAndResize(pMem, amt+1)) ){
72205 rc = sqlite3BtreePayload(pCur, offset, amt, pMem->z);
72207 pMem->z[amt] = 0; /* Overrun area used when reading malformed records */
72208 pMem->flags = MEM_Blob;
72209 pMem->n = (int)amt;
72211 sqlite3VdbeMemRelease(pMem);
72220 Mem *pMem /* OUT: Return data in this Mem structure. */
72227 assert( !VdbeMemDynamic(pMem) );
72231 assert( (pMem->flags & MEM_RowSet)==0 );
72236 pMem->z = &zData[offset];
72237 pMem->flags = MEM_Blob|MEM_Ephem;
72238 pMem->n = (int)amt;
72240 rc = vdbeMemFromBtreeResize(pCur, offset, amt, pMem);
72866 Mem *pMem = *ppVal; /* Write result into this Mem object */
72883 if( pMem==0 ){
72884 pMem = *ppVal = sqlite3ValueNew(db);
72885 if( pMem==0 ) return SQLITE_NOMEM_BKPT;
72887 sqlite3VdbeSerialGet(&a[iField-szField], t, pMem);
72888 pMem->enc = ENC(db);
74333 Mem *pMem = pOp->p4.pMem;
74334 if( pMem->flags & MEM_Str ){
74335 zP4 = pMem->z;
74336 }else if( pMem->flags & MEM_Int ){
74337 sqlite3XPrintf(&x, "%lld", pMem->u.i);
74338 }else if( pMem->flags & MEM_Real ){
74339 sqlite3XPrintf(&x, "%.16g", pMem->u.r);
74340 }else if( pMem->flags & MEM_Null ){
74343 assert( pMem->flags & MEM_Blob );
74603 Mem *pMem = &p->aMem[1]; /* First Mem of result set */
74615 releaseMemArray(pMem, 8);
74707 pMem->flags = MEM_Int;
74708 pMem->u.i = i; /* Program counter */
74709 pMem++;
74711 pMem->flags = MEM_Static|MEM_Str|MEM_Term;
74712 pMem->z = (char*)sqlite3OpcodeName(pOp->opcode); /* Opcode */
74713 assert( pMem->z!=0 );
74714 pMem->n = sqlite3Strlen30(pMem->z);
74715 pMem->enc = SQLITE_UTF8;
74716 pMem++;
74719 pMem->flags = MEM_Int;
74720 pMem->u.i = pOp->p1; /* P1 */
74721 pMem++;
74723 pMem->flags = MEM_Int;
74724 pMem->u.i = pOp->p2; /* P2 */
74725 pMem++;
74727 pMem->flags = MEM_Int;
74728 pMem->u.i = pOp->p3; /* P3 */
74729 pMem++;
74731 if( sqlite3VdbeMemClearAndResize(pMem, 100) ){ /* P4 */
74735 pMem->flags = MEM_Str|MEM_Term;
74736 zP4 = displayP4(pOp, pMem->z, pMem->szMalloc);
74737 if( zP4!=pMem->z ){
74738 pMem->n = 0;
74739 sqlite3VdbeMemSetStr(pMem, zP4, -1, SQLITE_UTF8, 0);
74741 assert( pMem->z!=0 );
74742 pMem->n = sqlite3Strlen30(pMem->z);
74743 pMem->enc = SQLITE_UTF8;
74745 pMem++;
74748 if( sqlite3VdbeMemClearAndResize(pMem, 4) ){
74752 pMem->flags = MEM_Str|MEM_Term;
74753 pMem->n = 2;
74754 sqlite3_snprintf(3, pMem->z, "%.2x", pOp->p5); /* P5 */
74755 pMem->enc = SQLITE_UTF8;
74756 pMem++;
74759 if( sqlite3VdbeMemClearAndResize(pMem, 500) ){
74763 pMem->flags = MEM_Str|MEM_Term;
74764 pMem->n = displayComment(pOp, zP4, pMem->z, 500);
74765 pMem->enc = SQLITE_UTF8;
74767 pMem->flags = MEM_Null; /* Comment */
76169 SQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem *pMem, int file_format, u32 *pLen){
76170 int flags = pMem->flags;
76181 i64 i = pMem->u.i;
76208 assert( pMem->db->mallocFailed || flags&(MEM_Str|MEM_Blob) );
76209 assert( pMem->n>=0 );
76210 n = (u32)pMem->n;
76212 n += pMem->u.nZero;
76321 SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(u8 *buf, Mem *pMem, u32 serial_type){
76329 assert( sizeof(v)==sizeof(pMem->u.r) );
76330 memcpy(&v, &pMem->u.r, sizeof(v));
76333 v = pMem->u.i;
76346 assert( pMem->n + ((pMem->flags & MEM_Zero)?pMem->u.nZero:0)
76348 len = pMem->n;
76349 if( len>0 ) memcpy(buf, pMem->z, len);
76378 Mem *pMem /* Memory cell to write value into */
76386 pMem->u.i = *(i64*)&x;
76387 pMem->flags = MEM_Int;
76388 testcase( pMem->u.i<0 );
76404 assert( sizeof(x)==8 && sizeof(pMem->u.r)==8 );
76406 memcpy(&pMem->u.r, &x, sizeof(x));
76407 pMem->flags = sqlite3IsNaN(pMem->u.r) ? MEM_Null : MEM_Real;
76414 Mem *pMem /* Memory cell to write value into */
76419 pMem->flags = MEM_Null|MEM_Zero;
76420 pMem->n = 0;
76421 pMem->u.nZero = 0;
76427 pMem->flags = MEM_Null;
76433 pMem->u.i = ONE_BYTE_INT(buf);
76434 pMem->flags = MEM_Int;
76435 testcase( pMem->u.i<0 );
76441 pMem->u.i = TWO_BYTE_INT(buf);
76442 pMem->flags = MEM_Int;
76443 testcase( pMem->u.i<0 );
76449 pMem->u.i = THREE_BYTE_INT(buf);
76450 pMem->flags = MEM_Int;
76451 testcase( pMem->u.i<0 );
76457 pMem->u.i = FOUR_BYTE_INT(buf);
76460 if( buf[0]&0x80 ) pMem->u.i |= 0xffffffff80000000LL;
76462 pMem->flags = MEM_Int;
76463 testcase( pMem->u.i<0 );
76469 pMem->u.i = FOUR_BYTE_UINT(buf+2) + (((i64)1)<<32)*TWO_BYTE_INT(buf);
76470 pMem->flags = MEM_Int;
76471 testcase( pMem->u.i<0 );
76478 return serialGet(buf,serial_type,pMem);
76484 pMem->u.i = serial_type-8;
76485 pMem->flags = MEM_Int;
76494 pMem->z = (char *)buf;
76495 pMem->n = (serial_type-12)/2;
76496 pMem->flags = aFlag[serial_type&1];
76497 return pMem->n;
76547 Mem *pMem = p->aMem;
76550 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
76558 pMem->enc = pKeyInfo->enc;
76559 pMem->db = pKeyInfo->db;
76561 pMem->szMalloc = 0;
76562 pMem->z = 0;
76563 d += sqlite3VdbeSerialGet(&aKey[d], serial_type, pMem);
76564 pMem++;
77547 Mem *pMem = &v->aVar[iVar-1];
77549 if( 0==(pMem->flags & MEM_Null) ){
77552 sqlite3VdbeMemCopy((Mem *)pRet, pMem);
77629 Mem *pMem = &p->aMem[i];
77630 if( pMem->zMalloc ) sqlite3VdbeMemRelease(pMem);
77904 Mem *pMem = (Mem*)pVal;
77905 return ((pMem->flags & MEM_Subtype) ? pMem->eSubtype : 0);
78527 Mem *pMem = p->pMem;
78528 assert( (pMem->flags & MEM_Agg)==0 );
78530 sqlite3VdbeMemSetNull(pMem);
78531 pMem->z = 0;
78533 sqlite3VdbeMemClearAndResize(pMem, nByte);
78534 pMem->flags = MEM_Agg;
78535 pMem->u.pDef = p->pFunc;
78536 if( pMem->z ){
78537 memset(pMem->z, 0, nByte);
78540 return (void*)pMem->z;
78552 if( (p->pMem->flags & MEM_Agg)==0 ){
78555 return (void*)p->pMem->z;
78654 assert( p && p->pMem && p->pFunc && p->pFunc->xFinalize );
78655 return p->pMem->n;
79465 Mem *pMem;
79502 pMem = *ppValue = &p->pUnpacked->aMem[iIdx];
79504 sqlite3VdbeMemSetInt64(pMem, p->iKey1);
79508 if( pMem->flags & MEM_Int ){
79509 sqlite3VdbeMemRealify(pMem);
79556 Mem *pMem;
79585 pMem = &pUnpack->aMem[iIdx];
79587 sqlite3VdbeMemSetInt64(pMem, p->iKey2);
79589 pMem = (sqlite3_value *)columnNullValue();
79606 pMem = &p->aNew[iIdx];
79607 if( pMem->flags==0 ){
79609 sqlite3VdbeMemSetInt64(pMem, p->iKey2);
79611 rc = sqlite3VdbeMemCopy(pMem, &p->v->aMem[p->iNewReg+1+iIdx]);
79616 *ppValue = pMem;
80100 Mem *pMem = iCur>0 ? &p->aMem[p->nMem-iCur] : p->aMem;
80113 if( SQLITE_OK==sqlite3VdbeMemClearAndResize(pMem, nByte) ){
80114 p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->z;
80122 &pMem->z[ROUND8(sizeof(VdbeCursor))+2*sizeof(u32)*nField];
80217 Mem *pMem = (Mem*)pVal;
80218 applyNumericAffinity(pMem, 0);
80242 static u16 SQLITE_NOINLINE computeNumericType(Mem *pMem){
80243 assert( (pMem->flags & (MEM_Int|MEM_Real))==0 );
80244 assert( (pMem->flags & (MEM_Str|MEM_Blob))!=0 );
80245 if( sqlite3AtoF(pMem->z, &pMem->u.r, pMem->n, pMem->enc)==0 ){
80248 if( sqlite3Atoi64(pMem->z, &pMem->u.i, pMem->n, pMem->enc)==0 ){
80261 static u16 numericType(Mem *pMem){
80262 if( pMem->flags & (MEM_Int|MEM_Real) ){
80263 return pMem->flags & (MEM_Int|MEM_Real);
80265 if( pMem->flags & (MEM_Str|MEM_Blob) ){
80266 return computeNumericType(pMem);
80276 SQLITE_PRIVATE void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf){
80278 int f = pMem->flags;
80298 sqlite3_snprintf(100, zCsr, "%d[", pMem->n);
80300 for(i=0; i<16 && i<pMem->n; i++){
80301 sqlite3_snprintf(100, zCsr, "%02X", ((int)pMem->z[i] & 0xFF));
80304 for(i=0; i<16 && i<pMem->n; i++){
80305 char z = pMem->z[i];
80311 sqlite3_snprintf(100, zCsr,"+%dz",pMem->u.nZero);
80331 sqlite3_snprintf(100, &zBuf[k], "%d", pMem->n);
80334 for(j=0; j<15 && j<pMem->n; j++){
80335 u8 c = pMem->z[j];
80343 sqlite3_snprintf(100,&zBuf[k], encnames[pMem->enc]);
81299 Mem *pMem;
81352 pMem = p->pResultSet = &aMem[pOp->p1];
81354 assert( memIsValid(&pMem[i]) );
81355 Deephemeralize(&pMem[i]);
81356 assert( (pMem[i].flags & MEM_Ephem)==0
81357 || (pMem[i].flags & (MEM_Str|MEM_Blob))==0 );
81358 sqlite3VdbeMemNulTerminate(&pMem[i]);
81359 REGISTER_TRACE(pOp->p1+i, &pMem[i]);
82564 sqlite3VdbeMemShallowCopy(pDest, pOp->p4.pMem, MEM_Static);
84243 Mem *pMem; /* Register holding largest rowid for AUTOINCREMENT */
84306 pMem = &pFrame->aMem[pOp->p3];
84310 pMem = &aMem[pOp->p3];
84311 memAboutToChange(p, pMem);
84313 assert( memIsValid(pMem) );
84315 REGISTER_TRACE(pOp->p3, pMem);
84316 sqlite3VdbeMemIntegerify(pMem);
84317 assert( (pMem->flags & MEM_Int)!=0 ); /* mem(P3) holds an integer */
84318 if( pMem->u.i==MAX_ROWID || pC->useRandomRowid ){
84322 if( v<pMem->u.i+1 ){
84323 v = pMem->u.i + 1;
84325 pMem->u.i = v;
85842 Mem *pMem; /* Used to iterate through memory cells */
85916 for(pMem=VdbeFrameMem(pFrame); pMem!=pEnd; pMem++){
85917 pMem->flags = MEM_Undefined;
85918 pMem->db = db;
86189 pCtx->pMem = 0;
86202 Mem *pMem;
86207 pMem = &aMem[pOp->p3];
86213 if( pCtx->pMem != pMem ){
86214 pCtx->pMem = pMem;
86225 pMem->n++;
86263 Mem *pMem;
86265 pMem = &aMem[pOp->p1];
86266 assert( (pMem->flags & ~(MEM_Null|MEM_Agg))==0 );
86267 rc = sqlite3VdbeMemFinalize(pMem, pOp->p4.pFunc);
86269 sqlite3VdbeError(p, "%s", sqlite3_value_text(pMem));
86272 sqlite3VdbeChangeEncoding(pMem, encoding);
86273 UPDATE_MAX_BLOBSIZE(pMem);
86274 if( sqlite3VdbeMemTooBig(pMem) ){
86295 Mem *pMem; /* Write results here */
86311 for(i=0, pMem = &aMem[pOp->p3]; i<3; i++, pMem++){
86312 sqlite3VdbeMemSetInt64(pMem, (i64)aRes[i]);