SQLite

Check-in [572378d3a2]
Login

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

Overview
Comment:The sqlite3_backup_init() interface must lock the destination in case it needs to change the error message. (CVS 6255)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 572378d3a29c7d55fa4a15df14800c26d6c563a1
User & Date: drh 2009-02-04 16:56:19.000
Context
2009-02-04
17:40
Simplify wording of backup API error message. Decapitalize some other error messages. (CVS 6256) (check-in: f92405afb6 user: drh tags: trunk)
16:56
The sqlite3_backup_init() interface must lock the destination in case it needs to change the error message. (CVS 6255) (check-in: 572378d3a2 user: drh tags: trunk)
15:27
Fix a bug in test_malloc.c whereby running multi-threaded test cases could cause subsequent OOM tests to fail. (CVS 6254) (check-in: 03ea9e5913 user: danielk1977 tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/backup.c.
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains the implementation of the sqlite3_backup_XXX() 
** API functions and the related features.
**
** $Id: backup.c,v 1.5 2009/02/04 01:49:30 shane Exp $
*/
#include "sqliteInt.h"
#include "btreeInt.h"

/* Macro to find the minimum of two numeric values.
*/
#ifndef MIN







|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains the implementation of the sqlite3_backup_XXX() 
** API functions and the related features.
**
** $Id: backup.c,v 1.6 2009/02/04 16:56:19 drh Exp $
*/
#include "sqliteInt.h"
#include "btreeInt.h"

/* Macro to find the minimum of two numeric values.
*/
#ifndef MIN
130
131
132
133
134
135
136

137
138
139
140
141
142
143
  ** sqlite3_backup_step(). The user is required to ensure that no
  ** other thread accesses the destination handle for the duration
  ** of the backup operation.  Any attempt to use the destination
  ** database connection while a backup is in progress may cause
  ** a malfunction or a deadlock.
  */
  sqlite3_mutex_enter(pSrcDb->mutex);


  if( pSrcDb==pDestDb ){
    sqlite3Error(
        pDestDb, SQLITE_ERROR, "Source and destination handles must be distinct"
    );
    p = 0;
  }else {







>







130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
  ** sqlite3_backup_step(). The user is required to ensure that no
  ** other thread accesses the destination handle for the duration
  ** of the backup operation.  Any attempt to use the destination
  ** database connection while a backup is in progress may cause
  ** a malfunction or a deadlock.
  */
  sqlite3_mutex_enter(pSrcDb->mutex);
  sqlite3_mutex_enter(pDestDb->mutex);

  if( pSrcDb==pDestDb ){
    sqlite3Error(
        pDestDb, SQLITE_ERROR, "Source and destination handles must be distinct"
    );
    p = 0;
  }else {
177
178
179
180
181
182
183

184
185
186
187
188
189
190
    pp = sqlite3PagerBackupPtr(sqlite3BtreePager(p->pSrc));
    p->pNext = *pp;
    *pp = p;
    sqlite3BtreeLeave(p->pSrc);
    p->pSrc->nBackup++;
  }


  sqlite3_mutex_leave(pSrcDb->mutex);
  return p;
}

/*
** Parameter zSrcData points to a buffer containing the data for 
** page iSrcPg from the source database. Copy this data into the 







>







178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
    pp = sqlite3PagerBackupPtr(sqlite3BtreePager(p->pSrc));
    p->pNext = *pp;
    *pp = p;
    sqlite3BtreeLeave(p->pSrc);
    p->pSrc->nBackup++;
  }

  sqlite3_mutex_leave(pDestDb->mutex);
  sqlite3_mutex_leave(pSrcDb->mutex);
  return p;
}

/*
** Parameter zSrcData points to a buffer containing the data for 
** page iSrcPg from the source database. Copy this data into the