/ Check-in [95edcf50]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix minor issues with the sqlite3_value_dup() interface.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | value-dup
Files: files | file ages | folders
SHA1:95edcf5010ecb8edd8eb74279c4766f9b655d4a2
User & Date: drh 2015-05-22 19:55:10
Context
2015-05-22
21:04
Make sure sqlite3_value_dup() works correctly even for sqlite3_value objects that are marked SQLITE_STATIC. Closed-Leaf check-in: f332ffc3 user: drh tags: value-dup
19:55
Fix minor issues with the sqlite3_value_dup() interface. check-in: 95edcf50 user: drh tags: value-dup
18:40
Update with fixes and enhancements from trunk. check-in: 9605d008 user: drh tags: value-dup
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/vdbeapi.c.

222
223
224
225
226
227
228
229



230
231
232
233
234
235
236
  memset(pNew, 0, sizeof(*pNew));
  memcpy(pNew, pOrig, MEMCELLSIZE);
  pNew->flags &= ~MEM_Dyn;
  pNew->db = 0;
  if( pNew->flags&(MEM_Str|MEM_Blob) ){
    if( 0==(pOrig->flags&MEM_Static) ){
      pNew->flags |= MEM_Ephem;
      sqlite3VdbeMemMakeWriteable(pNew);



    }
  }
  return pNew;
}

/* Destroy an sqlite3_value object previously obtained from
** sqlite3_value_dup().







|
>
>
>







222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
  memset(pNew, 0, sizeof(*pNew));
  memcpy(pNew, pOrig, MEMCELLSIZE);
  pNew->flags &= ~MEM_Dyn;
  pNew->db = 0;
  if( pNew->flags&(MEM_Str|MEM_Blob) ){
    if( 0==(pOrig->flags&MEM_Static) ){
      pNew->flags |= MEM_Ephem;
      if( sqlite3VdbeMemMakeWriteable(pNew)!=SQLITE_OK ){
        sqlite3ValueFree(pNew);
        pNew = 0;
      }
    }
  }
  return pNew;
}

/* Destroy an sqlite3_value object previously obtained from
** sqlite3_value_dup().

Changes to src/vdbemem.c.

792
793
794
795
796
797
798



799
800
801
802
803
804
805
806
/*
** Make a full copy of pFrom into pTo.  Prior contents of pTo are
** freed before the copy is made.
*/
int sqlite3VdbeMemCopy(Mem *pTo, const Mem *pFrom){
  int rc = SQLITE_OK;




  assert( pTo->db==pFrom->db );
  assert( (pFrom->flags & MEM_RowSet)==0 );
  if( VdbeMemDynamic(pTo) ) vdbeMemClearExternAndSetNull(pTo);
  memcpy(pTo, pFrom, MEMCELLSIZE);
  pTo->flags &= ~MEM_Dyn;
  if( pTo->flags&(MEM_Str|MEM_Blob) ){
    if( 0==(pFrom->flags&MEM_Static) ){
      pTo->flags |= MEM_Ephem;







>
>
>
|







792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
/*
** Make a full copy of pFrom into pTo.  Prior contents of pTo are
** freed before the copy is made.
*/
int sqlite3VdbeMemCopy(Mem *pTo, const Mem *pFrom){
  int rc = SQLITE_OK;

  /* The pFrom==0 case in the following assert() is when an sqlite3_value
  ** from sqlite3_value_dup() is used as the argument
  ** to sqlite3_result_value(). */
  assert( pTo->db==pFrom->db || pFrom->db==0 );
  assert( (pFrom->flags & MEM_RowSet)==0 );
  if( VdbeMemDynamic(pTo) ) vdbeMemClearExternAndSetNull(pTo);
  memcpy(pTo, pFrom, MEMCELLSIZE);
  pTo->flags &= ~MEM_Dyn;
  if( pTo->flags&(MEM_Str|MEM_Blob) ){
    if( 0==(pFrom->flags&MEM_Static) ){
      pTo->flags |= MEM_Ephem;