From e5a0cfa161a77e8ab674fc53f30154c9129eff70 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 1 Sep 2016 14:03:28 +0000 Subject: [PATCH] Have "sqldiff --rbu" ignore rows with NULL values in primary key fields. RBU can't handle such rows and the documentation already says sqldiff ignores them. Because the code now uses "=" instead of "IS" to filter on primary key columns, diffs on virtual tables are faster now too. FossilOrigin-Name: f4ba894a86aa195bcbe2fa69e91cd870ec3fb577 --- ext/rbu/rbudiff.test | 10 ++++++++++ manifest | 14 +++++++------- manifest.uuid | 2 +- tool/sqldiff.c | 12 +++++++----- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/ext/rbu/rbudiff.test b/ext/rbu/rbudiff.test index 041a242428..4a32009230 100644 --- a/ext/rbu/rbudiff.test +++ b/ext/rbu/rbudiff.test @@ -140,6 +140,15 @@ foreach {tn init mod} { ); } + 4 { + CREATE TABLE x1(a, b, c, PRIMARY KEY(a, b, c)); + INSERT INTO x1 VALUES('u', 'v', NULL); + INSERT INTO x1 VALUES('x', 'y', 'z'); + INSERT INTO x1 VALUES('a', NULL, 'b'); + } { + INSERT INTO x1 VALUES('a', 'b', 'c'); + } + } { catch { db close } @@ -280,5 +289,6 @@ tablE t1 USING FTs5(c); } } + finish_test diff --git a/manifest b/manifest index c4f3856500..ed5afd047d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C If\sSQLITE_ENABLE_ZIPVFS\sis\sdefined,\sjournal_mode=off\sis\sconfigured\sand\sa\ssavepoint\sor\sstatement\srollback\sis\sattempted,\smove\sthe\spager\sinto\sthe\serror\sstate\sto\sprevent\sthe\stransaction\sfrom\sbeing\scommitted.\sThis\smakes\sit\ssafe\sto\suse\sjournal_mode=off\swith\szipvfs\sunder\ssome\sconditions. -D 2016-09-01T09:35:20.703 +C Have\s"sqldiff\s--rbu"\signore\srows\swith\sNULL\svalues\sin\sprimary\skey\sfields.\sRBU\scan't\shandle\ssuch\srows\sand\sthe\sdocumentation\salready\ssays\ssqldiff\signores\sthem.\sBecause\sthe\scode\snow\suses\s"="\sinstead\sof\s"IS"\sto\sfilter\son\sprimary\skey\scolumns,\sdiffs\son\svirtual\stables\sare\sfaster\snow\stoo. +D 2016-09-01T14:03:28.041 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5017381e4853b1472e01d5bb926be1268eba429c @@ -245,7 +245,7 @@ F ext/rbu/rbuB.test c25bc325b8072a766e56bb76c001866b405925c2 F ext/rbu/rbuC.test efe47db508a0269b683cb2a1913a425ffd39a831 F ext/rbu/rbu_common.tcl a38e8e2d4a50fd6aaf151633714c1b1d2fae3ead F ext/rbu/rbucrash.test 8d2ed5d4b05fef6c00c2a6b5f7ead71fa172a695 -F ext/rbu/rbudiff.test b3c7675810b81de98a930a87fcd40d9ae545619d +F ext/rbu/rbudiff.test d099b56b073a737cfe1b8e9f67b77940130719cb F ext/rbu/rbufault.test cc0be8d5d392d98b0c2d6a51be377ea989250a89 F ext/rbu/rbufault2.test 9a7f19edd6ea35c4c9f807d8a3db0a03a5670c06 F ext/rbu/rbufault3.test 54a399888ac4af44c68f9f58afbed23149428bca @@ -1478,7 +1478,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 7ce07da76b5e745783e703a834417d725b7d45fd F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c -F tool/sqldiff.c c965d49bf2677db06103854b47e105484b5b1b84 +F tool/sqldiff.c 7f567367d87fdb493e3e65169569a10d9f330c3f F tool/srcck1.c 371de5363b70154012955544f86fdee8f6e5326f F tool/stack_usage.tcl f8e71b92cdb099a147dad572375595eae55eca43 F tool/symbols-mingw.sh 4dbcea7e74768305384c9fd2ed2b41bbf9f0414d @@ -1511,7 +1511,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6602974d17536bcb904a794bddedffd58926794b -R 78dc0041209a92fe8b940a2665fbfc99 +P 38d31e189e7c7899e14455f2c083aa676ce4d4c0 +R ca589e025240033a5748a5eba7e4950c U dan -Z f1c8273131a5d41903cfd86ae1fce8b9 +Z 28ca6847fc75deee037b1b39928043e8 diff --git a/manifest.uuid b/manifest.uuid index d765505e05..78d594bd6c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -38d31e189e7c7899e14455f2c083aa676ce4d4c0 \ No newline at end of file +f4ba894a86aa195bcbe2fa69e91cd870ec3fb577 \ No newline at end of file diff --git a/tool/sqldiff.c b/tool/sqldiff.c index b1363bb341..cbb57e7774 100644 --- a/tool/sqldiff.c +++ b/tool/sqldiff.c @@ -1179,8 +1179,9 @@ static void getRbudiffQuery( strPrintf(pSql, " FROM aux.%Q AS n WHERE NOT EXISTS (\n", zTab); strPrintf(pSql, " SELECT 1 FROM ", zTab); strPrintf(pSql, " main.%Q AS o WHERE ", zTab); - strPrintfArray(pSql, " AND ", "(n.%Q IS o.%Q)", azCol, nPK); - strPrintf(pSql, "\n)"); + strPrintfArray(pSql, " AND ", "(n.%Q = o.%Q)", azCol, nPK); + strPrintf(pSql, "\n) AND "); + strPrintfArray(pSql, " AND ", "(n.%Q IS NOT NULL)", azCol, nPK); /* Deleted rows: */ strPrintf(pSql, "\nUNION ALL\nSELECT "); @@ -1194,8 +1195,9 @@ static void getRbudiffQuery( strPrintf(pSql, " FROM main.%Q AS n WHERE NOT EXISTS (\n", zTab); strPrintf(pSql, " SELECT 1 FROM ", zTab); strPrintf(pSql, " aux.%Q AS o WHERE ", zTab); - strPrintfArray(pSql, " AND ", "(n.%Q IS o.%Q)", azCol, nPK); - strPrintf(pSql, "\n) "); + strPrintfArray(pSql, " AND ", "(n.%Q = o.%Q)", azCol, nPK); + strPrintf(pSql, "\n) AND "); + strPrintfArray(pSql, " AND ", "(n.%Q IS NOT NULL)", azCol, nPK); /* Updated rows. If all table columns are part of the primary key, there ** can be no updates. In this case this part of the compound SELECT can @@ -1226,7 +1228,7 @@ static void getRbudiffQuery( ); strPrintf(pSql, "\nFROM main.%Q AS o, aux.%Q AS n\nWHERE ", zTab, zTab); - strPrintfArray(pSql, " AND ", "(n.%Q IS o.%Q)", azCol, nPK); + strPrintfArray(pSql, " AND ", "(n.%Q = o.%Q)", azCol, nPK); strPrintf(pSql, " AND ota_control LIKE '%%x%%'"); }