In sqlite3-rsync,
open the replica database using ATTACH since the sqlite3_dbpage virtual table is technically a part of "main". This avoids locking problems. FossilOrigin-Name: 39c56c836a8ae52c5b42cc0d04b92f7c0e6889a03c4fdffd301209383b7c1f87
This commit is contained in:
parent
f8cafd7b11
commit
d70fbffc1a
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C Improved\serror\smessage\sin\ssqlite3-rsync\sif\sthe\sSQL\sstatement\sfor\sORIGIN_TXN\nfails.
|
||||
D 2024-09-16T09:12:11.717
|
||||
C In\ssqlite3-rsync,\s\nopen\sthe\sreplica\sdatabase\susing\sATTACH\ssince\sthe\ssqlite3_dbpage\svirtual\stable\nis\stechnically\sa\spart\sof\s"main".\s\sThis\savoids\slocking\sproblems.
|
||||
D 2024-09-16T10:58:11.340
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@ -2174,7 +2174,7 @@ F tool/speedtest8inst1.c 7ce07da76b5e745783e703a834417d725b7d45fd
|
||||
F tool/spellsift.tcl 52b4b04dc4333c7ab024f09d9d66ed6b6f7c6eb00b38497a09f338fa55d40618 x
|
||||
F tool/split-sqlite3c.tcl 5aa60643afca558bc732b1444ae81a522326f91e1dc5665b369c54f09e20de60
|
||||
F tool/sqldiff.c 847fc8fcfddf5ce4797b7394cad6372f2f5dc17d8186e2ef8fb44d50fae4f44a
|
||||
F tool/sqlite3-rsync.c 2606fcc8f62d7620c5d32866583be604734ef0a5ffb912672af29ebcef7e0942
|
||||
F tool/sqlite3-rsync.c 5300955015bdaa7dee47596d4f5470f558e525c3a384741efeb51f130183a963
|
||||
F tool/sqlite3_analyzer.c.in 8da2b08f56eeac331a715036cf707cc20f879f231362be0c22efd682e2b89b4f
|
||||
F tool/sqltclsh.c.in 1bcc2e9da58fadf17b0bf6a50e68c1159e602ce057210b655d50bad5aaaef898
|
||||
F tool/sqltclsh.tcl 862f4cf1418df5e1315b5db3b5ebe88969e2a784525af5fbf9596592f14ed848
|
||||
@ -2213,8 +2213,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P 23a63505152ff995e4ce0963dc4ab9f76ed55da7e7f5e1b85a2577473642e3ad
|
||||
R 7ac67254bf574f521c3ff56a758b7b73
|
||||
P 73bde71ed10f52b851e220de35519d5fb7e65a932437ab82a194faff490b7930
|
||||
R f7d231e0373df95dd0aff2e436d32219
|
||||
U drh
|
||||
Z d4fb228b1805959bd390d87ed1c481a4
|
||||
Z 3dc13fb7854d43a127a1dc7a11aff974
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
@ -1 +1 @@
|
||||
73bde71ed10f52b851e220de35519d5fb7e65a932437ab82a194faff490b7930
|
||||
39c56c836a8ae52c5b42cc0d04b92f7c0e6889a03c4fdffd301209383b7c1f87
|
||||
|
@ -1282,7 +1282,6 @@ static void originSide(SQLiteRsync *p){
|
||||
}
|
||||
case REPLICA_READY: {
|
||||
sqlite3_stmt *pStmt;
|
||||
int needPageOne = 0;
|
||||
sqlite3_finalize(pCkHash);
|
||||
pCkHash = 0;
|
||||
if( iPage+1<p->nPage ){
|
||||
@ -1298,32 +1297,12 @@ static void originSide(SQLiteRsync *p){
|
||||
while( sqlite3_step(pStmt)==SQLITE_ROW && p->nErr==0 && p->nWrErr==0 ){
|
||||
unsigned int pgno = (unsigned int)sqlite3_column_int64(pStmt,0);
|
||||
const void *pContent = sqlite3_column_blob(pStmt, 1);
|
||||
if( pgno==1 ){
|
||||
needPageOne = 1;
|
||||
}else{
|
||||
writeByte(p, ORIGIN_PAGE);
|
||||
writeUint32(p, (unsigned int)sqlite3_column_int64(pStmt, 0));
|
||||
writeBytes(p, szPg, pContent);
|
||||
p->nPageSent++;
|
||||
}
|
||||
writeByte(p, ORIGIN_PAGE);
|
||||
writeUint32(p, pgno);
|
||||
writeBytes(p, szPg, pContent);
|
||||
p->nPageSent++;
|
||||
}
|
||||
sqlite3_finalize(pStmt);
|
||||
if( needPageOne ){
|
||||
pStmt = prepareStmt(p,
|
||||
"SELECT data"
|
||||
" FROM sqlite_dbpage('main')"
|
||||
" WHERE pgno=1"
|
||||
);
|
||||
if( pStmt==0 ) break;
|
||||
while( sqlite3_step(pStmt)==SQLITE_ROW && p->nErr==0 &&p->nWrErr==0 ){
|
||||
const void *pContent = sqlite3_column_blob(pStmt, 0);
|
||||
writeByte(p, ORIGIN_PAGE);
|
||||
writeUint32(p, 1);
|
||||
writeBytes(p, szPg, pContent);
|
||||
p->nPageSent++;
|
||||
}
|
||||
sqlite3_finalize(pStmt);
|
||||
}
|
||||
writeByte(p, ORIGIN_TXN);
|
||||
writeUint32(p, nPage);
|
||||
writeByte(p, ORIGIN_END);
|
||||
@ -1417,30 +1396,35 @@ static void replicaSide(SQLiteRsync *p){
|
||||
}
|
||||
p->nPage = nOPage;
|
||||
p->szPage = szOPage;
|
||||
rc = sqlite3_open(p->zReplica, &p->db);
|
||||
rc = sqlite3_open(":memory:", &p->db);
|
||||
if( rc ){
|
||||
reportError(p, "cannot open replica \"%s\": %s",
|
||||
p->zReplica, sqlite3_errmsg(p->db));
|
||||
reportError(p, "cannot open in-memory database: %s",
|
||||
sqlite3_errmsg(p->db));
|
||||
closeDb(p);
|
||||
break;
|
||||
}
|
||||
runSql(p, "ATTACH %Q AS 'replica'", p->zReplica);
|
||||
if( p->nErr ){
|
||||
closeDb(p);
|
||||
break;
|
||||
}
|
||||
hashRegister(p->db);
|
||||
if( runSqlReturnUInt(p, &nRPage, "PRAGMA page_count") ){
|
||||
if( runSqlReturnUInt(p, &nRPage, "PRAGMA replica.page_count") ){
|
||||
break;
|
||||
}
|
||||
if( nRPage==0 ){
|
||||
runSql(p, "PRAGMA page_size=%u", szOPage);
|
||||
runSql(p, "PRAGMA journal_mode=WAL");
|
||||
runSql(p, "SELECT * FROM sqlite_schema");
|
||||
runSql(p, "PRAGMA replica.page_size=%u", szOPage);
|
||||
runSql(p, "PRAGMA replica.journal_mode=WAL");
|
||||
runSql(p, "SELECT * FROM replica.sqlite_schema");
|
||||
}
|
||||
runSql(p, "BEGIN IMMEDIATE");
|
||||
runSqlReturnText(p, buf, "PRAGMA journal_mode");
|
||||
runSqlReturnText(p, buf, "PRAGMA replica.journal_mode");
|
||||
if( strcmp(buf, "wal")!=0 ){
|
||||
reportError(p, "replica is not in WAL mode");
|
||||
break;
|
||||
}
|
||||
runSqlReturnUInt(p, &nRPage, "PRAGMA page_count");
|
||||
runSqlReturnUInt(p, &szRPage, "PRAGMA page_size");
|
||||
runSqlReturnUInt(p, &nRPage, "PRAGMA replica.page_count");
|
||||
runSqlReturnUInt(p, &szRPage, "PRAGMA replica.page_size");
|
||||
if( szRPage!=szOPage ){
|
||||
reportError(p, "page size mismatch; origin is %d bytes and "
|
||||
"replica is %d bytes", szOPage, szRPage);
|
||||
@ -1448,7 +1432,7 @@ static void replicaSide(SQLiteRsync *p){
|
||||
}
|
||||
|
||||
pStmt = prepareStmt(p,
|
||||
"SELECT hash(data) FROM sqlite_dbpage"
|
||||
"SELECT hash(data) FROM sqlite_dbpage('replica')"
|
||||
" WHERE pgno<=min(%d,%d)"
|
||||
" ORDER BY pgno", nRPage, nOPage);
|
||||
while( sqlite3_step(pStmt)==SQLITE_ROW && p->nErr==0 && p->nWrErr==0 ){
|
||||
@ -1493,7 +1477,7 @@ static void replicaSide(SQLiteRsync *p){
|
||||
if( p->nErr ) break;
|
||||
if( pIns==0 ){
|
||||
pIns = prepareStmt(p,
|
||||
"INSERT INTO sqlite_dbpage(pgno,data) VALUES(?1,?2)"
|
||||
"INSERT INTO sqlite_dbpage(pgno,data,schema)VALUES(?1,?2,'replica')"
|
||||
);
|
||||
if( pIns==0 ) break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user