Lines Matching defs:pMem
10328 Mem *pMem; /* Used when p4type is P4_MEM */
15531 Mem *pMem; /* Memory cell used to store aggregate context */
15704 SQLITE_PRIVATE int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve);
15705 SQLITE_PRIVATE int sqlite3VdbeMemClearAndResize(Mem *pMem, int n);
15742 SQLITE_PRIVATE void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf);
15744 SQLITE_PRIVATE int sqlite3VdbeMemHandleBom(Mem *pMem);
24243 ** This routine transforms the internal text encoding used by pMem to
24245 ** encoding, or if *pMem does not contain a string value.
24247 SQLITE_PRIVATE SQLITE_NOINLINE int sqlite3VdbeMemTranslate(Mem *pMem, u8 desiredEnc){
24255 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
24256 assert( pMem->flags&MEM_Str );
24257 assert( pMem->enc!=desiredEnc );
24258 assert( pMem->enc!=0 );
24259 assert( pMem->n>=0 );
24264 sqlite3VdbeMemPrettyPrint(pMem, zBuf);
24273 if( pMem->enc!=SQLITE_UTF8 && desiredEnc!=SQLITE_UTF8 ){
24276 rc = sqlite3VdbeMemMakeWriteable(pMem);
24281 zIn = (u8*)pMem->z;
24282 zTerm = &zIn[pMem->n&~1];
24289 pMem->enc = desiredEnc;
24300 pMem->n &= ~1;
24301 len = pMem->n * 2 + 1;
24308 len = pMem->n * 2 + 2;
24317 zIn = (u8*)pMem->z;
24318 zTerm = &zIn[pMem->n];
24319 zOut = sqlite3DbMallocRaw(pMem->db, len);
24325 if( pMem->enc==SQLITE_UTF8 ){
24340 pMem->n = (int)(z - zOut);
24344 if( pMem->enc==SQLITE_UTF16LE ){
24357 pMem->n = (int)(z - zOut);
24360 assert( (pMem->n+(desiredEnc==SQLITE_UTF8?1:2))<=len );
24362 c = pMem->flags;
24363 sqlite3VdbeMemRelease(pMem);
24364 pMem->flags = MEM_Str|MEM_Term|(c&MEM_AffMask);
24365 pMem->enc = desiredEnc;
24366 pMem->z = (char*)zOut;
24367 pMem->zMalloc = pMem->z;
24368 pMem->szMalloc = sqlite3DbMallocSize(pMem->db, pMem->z);
24374 sqlite3VdbeMemPrettyPrint(pMem, zBuf);
24383 ** UTF-16 string stored in *pMem. If one is present, it is removed and
24390 SQLITE_PRIVATE int sqlite3VdbeMemHandleBom(Mem *pMem){
24394 assert( pMem->n>=0 );
24395 if( pMem->n>1 ){
24396 u8 b1 = *(u8 *)pMem->z;
24397 u8 b2 = *(((u8 *)pMem->z) + 1);
24407 rc = sqlite3VdbeMemMakeWriteable(pMem);
24409 pMem->n -= 2;
24410 memmove(pMem->z, &pMem->z[2], pMem->n);
24411 pMem->z[pMem->n] = '\0';
24412 pMem->z[pMem->n+1] = '\0';
24413 pMem->flags |= MEM_Term;
24414 pMem->enc = bom;
31124 void *pMem;
31126 pMem = osMmap(0, nMap,
31130 if( pMem==MAP_FAILED ){
31135 pMem = sqlite3_malloc64(szRegion);
31136 if( pMem==0 ){
31140 memset(pMem, 0, szRegion);
31144 pShmNode->apRegion[pShmNode->nRegion+i] = &((char*)pMem)[szRegion*i];
35621 MUTEX_LOGIC( sqlite3_mutex *pMem; ) /* The memsys static mutex */
35623 MUTEX_LOGIC( pMem = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM); )
35625 sqlite3_mutex_enter(pMem);
35652 sqlite3_mutex_leave(pMem);
64986 ** this: assert( sqlite3VdbeCheckMemInvariants(pMem) );
65029 ** If pMem is an object with a valid string representation, this routine
65033 ** If pMem is not a string object, or the encoding of the string
65041 SQLITE_PRIVATE int sqlite3VdbeChangeEncoding(Mem *pMem, int desiredEnc){
65045 assert( (pMem->flags&MEM_RowSet)==0 );
65048 if( !(pMem->flags&MEM_Str) || pMem->enc==desiredEnc ){
65051 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
65059 rc = sqlite3VdbeMemTranslate(pMem, (u8)desiredEnc);
65061 assert(rc==SQLITE_OK || pMem->enc!=desiredEnc);
65062 assert(rc==SQLITE_NOMEM || pMem->enc==desiredEnc);
65068 ** Make sure pMem->z points to a writable allocation of at least
65072 ** pMem->z into the new allocation. pMem must be either a string or
65074 ** in pMem->z is discarded.
65076 SQLITE_PRIVATE SQLITE_NOINLINE int sqlite3VdbeMemGrow(Mem *pMem, int n, int bPreserve){
65077 assert( sqlite3VdbeCheckMemInvariants(pMem) );
65078 assert( (pMem->flags&MEM_RowSet)==0 );
65082 assert( bPreserve==0 || pMem->flags&(MEM_Blob|MEM_Str) );
65083 testcase( bPreserve && pMem->z==0 );
65085 assert( pMem->szMalloc==0
65086 || pMem->szMalloc==sqlite3DbMallocSize(pMem->db, pMem->zMalloc) );
65087 if( pMem->szMalloc<n ){
65089 if( bPreserve && pMem->szMalloc>0 && pMem->z==pMem->zMalloc ){
65090 pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n);
65093 if( pMem->szMalloc>0 ) sqlite3DbFree(pMem->db, pMem->zMalloc);
65094 pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, n);
65096 if( pMem->zMalloc==0 ){
65097 sqlite3VdbeMemSetNull(pMem);
65098 pMem->z = 0;
65099 pMem->szMalloc = 0;
65102 pMem->szMalloc = sqlite3DbMallocSize(pMem->db, pMem->zMalloc);
65106 if( bPreserve && pMem->z && pMem->z!=pMem->zMalloc ){
65107 memcpy(pMem->zMalloc, pMem->z, pMem->n);
65109 if( (pMem->flags&MEM_Dyn)!=0 ){
65110 assert( pMem->xDel!=0 && pMem->xDel!=SQLITE_DYNAMIC );
65111 pMem->xDel((void *)(pMem->z));
65114 pMem->z = pMem->zMalloc;
65115 pMem->flags &= ~(MEM_Dyn|MEM_Ephem|MEM_Static);
65120 ** Change the pMem->zMalloc allocation to be at least szNew bytes.
65121 ** If pMem->zMalloc already meets or exceeds the requested size, this
65124 ** Any prior string or blob content in the pMem object may be discarded.
65125 ** The pMem->xDel destructor is called, if it exists. Though MEM_Str
65132 SQLITE_PRIVATE int sqlite3VdbeMemClearAndResize(Mem *pMem, int szNew){
65134 assert( (pMem->flags & MEM_Dyn)==0 || pMem->szMalloc==0 );
65135 if( pMem->szMalloc<szNew ){
65136 return sqlite3VdbeMemGrow(pMem, szNew, 0);
65138 assert( (pMem->flags & MEM_Dyn)==0 );
65139 pMem->z = pMem->zMalloc;
65140 pMem->flags &= (MEM_Null|MEM_Int|MEM_Real);
65145 ** Change pMem so that its MEM_Str or MEM_Blob value is stored in
65150 SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem *pMem){
65152 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
65153 assert( (pMem->flags&MEM_RowSet)==0 );
65154 ExpandBlob(pMem);
65155 f = pMem->flags;
65156 if( (f&(MEM_Str|MEM_Blob)) && (pMem->szMalloc==0 || pMem->z!=pMem->zMalloc) ){
65157 if( sqlite3VdbeMemGrow(pMem, pMem->n + 2, 1) ){
65160 pMem->z[pMem->n] = 0;
65161 pMem->z[pMem->n+1] = 0;
65162 pMem->flags |= MEM_Term;
65164 pMem->flags &= ~MEM_Ephem;
65166 pMem->pScopyFrom = 0;
65177 SQLITE_PRIVATE int sqlite3VdbeMemExpandBlob(Mem *pMem){
65178 if( pMem->flags & MEM_Zero ){
65180 assert( pMem->flags&MEM_Blob );
65181 assert( (pMem->flags&MEM_RowSet)==0 );
65182 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
65185 nByte = pMem->n + pMem->u.nZero;
65189 if( sqlite3VdbeMemGrow(pMem, nByte, 1) ){
65193 memset(&pMem->z[pMem->n], 0, pMem->u.nZero);
65194 pMem->n += pMem->u.nZero;
65195 pMem->flags &= ~(MEM_Zero|MEM_Term);
65202 ** It is already known that pMem contains an unterminated string.
65205 static SQLITE_NOINLINE int vdbeMemAddTerminator(Mem *pMem){
65206 if( sqlite3VdbeMemGrow(pMem, pMem->n+2, 1) ){
65209 pMem->z[pMem->n] = 0;
65210 pMem->z[pMem->n+1] = 0;
65211 pMem->flags |= MEM_Term;
65218 SQLITE_PRIVATE int sqlite3VdbeMemNulTerminate(Mem *pMem){
65219 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
65220 testcase( (pMem->flags & (MEM_Term|MEM_Str))==(MEM_Term|MEM_Str) );
65221 testcase( (pMem->flags & (MEM_Term|MEM_Str))==0 );
65222 if( (pMem->flags & (MEM_Term|MEM_Str))!=MEM_Str ){
65225 return vdbeMemAddTerminator(pMem);
65243 SQLITE_PRIVATE int sqlite3VdbeMemStringify(Mem *pMem, u8 enc, u8 bForce){
65244 int fg = pMem->flags;
65247 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
65251 assert( (pMem->flags&MEM_RowSet)==0 );
65252 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
65255 if( sqlite3VdbeMemClearAndResize(pMem, nByte) ){
65266 sqlite3_snprintf(nByte, pMem->z, "%lld", pMem->u.i);
65269 sqlite3_snprintf(nByte, pMem->z, "%!.15g", pMem->u.r);
65271 pMem->n = sqlite3Strlen30(pMem->z);
65272 pMem->enc = SQLITE_UTF8;
65273 pMem->flags |= MEM_Str|MEM_Term;
65274 if( bForce ) pMem->flags &= ~(MEM_Int|MEM_Real);
65275 sqlite3VdbeChangeEncoding(pMem, enc);
65280 ** Memory cell pMem contains the context of an aggregate function.
65282 ** result of the aggregate is stored back into pMem.
65287 SQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem *pMem, FuncDef *pFunc){
65292 assert( (pMem->flags & MEM_Null)!=0 || pFunc==pMem->u.pDef );
65293 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
65297 t.db = pMem->db;
65299 ctx.pMem = pMem;
65302 assert( (pMem->flags & MEM_Dyn)==0 );
65303 if( pMem->szMalloc>0 ) sqlite3DbFree(pMem->db, pMem->zMalloc);
65304 memcpy(pMem, &t, sizeof(t));
65409 ** at representing the value that *pMem describes as an integer.
65410 ** If pMem is an integer, then the value is exact. If pMem is
65412 ** If pMem is a string or blob, then we make an attempt to convert
65413 ** it into an integer and return that. If pMem represents an
65416 ** If pMem represents a string value, its encoding might be changed.
65418 SQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem *pMem){
65420 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
65421 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
65422 flags = pMem->flags;
65424 return pMem->u.i;
65426 return doubleToInt64(pMem->u.r);
65429 assert( pMem->z || pMem->n==0 );
65430 sqlite3Atoi64(pMem->z, &value, pMem->n, pMem->enc);
65438 ** Return the best representation of pMem that we can get into a
65439 ** double. If pMem is already a double or an integer, return its
65443 SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem *pMem){
65444 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
65445 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
65446 if( pMem->flags & MEM_Real ){
65447 return pMem->u.r;
65448 }else if( pMem->flags & MEM_Int ){
65449 return (double)pMem->u.i;
65450 }else if( pMem->flags & (MEM_Str|MEM_Blob) ){
65453 sqlite3AtoF(pMem->z, &val, pMem->n, pMem->enc);
65465 SQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem *pMem){
65467 assert( pMem->flags & MEM_Real );
65468 assert( (pMem->flags & MEM_RowSet)==0 );
65469 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
65470 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
65472 ix = doubleToInt64(pMem->u.r);
65484 if( pMem->u.r==ix && ix>SMALLEST_INT64 && ix<LARGEST_INT64 ){
65485 pMem->u.i = ix;
65486 MemSetTypeFlag(pMem, MEM_Int);
65491 ** Convert pMem to type integer. Invalidate any prior representations.
65493 SQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem *pMem){
65494 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
65495 assert( (pMem->flags & MEM_RowSet)==0 );
65496 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
65498 pMem->u.i = sqlite3VdbeIntValue(pMem);
65499 MemSetTypeFlag(pMem, MEM_Int);
65504 ** Convert pMem so that it is of type MEM_Real.
65507 SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem *pMem){
65508 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
65509 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
65511 pMem->u.r = sqlite3VdbeRealValue(pMem);
65512 MemSetTypeFlag(pMem, MEM_Real);
65517 ** Convert pMem so that it has types MEM_Real or MEM_Int or both.
65524 SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem *pMem){
65525 if( (pMem->flags & (MEM_Int|MEM_Real|MEM_Null))==0 ){
65526 assert( (pMem->flags & (MEM_Blob|MEM_Str))!=0 );
65527 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
65528 if( 0==sqlite3Atoi64(pMem->z, &pMem->u.i, pMem->n, pMem->enc) ){
65529 MemSetTypeFlag(pMem, MEM_Int);
65531 pMem->u.r = sqlite3VdbeRealValue(pMem);
65532 MemSetTypeFlag(pMem, MEM_Real);
65533 sqlite3VdbeIntegerAffinity(pMem);
65536 assert( (pMem->flags & (MEM_Int|MEM_Real|MEM_Null))!=0 );
65537 pMem->flags &= ~(MEM_Str|MEM_Blob);
65542 ** Cast the datatype of the value in pMem according to the affinity
65548 SQLITE_PRIVATE void sqlite3VdbeMemCast(Mem *pMem, u8 aff, u8 encoding){
65549 if( pMem->flags & MEM_Null ) return;
65552 if( (pMem->flags & MEM_Blob)==0 ){
65553 sqlite3ValueApplyAffinity(pMem, SQLITE_AFF_TEXT, encoding);
65554 assert( pMem->flags & MEM_Str || pMem->db->mallocFailed );
65555 MemSetTypeFlag(pMem, MEM_Blob);
65557 pMem->flags &= ~(MEM_TypeMask&~MEM_Blob);
65562 sqlite3VdbeMemNumerify(pMem);
65566 sqlite3VdbeMemIntegerify(pMem);
65570 sqlite3VdbeMemRealify(pMem);
65576 pMem->flags |= (pMem->flags&MEM_Blob)>>3;
65577 sqlite3ValueApplyAffinity(pMem, SQLITE_AFF_TEXT, encoding);
65578 assert( pMem->flags & MEM_Str || pMem->db->mallocFailed );
65579 pMem->flags &= ~(MEM_Int|MEM_Real|MEM_Blob|MEM_Zero);
65590 SQLITE_PRIVATE void sqlite3VdbeMemInit(Mem *pMem, sqlite3 *db, u16 flags){
65592 pMem->flags = flags;
65593 pMem->db = db;
65594 pMem->szMalloc = 0;
65599 ** Delete any previous value and set the value stored in *pMem to NULL.
65610 SQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem *pMem){
65611 if( VdbeMemDynamic(pMem) ){
65612 vdbeMemClearExternAndSetNull(pMem);
65614 pMem->flags = MEM_Null;
65625 SQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem *pMem, int n){
65626 sqlite3VdbeMemRelease(pMem);
65627 pMem->flags = MEM_Blob|MEM_Zero;
65628 pMem->n = 0;
65630 pMem->u.nZero = n;
65631 pMem->enc = SQLITE_UTF8;
65632 pMem->z = 0;
65636 ** The pMem is known to contain content that needs to be destroyed prior
65640 static SQLITE_NOINLINE void vdbeReleaseAndSetInt64(Mem *pMem, i64 val){
65641 sqlite3VdbeMemSetNull(pMem);
65642 pMem->u.i = val;
65643 pMem->flags = MEM_Int;
65647 ** Delete any previous value and set the value stored in *pMem to val,
65650 SQLITE_PRIVATE void sqlite3VdbeMemSetInt64(Mem *pMem, i64 val){
65651 if( VdbeMemDynamic(pMem) ){
65652 vdbeReleaseAndSetInt64(pMem, val);
65654 pMem->u.i = val;
65655 pMem->flags = MEM_Int;
65661 ** Delete any previous value and set the value stored in *pMem to val,
65664 SQLITE_PRIVATE void sqlite3VdbeMemSetDouble(Mem *pMem, double val){
65665 sqlite3VdbeMemSetNull(pMem);
65667 pMem->u.r = val;
65668 pMem->flags = MEM_Real;
65674 ** Delete any previous value and set the value of pMem to be an
65677 SQLITE_PRIVATE void sqlite3VdbeMemSetRowSet(Mem *pMem){
65678 sqlite3 *db = pMem->db;
65680 assert( (pMem->flags & MEM_RowSet)==0 );
65681 sqlite3VdbeMemRelease(pMem);
65682 pMem->zMalloc = sqlite3DbMallocRaw(db, 64);
65684 pMem->flags = MEM_Null;
65685 pMem->szMalloc = 0;
65687 assert( pMem->zMalloc );
65688 pMem->szMalloc = sqlite3DbMallocSize(db, pMem->zMalloc);
65689 pMem->u.pRowSet = sqlite3RowSetInit(db, pMem->zMalloc, pMem->szMalloc);
65690 assert( pMem->u.pRowSet!=0 );
65691 pMem->flags = MEM_RowSet;
65720 SQLITE_PRIVATE void sqlite3VdbeMemAboutToChange(Vdbe *pVdbe, Mem *pMem){
65724 if( pX->pScopyFrom==pMem ){
65729 pMem->pScopyFrom = 0;
65811 ** is required to store the string, then value of pMem is unchanged. In
65815 Mem *pMem, /* Memory cell to set to string value */
65821 int nByte = n; /* New value for pMem->n */
65823 u16 flags = 0; /* New value for pMem->flags */
65825 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
65826 assert( (pMem->flags & MEM_RowSet)==0 );
65828 /* If z is a NULL pointer, set pMem to contain an SQL NULL. */
65830 sqlite3VdbeMemSetNull(pMem);
65834 if( pMem->db ){
65835 iLimit = pMem->db->aLimit[SQLITE_LIMIT_LENGTH];
65866 if( sqlite3VdbeMemClearAndResize(pMem, MAX(nAlloc,32)) ){
65869 memcpy(pMem->z, z, nAlloc);
65871 sqlite3VdbeMemRelease(pMem);
65872 pMem->zMalloc = pMem->z = (char *)z;
65873 pMem->szMalloc = sqlite3DbMallocSize(pMem->db, pMem->zMalloc);
65875 sqlite3VdbeMemRelease(pMem);
65876 pMem->z = (char *)z;
65877 pMem->xDel = xDel;
65881 pMem->n = nByte;
65882 pMem->flags = flags;
65883 pMem->enc = (enc==0 ? SQLITE_UTF8 : enc);
65886 if( pMem->enc!=SQLITE_UTF8 && sqlite3VdbeMemHandleBom(pMem) ){
65903 ** into the pMem element.
65905 ** The pMem object must have been initialized. This routine will use
65906 ** pMem->zMalloc to hold the content from the btree, if possible. New
65907 ** pMem->zMalloc space will be allocated if necessary. The calling routine
65908 ** is responsible for making sure that the pMem object is eventually
65912 ** to read from the disk) then the pMem is left in an inconsistent state.
65919 Mem *pMem /* OUT: Return data in this Mem structure. */
65922 pMem->flags = MEM_Null;
65923 if( SQLITE_OK==(rc = sqlite3VdbeMemClearAndResize(pMem, amt+2)) ){
65925 rc = sqlite3BtreeKey(pCur, offset, amt, pMem->z);
65927 rc = sqlite3BtreeData(pCur, offset, amt, pMem->z);
65930 pMem->z[amt] = 0;
65931 pMem->z[amt+1] = 0;
65932 pMem->flags = MEM_Blob|MEM_Term;
65933 pMem->n = (int)amt;
65935 sqlite3VdbeMemRelease(pMem);
65945 Mem *pMem /* OUT: Return data in this Mem structure. */
65952 assert( !VdbeMemDynamic(pMem) );
65956 assert( (pMem->flags & MEM_RowSet)==0 );
65965 pMem->z = &zData[offset];
65966 pMem->flags = MEM_Blob|MEM_Ephem;
65967 pMem->n = (int)amt;
65969 rc = vdbeMemFromBtreeResize(pCur, offset, amt, key, pMem);
66588 Mem *pMem = *ppVal; /* Write result into this Mem object */
66605 if( pMem==0 ){
66606 pMem = *ppVal = sqlite3ValueNew(db);
66607 if( pMem==0 ) return SQLITE_NOMEM;
66609 sqlite3VdbeSerialGet(&a[iField-szField], t, pMem);
66610 pMem->enc = ENC(db);
67842 Mem *pMem = pOp->p4.pMem;
67843 if( pMem->flags & MEM_Str ){
67844 zP4 = pMem->z;
67845 }else if( pMem->flags & MEM_Int ){
67846 sqlite3_snprintf(nTemp, zTemp, "%lld", pMem->u.i);
67847 }else if( pMem->flags & MEM_Real ){
67848 sqlite3_snprintf(nTemp, zTemp, "%.16g", pMem->u.r);
67849 }else if( pMem->flags & MEM_Null ){
67852 assert( pMem->flags & MEM_Blob );
68084 Mem *pMem = &p->aMem[1]; /* First Mem of result set */
68094 releaseMemArray(pMem, 8);
68158 pMem->flags = MEM_Int;
68159 pMem->u.i = i; /* Program counter */
68160 pMem++;
68162 pMem->flags = MEM_Static|MEM_Str|MEM_Term;
68163 pMem->z = (char*)sqlite3OpcodeName(pOp->opcode); /* Opcode */
68164 assert( pMem->z!=0 );
68165 pMem->n = sqlite3Strlen30(pMem->z);
68166 pMem->enc = SQLITE_UTF8;
68167 pMem++;
68189 pMem->flags = MEM_Int;
68190 pMem->u.i = pOp->p1; /* P1 */
68191 pMem++;
68193 pMem->flags = MEM_Int;
68194 pMem->u.i = pOp->p2; /* P2 */
68195 pMem++;
68197 pMem->flags = MEM_Int;
68198 pMem->u.i = pOp->p3; /* P3 */
68199 pMem++;
68201 if( sqlite3VdbeMemClearAndResize(pMem, 32) ){ /* P4 */
68205 pMem->flags = MEM_Str|MEM_Term;
68206 zP4 = displayP4(pOp, pMem->z, 32);
68207 if( zP4!=pMem->z ){
68208 sqlite3VdbeMemSetStr(pMem, zP4, -1, SQLITE_UTF8, 0);
68210 assert( pMem->z!=0 );
68211 pMem->n = sqlite3Strlen30(pMem->z);
68212 pMem->enc = SQLITE_UTF8;
68214 pMem++;
68217 if( sqlite3VdbeMemClearAndResize(pMem, 4) ){
68221 pMem->flags = MEM_Str|MEM_Term;
68222 pMem->n = 2;
68223 sqlite3_snprintf(3, pMem->z, "%.2x", pOp->p5); /* P5 */
68224 pMem->enc = SQLITE_UTF8;
68225 pMem++;
68228 if( sqlite3VdbeMemClearAndResize(pMem, 500) ){
68232 pMem->flags = MEM_Str|MEM_Term;
68233 pMem->n = displayComment(pOp, zP4, pMem->z, 500);
68234 pMem->enc = SQLITE_UTF8;
68236 pMem->flags = MEM_Null; /* Comment */
69623 ** Return the serial-type for the value stored in pMem.
69625 SQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem *pMem, int file_format){
69626 int flags = pMem->flags;
69635 i64 i = pMem->u.i;
69654 assert( pMem->db->mallocFailed || flags&(MEM_Str|MEM_Blob) );
69655 assert( pMem->n>=0 );
69656 n = (u32)pMem->n;
69658 n += pMem->u.nZero;
69735 ** Write the serialized data blob for the value stored in pMem into
69741 ** of the pMem->u.nZero bytes for a MEM_Zero value.
69747 SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(u8 *buf, Mem *pMem, u32 serial_type){
69755 assert( sizeof(v)==sizeof(pMem->u.r) );
69756 memcpy(&v, &pMem->u.r, sizeof(v));
69759 v = pMem->u.i;
69772 assert( pMem->n + ((pMem->flags & MEM_Zero)?pMem->u.nZero:0)
69774 len = pMem->n;
69775 memcpy(buf, pMem->z, len);
69794 ** and store the result in pMem. Return the number of bytes read.
69804 Mem *pMem /* Memory cell to write value into */
69812 pMem->u.i = *(i64*)&x;
69813 pMem->flags = MEM_Int;
69814 testcase( pMem->u.i<0 );
69830 assert( sizeof(x)==8 && sizeof(pMem->u.r)==8 );
69832 memcpy(&pMem->u.r, &x, sizeof(x));
69833 pMem->flags = sqlite3IsNaN(pMem->u.r) ? MEM_Null : MEM_Real;
69840 Mem *pMem /* Memory cell to write value into */
69847 pMem->flags = MEM_Null;
69853 pMem->u.i = ONE_BYTE_INT(buf);
69854 pMem->flags = MEM_Int;
69855 testcase( pMem->u.i<0 );
69861 pMem->u.i = TWO_BYTE_INT(buf);
69862 pMem->flags = MEM_Int;
69863 testcase( pMem->u.i<0 );
69869 pMem->u.i = THREE_BYTE_INT(buf);
69870 pMem->flags = MEM_Int;
69871 testcase( pMem->u.i<0 );
69877 pMem->u.i = FOUR_BYTE_INT(buf);
69878 pMem->flags = MEM_Int;
69879 testcase( pMem->u.i<0 );
69885 pMem->u.i = FOUR_BYTE_UINT(buf+2) + (((i64)1)<<32)*TWO_BYTE_INT(buf);
69886 pMem->flags = MEM_Int;
69887 testcase( pMem->u.i<0 );
69894 return serialGet(buf,serial_type,pMem);
69900 pMem->u.i = serial_type-8;
69901 pMem->flags = MEM_Int;
69910 pMem->z = (char *)buf;
69911 pMem->n = (serial_type-12)/2;
69912 pMem->flags = aFlag[serial_type&1];
69913 return pMem->n;
69980 Mem *pMem = p->aMem;
69983 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
69991 pMem->enc = pKeyInfo->enc;
69992 pMem->db = pKeyInfo->db;
69993 /* pMem->flags = 0; // sqlite3VdbeSerialGet() will set this for us */
69994 pMem->szMalloc = 0;
69995 d += sqlite3VdbeSerialGet(&aKey[d], serial_type, pMem);
69996 pMem++;
70905 Mem *pMem = &v->aVar[iVar-1];
70906 if( 0==(pMem->flags & MEM_Null) ){
70909 sqlite3VdbeMemCopy((Mem *)pRet, pMem);
71705 ** its pMem->z element.
71708 Mem *pMem = p->pMem;
71709 assert( (pMem->flags & MEM_Agg)==0 );
71711 sqlite3VdbeMemSetNull(pMem);
71712 pMem->z = 0;
71714 sqlite3VdbeMemClearAndResize(pMem, nByte);
71715 pMem->flags = MEM_Agg;
71716 pMem->u.pDef = p->pFunc;
71717 if( pMem->z ){
71718 memset(pMem->z, 0, nByte);
71721 return (void*)pMem->z;
71733 if( (p->pMem->flags & MEM_Agg)==0 ){
71736 return (void*)p->pMem->z;
71821 assert( p && p->pMem && p->pFunc && p->pFunc->xStep );
71822 return p->pMem->n;
73009 Mem *pMem = &p->aMem[p->nMem-iCur];
73022 if( SQLITE_OK==sqlite3VdbeMemClearAndResize(pMem, nByte) ){
73023 p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->z;
73030 &pMem->z[ROUND8(sizeof(VdbeCursor))+2*sizeof(u32)*nField];
73122 Mem *pMem = (Mem*)pVal;
73123 applyNumericAffinity(pMem, 0);
73142 ** pMem currently only holds a string type (or maybe a BLOB that we can
73144 ** numeric type, if has one. Set the pMem->u.r and pMem->u.i fields
73147 static u16 SQLITE_NOINLINE computeNumericType(Mem *pMem){
73148 assert( (pMem->flags & (MEM_Int|MEM_Real))==0 );
73149 assert( (pMem->flags & (MEM_Str|MEM_Blob))!=0 );
73150 if( sqlite3AtoF(pMem->z, &pMem->u.r, pMem->n, pMem->enc)==0 ){
73153 if( sqlite3Atoi64(pMem->z, &pMem->u.i, pMem->n, pMem->enc)==SQLITE_OK ){
73160 ** Return the numeric type for pMem, either MEM_Int or MEM_Real or both or
73163 ** Unlike applyNumericAffinity(), this routine does not modify pMem->flags.
73164 ** But it does set pMem->u.r and pMem->u.i appropriately.
73166 static u16 numericType(Mem *pMem){
73167 if( pMem->flags & (MEM_Int|MEM_Real) ){
73168 return pMem->flags & (MEM_Int|MEM_Real);
73170 if( pMem->flags & (MEM_Str|MEM_Blob) ){
73171 return computeNumericType(pMem);
73178 ** Write a nice string representation of the contents of cell pMem
73181 SQLITE_PRIVATE void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf){
73183 int f = pMem->flags;
73205 sqlite3_snprintf(100, zCsr, "%d[", pMem->n);
73207 for(i=0; i<16 && i<pMem->n; i++){
73208 sqlite3_snprintf(100, zCsr, "%02X", ((int)pMem->z[i] & 0xFF));
73211 for(i=0; i<16 && i<pMem->n; i++){
73212 char z = pMem->z[i];
73217 sqlite3_snprintf(100, zCsr, "]%s", encnames[pMem->enc]);
73220 sqlite3_snprintf(100, zCsr,"+%dz",pMem->u.nZero);
73240 sqlite3_snprintf(100, &zBuf[k], "%d", pMem->n);
73243 for(j=0; j<15 && j<pMem->n; j++){
73244 u8 c = pMem->z[j];
73252 sqlite3_snprintf(100,&zBuf[k], encnames[pMem->enc]);
74177 Mem *pMem;
74232 pMem = p->pResultSet = &aMem[pOp->p1];
74234 assert( memIsValid(&pMem[i]) );
74235 Deephemeralize(&pMem[i]);
74236 assert( (pMem[i].flags & MEM_Ephem)==0
74237 || (pMem[i].flags & (MEM_Str|MEM_Blob))==0 );
74238 sqlite3VdbeMemNulTerminate(&pMem[i]);
74239 REGISTER_TRACE(pOp->p1+i, &pMem[i]);
75422 sqlite3VdbeMemShallowCopy(pDest, pOp->p4.pMem, MEM_Static);
76960 Mem *pMem; /* Register holding largest rowid for AUTOINCREMENT */
77023 pMem = &pFrame->aMem[pOp->p3];
77027 pMem = &aMem[pOp->p3];
77028 memAboutToChange(p, pMem);
77030 assert( memIsValid(pMem) );
77032 REGISTER_TRACE(pOp->p3, pMem);
77033 sqlite3VdbeMemIntegerify(pMem);
77034 assert( (pMem->flags & MEM_Int)!=0 ); /* mem(P3) holds an integer */
77035 if( pMem->u.i==MAX_ROWID || pC->useRandomRowid ){
77039 if( v<pMem->u.i+1 ){
77040 v = pMem->u.i + 1;
77042 pMem->u.i = v;
78365 Mem *pMem; /* Used to iterate through memory cells */
78439 for(pMem=VdbeFrameMem(pFrame); pMem!=pEnd; pMem++){
78440 pMem->flags = MEM_Undefined;
78441 pMem->db = db;
78700 pCtx->pMem = 0;
78713 Mem *pMem;
78718 pMem = &aMem[pOp->p3];
78724 if( pCtx->pMem != pMem ){
78725 pCtx->pMem = pMem;
78736 pMem->n++;
78773 Mem *pMem;
78775 pMem = &aMem[pOp->p1];
78776 assert( (pMem->flags & ~(MEM_Null|MEM_Agg))==0 );
78777 rc = sqlite3VdbeMemFinalize(pMem, pOp->p4.pFunc);
78779 sqlite3VdbeError(p, "%s", sqlite3_value_text(pMem));
78781 sqlite3VdbeChangeEncoding(pMem, encoding);
78782 UPDATE_MAX_BLOBSIZE(pMem);
78783 if( sqlite3VdbeMemTooBig(pMem) ){
78804 Mem *pMem; /* Write results here */
78819 for(i=0, pMem = &aMem[pOp->p3]; i<3; i++, pMem++){
78820 sqlite3VdbeMemSetInt64(pMem, (i64)aRes[i]);