mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
For sqldiff, sqlite_schema comparisons must use compound (synthesized) PK.
FossilOrigin-Name: 5bdd8466129b8e477c8349847f19f2a5adea3f650cca6dbafa3b835e5a538d09
This commit is contained in:
14
manifest
14
manifest
@@ -1,5 +1,5 @@
|
|||||||
C New\stest\scases\sadded\sto\sfuzzdata8.db.\s\sNo\scode\schanges.
|
C For\ssqldiff,\ssqlite_schema\scomparisons\smust\suse\scompound\s(synthesized)\sPK.
|
||||||
D 2021-09-07T19:23:32.687
|
D 2021-09-07T20:58:49.103
|
||||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||||
@@ -1887,7 +1887,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
|||||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||||
F tool/speedtest8inst1.c 7ce07da76b5e745783e703a834417d725b7d45fd
|
F tool/speedtest8inst1.c 7ce07da76b5e745783e703a834417d725b7d45fd
|
||||||
F tool/split-sqlite3c.tcl 3efcd4240b738f6bb2b5af0aea7e1e0ef9bc1c61654f645076cec883030b710c
|
F tool/split-sqlite3c.tcl 3efcd4240b738f6bb2b5af0aea7e1e0ef9bc1c61654f645076cec883030b710c
|
||||||
F tool/sqldiff.c 76381d75e306e3d8cb8bd16dee9e5f752861442898166899749a645db9463e63
|
F tool/sqldiff.c 9c639de9fa541a947ea9776435c84adf00f43945e262556e15219ef09f0d912c
|
||||||
F tool/sqlite3_analyzer.c.in 7eeaae8b0d7577662acaabbb11107af0659d1b41bc1dfdd4d91422de27127968
|
F tool/sqlite3_analyzer.c.in 7eeaae8b0d7577662acaabbb11107af0659d1b41bc1dfdd4d91422de27127968
|
||||||
F tool/sqltclsh.c.in 1bcc2e9da58fadf17b0bf6a50e68c1159e602ce057210b655d50bad5aaaef898
|
F tool/sqltclsh.c.in 1bcc2e9da58fadf17b0bf6a50e68c1159e602ce057210b655d50bad5aaaef898
|
||||||
F tool/sqltclsh.tcl 862f4cf1418df5e1315b5db3b5ebe88969e2a784525af5fbf9596592f14ed848
|
F tool/sqltclsh.tcl 862f4cf1418df5e1315b5db3b5ebe88969e2a784525af5fbf9596592f14ed848
|
||||||
@@ -1922,7 +1922,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
|||||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||||
P 7ff92da9f183bc24a0d93996df771df7a712df1122ad897cb9143cde7d57ef7d
|
P 51e5aadafe1a4ba6a0be7fc1732d1ec940cbc5e23723b76267c2abf887d713ac
|
||||||
R 13319b6ed34117906bc5e784808c9a4f
|
R 17b6b23653b2d1c22cf2c809d09a9c4a
|
||||||
U drh
|
U larrybr
|
||||||
Z 6d5eaeab927eb4f20a0418089bf7ab3c
|
Z 07a4f44349ac85e50a32dd7e3855976b
|
||||||
|
@@ -1 +1 @@
|
|||||||
51e5aadafe1a4ba6a0be7fc1732d1ec940cbc5e23723b76267c2abf887d713ac
|
5bdd8466129b8e477c8349847f19f2a5adea3f650cca6dbafa3b835e5a538d09
|
@@ -200,7 +200,7 @@ static void namelistFree(char **az){
|
|||||||
** Primary key columns are listed first, followed by data columns.
|
** Primary key columns are listed first, followed by data columns.
|
||||||
** The number of columns in the primary key is returned in *pnPkey.
|
** The number of columns in the primary key is returned in *pnPkey.
|
||||||
**
|
**
|
||||||
** Normally, the "primary key" in the previous sentence is the true
|
** Normally [a], the "primary key" in the previous sentence is the true
|
||||||
** primary key - the rowid or INTEGER PRIMARY KEY for ordinary tables
|
** primary key - the rowid or INTEGER PRIMARY KEY for ordinary tables
|
||||||
** or the declared PRIMARY KEY for WITHOUT ROWID tables. However, if
|
** or the declared PRIMARY KEY for WITHOUT ROWID tables. However, if
|
||||||
** the g.bSchemaPK flag is set, then the schema-defined PRIMARY KEY is
|
** the g.bSchemaPK flag is set, then the schema-defined PRIMARY KEY is
|
||||||
@@ -210,8 +210,9 @@ static void namelistFree(char **az){
|
|||||||
** If the primary key for a table is the rowid but rowid is inaccessible,
|
** If the primary key for a table is the rowid but rowid is inaccessible,
|
||||||
** then this routine returns a NULL pointer.
|
** then this routine returns a NULL pointer.
|
||||||
**
|
**
|
||||||
** [a. If the named table is sqlite_schema, omits the "rootpage" column.]
|
** [a. If the lone, named table is "sqlite_schema", "rootpage" column is
|
||||||
|
** omitted and the "type" and "name" columns are made to be the PK.]
|
||||||
|
**
|
||||||
** Examples:
|
** Examples:
|
||||||
** CREATE TABLE t1(a INT UNIQUE, b INTEGER, c TEXT, PRIMARY KEY(c));
|
** CREATE TABLE t1(a INT UNIQUE, b INTEGER, c TEXT, PRIMARY KEY(c));
|
||||||
** *pnPKey = 1;
|
** *pnPKey = 1;
|
||||||
@@ -302,18 +303,32 @@ static char **columnNames(
|
|||||||
if( nPK==0 ) nPK = 1;
|
if( nPK==0 ) nPK = 1;
|
||||||
truePk = 1;
|
truePk = 1;
|
||||||
}
|
}
|
||||||
|
if( g.bSchemaCompare ){
|
||||||
|
assert( sqlite3_stricmp(zTab,"sqlite_schema")==0
|
||||||
|
|| sqlite3_stricmp(zTab,"sqlite_master")==0 );
|
||||||
|
/* For sqlite_schema, will use type and name as the PK. */
|
||||||
|
nPK = 2;
|
||||||
|
truePk = 0;
|
||||||
|
}
|
||||||
*pnPKey = nPK;
|
*pnPKey = nPK;
|
||||||
naz = nPK;
|
naz = nPK;
|
||||||
az = sqlite3_malloc( sizeof(char*)*(nPK+1) );
|
az = sqlite3_malloc( sizeof(char*)*(nPK+1) );
|
||||||
if( az==0 ) runtimeError("out of memory");
|
if( az==0 ) runtimeError("out of memory");
|
||||||
memset(az, 0, sizeof(char*)*(nPK+1));
|
memset(az, 0, sizeof(char*)*(nPK+1));
|
||||||
|
if( g.bSchemaCompare ){
|
||||||
|
az[0] = sqlite3_mprintf("%s", "type");
|
||||||
|
az[1] = sqlite3_mprintf("%s", "name");
|
||||||
|
}
|
||||||
while( SQLITE_ROW==sqlite3_step(pStmt) ){
|
while( SQLITE_ROW==sqlite3_step(pStmt) ){
|
||||||
char * sid = safeId((char*)sqlite3_column_text(pStmt,1));
|
char * sid = safeId((char*)sqlite3_column_text(pStmt,1));
|
||||||
int iPKey;
|
int iPKey;
|
||||||
if( truePk && (iPKey = sqlite3_column_int(pStmt,5))>0 ){
|
if( truePk && (iPKey = sqlite3_column_int(pStmt,5))>0 ){
|
||||||
az[iPKey-1] = sid;
|
az[iPKey-1] = sid;
|
||||||
}else{
|
}else{
|
||||||
if( !g.bSchemaCompare || strcmp(sid,"rootpage")!=0 ){
|
if( !g.bSchemaCompare
|
||||||
|
|| !(strcmp(sid,"rootpage")==0
|
||||||
|
||strcmp(sid,"name")==0
|
||||||
|
||strcmp(sid,"type")==0)){
|
||||||
az = sqlite3_realloc(az, sizeof(char*)*(naz+2) );
|
az = sqlite3_realloc(az, sizeof(char*)*(naz+2) );
|
||||||
if( az==0 ) runtimeError("out of memory");
|
if( az==0 ) runtimeError("out of memory");
|
||||||
az[naz++] = sid;
|
az[naz++] = sid;
|
||||||
@@ -335,17 +350,13 @@ static char **columnNames(
|
|||||||
** avoids extraneous diffs against the schemas due to rowid variance. */
|
** avoids extraneous diffs against the schemas due to rowid variance. */
|
||||||
if( az[0]==0 ){
|
if( az[0]==0 ){
|
||||||
const char *azRowid[] = { "rowid", "_rowid_", "oid" };
|
const char *azRowid[] = { "rowid", "_rowid_", "oid" };
|
||||||
if( g.bSchemaCompare ){
|
for(i=0; i<sizeof(azRowid)/sizeof(azRowid[0]); i++){
|
||||||
az[0] = sqlite3_mprintf("%s", "name");
|
for(j=1; j<naz; j++){
|
||||||
}else {
|
if( sqlite3_stricmp(az[j], azRowid[i])==0 ) break;
|
||||||
for(i=0; i<sizeof(azRowid)/sizeof(azRowid[0]); i++){
|
}
|
||||||
for(j=1; j<naz; j++){
|
if( j>=naz ){
|
||||||
if( sqlite3_stricmp(az[j], azRowid[i])==0 ) break;
|
az[0] = sqlite3_mprintf("%s", azRowid[i]);
|
||||||
}
|
break;
|
||||||
if( j>=naz ){
|
|
||||||
az[0] = sqlite3_mprintf("%s", azRowid[i]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( az[0]==0 ){
|
if( az[0]==0 ){
|
||||||
@@ -1979,8 +1990,8 @@ int main(int argc, char **argv){
|
|||||||
if( i==argc-1 ) cmdlineError("missing argument to %s", argv[i]);
|
if( i==argc-1 ) cmdlineError("missing argument to %s", argv[i]);
|
||||||
zTab = argv[++i];
|
zTab = argv[++i];
|
||||||
g.bSchemaCompare =
|
g.bSchemaCompare =
|
||||||
sqlite3_stricmp(zTab, "sqlite_schema")
|
sqlite3_stricmp(zTab, "sqlite_schema")==0
|
||||||
|| sqlite3_stricmp(zTab, "sqlite_master");
|
|| sqlite3_stricmp(zTab, "sqlite_master")==0;
|
||||||
}else
|
}else
|
||||||
if( strcmp(z,"transaction")==0 ){
|
if( strcmp(z,"transaction")==0 ){
|
||||||
useTransaction = 1;
|
useTransaction = 1;
|
||||||
|
Reference in New Issue
Block a user