diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/build.c | 18 | ||||
-rw-r--r-- | src/tclsqlite.c | 19 |
2 files changed, 24 insertions, 13 deletions
diff --git a/src/build.c b/src/build.c index 35f5f5c36..8eab3823c 100644 --- a/src/build.c +++ b/src/build.c @@ -1739,15 +1739,6 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){ }else{ pPk = sqlite3PrimaryKeyIndex(pTab); - /* Bypass the creation of the PRIMARY KEY btree and the sqlite_master - ** table entry. This is only required if currently generating VDBE - ** code for a CREATE TABLE (not when parsing one as part of reading - ** a database schema). */ - if( v ){ - assert( db->init.busy==0 ); - sqlite3VdbeChangeOpcode(v, pPk->tnum, OP_Goto); - } - /* ** Remove all redundant columns from the PRIMARY KEY. For example, change ** "PRIMARY KEY(a,b,a,b,c,b,c,d)" into just "PRIMARY KEY(a,b,c,d)". Later @@ -1767,6 +1758,15 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){ if( !db->init.imposterTable ) pPk->uniqNotNull = 1; nPk = pPk->nKeyCol; + /* Bypass the creation of the PRIMARY KEY btree and the sqlite_master + ** table entry. This is only required if currently generating VDBE + ** code for a CREATE TABLE (not when parsing one as part of reading + ** a database schema). */ + if( v && pPk->tnum>0 ){ + assert( db->init.busy==0 ); + sqlite3VdbeChangeOpcode(v, pPk->tnum, OP_Goto); + } + /* The root page of the PRIMARY KEY is the table root page */ pPk->tnum = pTab->tnum; diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 341d3f0dc..1b9f91405 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -3882,28 +3882,39 @@ static int SQLITE_TCLAPI md5file_cmd( const char **argv ){ FILE *in; + int ofst; + int amt; MD5Context ctx; void (*converter)(unsigned char*, char*); unsigned char digest[16]; char zBuf[10240]; - if( argc!=2 ){ + if( argc!=2 && argc!=4 ){ Tcl_AppendResult(interp,"wrong # args: should be \"", argv[0], - " FILENAME\"", (char*)0); + " FILENAME [OFFSET AMT]\"", (char*)0); return TCL_ERROR; } + if( argc==4 ){ + ofst = atoi(argv[2]); + amt = atoi(argv[3]); + }else{ + ofst = 0; + amt = 2147483647; + } in = fopen(argv[1],"rb"); if( in==0 ){ Tcl_AppendResult(interp,"unable to open file \"", argv[1], "\" for reading", (char*)0); return TCL_ERROR; } + fseek(in, ofst, SEEK_SET); MD5Init(&ctx); - for(;;){ + while( amt>0 ){ int n; - n = (int)fread(zBuf, 1, sizeof(zBuf), in); + n = (int)fread(zBuf, 1, sizeof(zBuf)<=amt ? sizeof(zBuf) : amt, in); if( n<=0 ) break; MD5Update(&ctx, (unsigned char*)zBuf, (unsigned)n); + amt -= n; } fclose(in); MD5Final(digest, &ctx); |