Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix an issue with sqldiff reported by forum post 9bd2155bdfae25a7. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
736a79c1491065f4ee77ce644af0e529 |
User & Date: | drh 2023-05-27 20:08:23 |
Context
2023-06-12
| ||
13:43 | Fix an issue with sqldiff reported by forum post 9bd2155bdfae25a7. (check-in: 50721074 user: drh tags: branch-3.42) | |
2023-05-30
| ||
13:27 | Minor internal JS doc fix. No code changes. (check-in: 68abee3c user: stephan tags: trunk) | |
2023-05-29
| ||
18:01 | Prototype implementation of a proposed "timediff(X,Y)" SQL function. (check-in: 054a1951 user: drh tags: timediff) | |
2023-05-27
| ||
20:08 | Fix an issue with sqldiff reported by forum post 9bd2155bdfae25a7. (check-in: 736a79c1 user: drh tags: trunk) | |
19:34 | Add extra tests for fts5, large rowids and "ORDER BY rowid DESC". No changes to code. (check-in: b5b5eaee user: dan tags: trunk) | |
Changes
Changes to test/sqldiff1.test.
︙ | ︙ | |||
59 60 61 62 63 64 65 66 | INSERT INTO t2(a,b) VALUES(53.5,'one'||X'0a0d'); INSERT INTO t2(a,b) VALUES(54.5,'one'||X'0a' ||'two'); CREATE TABLE t3(a,b,c); INSERT INTO t3(rowid,a,b,c) VALUES(1,111,222,333); DROP TABLE t4;} finish_test | > > > > > > > > > > > > > > > > > > > > > > | 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | INSERT INTO t2(a,b) VALUES(53.5,'one'||X'0a0d'); INSERT INTO t2(a,b) VALUES(54.5,'one'||X'0a' ||'two'); CREATE TABLE t3(a,b,c); INSERT INTO t3(rowid,a,b,c) VALUES(1,111,222,333); DROP TABLE t4;} db close forcedelete test.db test2.db sqlite3 db test.db do_test sqldiff-2.0 { db eval { CREATE TABLE t1(a INTEGER PRIMARY KEY); } db close sqlite3 db test2.db db eval { CREATE TABLE t1(a INTEGER PRIMARY KEY, b); } db close set line "exec $PROG test.db test2.db" unset -nocomplain ::MSG catch {eval $line} ::MSG } {0} do_test sqldiff-2.1 { set ::MSG } {ALTER TABLE t1 ADD COLUMN b;} finish_test |
Changes to tool/sqldiff.c.
︙ | ︙ | |||
601 602 603 604 605 606 607 | nQ = nPk2+1+2*(n2-nPk2); if( n2>nPk2 ){ zSep = "SELECT "; for(i=0; i<nPk; i++){ strPrintf(&sql, "%sB.%s", zSep, az[i]); zSep = ", "; } | | | | | | | | 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 | nQ = nPk2+1+2*(n2-nPk2); if( n2>nPk2 ){ zSep = "SELECT "; for(i=0; i<nPk; i++){ strPrintf(&sql, "%sB.%s", zSep, az[i]); zSep = ", "; } strPrintf(&sql, ", 1 /* changed row */"); while( az[i] ){ 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", az2[i], az2[i]); i++; } 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]); zSep = " AND"; } zSep = "\n AND ("; while( az[i] ){ |
︙ | ︙ | |||
638 639 640 641 642 643 644 | strPrintf(&sql, " UNION ALL\n"); } zSep = "SELECT "; for(i=0; i<nPk; i++){ strPrintf(&sql, "%sA.%s", zSep, az[i]); zSep = ", "; } | | | | | | | | 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 | strPrintf(&sql, " UNION ALL\n"); } zSep = "SELECT "; for(i=0; i<nPk; i++){ strPrintf(&sql, "%sA.%s", zSep, az[i]); zSep = ", "; } strPrintf(&sql, ", 2 /* deleted row */"); while( az2[i] ){ strPrintf(&sql, ", NULL, NULL"); i++; } 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++){ strPrintf(&sql, "%s A.%s=B.%s", zSep, az[i], az[i]); zSep = " AND"; } strPrintf(&sql, ")\n"); zSep = " UNION ALL\nSELECT "; for(i=0; i<nPk; i++){ strPrintf(&sql, "%sB.%s", zSep, az[i]); zSep = ", "; } strPrintf(&sql, ", 3 /* inserted row */"); while( az2[i] ){ strPrintf(&sql, ", 1, B.%s", az2[i]); i++; } 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++){ strPrintf(&sql, "%s A.%s=B.%s", zSep, az[i], az[i]); zSep = " AND"; } strPrintf(&sql, ")\n ORDER BY"); |
︙ | ︙ |