mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Fix an issue with sqldiff reported by
[forum:/info/9bd2155bdfae25a7|forum post 9bd2155bdfae25a7]. FossilOrigin-Name: 736a79c1491065f4ee77ce644af0e529e555ca733c78dbd55487d55d4ddbe5bd
This commit is contained in:
@ -605,18 +605,18 @@ static void diff_one_table(const char *zTab, FILE *out){
|
||||
strPrintf(&sql, "%sB.%s", zSep, az[i]);
|
||||
zSep = ", ";
|
||||
}
|
||||
strPrintf(&sql, ", 1%s -- changed row\n", nPk==n ? "" : ",");
|
||||
strPrintf(&sql, ", 1 /* changed row */");
|
||||
while( az[i] ){
|
||||
strPrintf(&sql, " A.%s IS NOT B.%s, B.%s%s\n",
|
||||
az[i], az2[i], az2[i], az2[i+1]==0 ? "" : ",");
|
||||
strPrintf(&sql, ", A.%s IS NOT B.%s, B.%s",
|
||||
az[i], az2[i], az2[i]);
|
||||
i++;
|
||||
}
|
||||
while( az2[i] ){
|
||||
strPrintf(&sql, " B.%s IS NOT NULL, B.%s%s\n",
|
||||
az2[i], az2[i], az2[i+1]==0 ? "" : ",");
|
||||
strPrintf(&sql, ", B.%s IS NOT NULL, B.%s",
|
||||
az2[i], az2[i]);
|
||||
i++;
|
||||
}
|
||||
strPrintf(&sql, " FROM main.%s A, aux.%s B\n", zId, zId);
|
||||
strPrintf(&sql, "\n FROM main.%s A, aux.%s B\n", zId, zId);
|
||||
zSep = " WHERE";
|
||||
for(i=0; i<nPk; i++){
|
||||
strPrintf(&sql, "%s A.%s=B.%s", zSep, az[i], az[i]);
|
||||
@ -642,12 +642,12 @@ static void diff_one_table(const char *zTab, FILE *out){
|
||||
strPrintf(&sql, "%sA.%s", zSep, az[i]);
|
||||
zSep = ", ";
|
||||
}
|
||||
strPrintf(&sql, ", 2%s -- deleted row\n", nPk==n ? "" : ",");
|
||||
strPrintf(&sql, ", 2 /* deleted row */");
|
||||
while( az2[i] ){
|
||||
strPrintf(&sql, " NULL, NULL%s\n", i==n2-1 ? "" : ",");
|
||||
strPrintf(&sql, ", NULL, NULL");
|
||||
i++;
|
||||
}
|
||||
strPrintf(&sql, " FROM main.%s A\n", zId);
|
||||
strPrintf(&sql, "\n FROM main.%s A\n", zId);
|
||||
strPrintf(&sql, " WHERE NOT EXISTS(SELECT 1 FROM aux.%s B\n", zId);
|
||||
zSep = " WHERE";
|
||||
for(i=0; i<nPk; i++){
|
||||
@ -660,12 +660,12 @@ static void diff_one_table(const char *zTab, FILE *out){
|
||||
strPrintf(&sql, "%sB.%s", zSep, az[i]);
|
||||
zSep = ", ";
|
||||
}
|
||||
strPrintf(&sql, ", 3%s -- inserted row\n", nPk==n ? "" : ",");
|
||||
strPrintf(&sql, ", 3 /* inserted row */");
|
||||
while( az2[i] ){
|
||||
strPrintf(&sql, " 1, B.%s%s\n", az2[i], az2[i+1]==0 ? "" : ",");
|
||||
strPrintf(&sql, ", 1, B.%s", az2[i]);
|
||||
i++;
|
||||
}
|
||||
strPrintf(&sql, " FROM aux.%s B\n", zId);
|
||||
strPrintf(&sql, "\n FROM aux.%s B\n", zId);
|
||||
strPrintf(&sql, " WHERE NOT EXISTS(SELECT 1 FROM main.%s A\n", zId);
|
||||
zSep = " WHERE";
|
||||
for(i=0; i<nPk; i++){
|
||||
|
Reference in New Issue
Block a user