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
diff --git a/tool/sqldiff.c b/tool/sqldiff.c
index b1363bb..cbb57e7 100644
--- a/tool/sqldiff.c
+++ b/tool/sqldiff.c
@@ -1179,8 +1179,9 @@
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 @@
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 @@
);
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%%'");
}