1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-30 19:03:16 +03:00

Modify the sqlite3session_diff() API so that tables with no PRIMARY KEYs are ignored. This matches the other sessions APIs. Also change sqlite3session_diff() so that it returns SQLITE_SCHEMA, instead of SQLITE_ERROR, if the tables being compared do not have compatible schemas.

FossilOrigin-Name: aada0ad08e3baa10d14d1f3393183110289e068e
This commit is contained in:
dan
2015-04-23 17:22:49 +00:00
parent 4cc923e3e3
commit b9db909952
6 changed files with 51 additions and 41 deletions

View File

@ -1474,12 +1474,12 @@ int sqlite3session_diff(
/* Check the table schemas match */
if( rc==SQLITE_OK ){
int bHasPk = 0;
int bMismatch = 0;
int nCol; /* Columns in zFrom.zTbl */
u8 *abPK;
const char **azCol = 0;
rc = sessionTableInfo(db, zFrom, zTbl, &nCol, 0, &azCol, &abPK);
if( rc==SQLITE_OK ){
int bMismatch = 0;
if( pTo->nCol!=nCol ){
bMismatch = 1;
}else{
@ -1491,16 +1491,16 @@ int sqlite3session_diff(
}
}
if( bMismatch ){
*pzErrMsg = sqlite3_mprintf("table schemas do not match");
rc = SQLITE_ERROR;
}
if( bHasPk==0 ){
*pzErrMsg = sqlite3_mprintf("table has no primary key");
rc = SQLITE_ERROR;
}
}
sqlite3_free(azCol);
if( bMismatch ){
*pzErrMsg = sqlite3_mprintf("table schemas do not match");
rc = SQLITE_SCHEMA;
}
if( bHasPk==0 ){
/* Ignore tables with no primary keys */
goto diff_out;
}
}
if( rc==SQLITE_OK ){