aboutsummaryrefslogtreecommitdiff
path: root/tool/sqldiff.c
diff options
context:
space:
mode:
authordan <dan@noemail.net>2016-09-01 14:03:28 +0000
committerdan <dan@noemail.net>2016-09-01 14:03:28 +0000
commite5a0cfa161a77e8ab674fc53f30154c9129eff70 (patch)
tree6e5c020c6ab2cb12a58f2744af61db0ed26864d9 /tool/sqldiff.c
parentd0d49b9ca3c106e972ca724c7202a81182f4260f (diff)
downloadsqlite-e5a0cfa161a77e8ab674fc53f30154c9129eff70.tar.gz
sqlite-e5a0cfa161a77e8ab674fc53f30154c9129eff70.zip
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
Diffstat (limited to 'tool/sqldiff.c')
-rw-r--r--tool/sqldiff.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/tool/sqldiff.c b/tool/sqldiff.c
index b1363bb34..cbb57e777 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%%'");
}