Check-in [6cfd8ecc05]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
SHA1 Hash:6cfd8ecc05c82f1e60e302015ee4c26d2d128134
Date: 2012-04-24 13:36:55
User: drh
Comment:Update to the latest SQLite version 3.7.12 beta.
Tags And Properties
Changes

Changes to src/shell.c

495 /* 495 /* 496 ** Output the given string as a hex-encoded blob (eg. X'1234' ) 496 ** Output the given string as a hex-encoded blob (eg. X'1234' ) 497 */ 497 */ 498 static void output_hex_blob(FILE *out, const void *pBlob, int nBlob){ 498 static void output_hex_blob(FILE *out, const void *pBlob, int nBlob){ 499 int i; 499 int i; 500 char *zBlob = (char *)pBlob; 500 char *zBlob = (char *)pBlob; 501 fprintf(out,"X'"); 501 fprintf(out,"X'"); 502 for(i=0; i<nBlob; i++){ fprintf(out,"%02x",zBlob[i]); } | 502 for(i=0; i<nBlob; i++){ fprintf(out,"%02x",zBlob[i]&0xff); } 503 fprintf(out,"'"); 503 fprintf(out,"'"); 504 } 504 } 505 505 506 /* 506 /* 507 ** Output the given string as a quoted string using SQL quoting conventions. 507 ** Output the given string as a quoted string using SQL quoting conventions. 508 */ 508 */ 509 static void output_quoted_string(FILE *out, const char *z){ 509 static void output_quoted_string(FILE *out, const char *z){ ................................................................................................................................................................................ 2244 }else 2244 }else 2245 2245 2246 if( c=='s' && strncmp(azArg[0], "stats", n)==0 && nArg>1 && nArg<3 ){ 2246 if( c=='s' && strncmp(azArg[0], "stats", n)==0 && nArg>1 && nArg<3 ){ 2247 p->statsOn = booleanValue(azArg[1]); 2247 p->statsOn = booleanValue(azArg[1]); 2248 }else 2248 }else 2249 2249 2250 if( c=='t' && n>1 && strncmp(azArg[0], "tables", n)==0 && nArg<3 ){ 2250 if( c=='t' && n>1 && strncmp(azArg[0], "tables", n)==0 && nArg<3 ){ 2251 char **azResult; | 2251 sqlite3_stmt *pStmt; 2252 int nRow; | 2252 char **azResult; 2253 char *zErrMsg; | 2253 int nRow, nAlloc; 2254 open_db(p); | 2254 char *zSql = 0; 2255 if( nArg==1 ){ | 2255 int ii; 2256 rc = sqlite3_get_table(p->db, | 2256 open_db(p); 2257 "SELECT name FROM sqlite_master " | 2257 rc = sqlite3_prepare_v2(p->db, "PRAGMA database_list", -1, &pStmt, 0); 2258 "WHERE type IN ('table','view') AND name NOT LIKE 'sqlite_%' " | 2258 if( rc ) return rc; 2259 "UNION ALL " | 2259 zSql = sqlite3_mprintf( 2260 "SELECT name FROM sqlite_temp_master " | 2260 "SELECT name FROM sqlite_master" 2261 "WHERE type IN ('table','view') " | 2261 " WHERE type IN ('table','view')" 2262 "ORDER BY 1", | 2262 " AND name NOT LIKE 'sqlite_%%'" 2263 &azResult, &nRow, 0, &zErrMsg | 2263 " AND name LIKE ?1"); 2264 ); | 2264 while( sqlite3_step(pStmt)==SQLITE_ROW ){ 2265 }else{ | 2265 const char *zDbName = (const char*)sqlite3_column_text(pStmt, 1); 2266 zShellStatic = azArg[1]; | 2266 if( zDbName==0 || strcmp(zDbName,"main")==0 ) continue; 2267 rc = sqlite3_get_table(p->db, | 2267 if( strcmp(zDbName,"temp")==0 ){ 2268 "SELECT name FROM sqlite_master " | 2268 zSql = sqlite3_mprintf( 2269 "WHERE type IN ('table','view') AND name LIKE shellstatic() " | 2269 "%z UNION ALL " 2270 "UNION ALL " | 2270 "SELECT 'temp.' || name FROM sqlite_temp_master" 2271 "SELECT name FROM sqlite_temp_master " | 2271 " WHERE type IN ('table','view')" 2272 "WHERE type IN ('table','view') AND name LIKE shellstatic() " | 2272 " AND name NOT LIKE 'sqlite_%%'" 2273 "ORDER BY 1", | 2273 " AND name LIKE ?1", zSql); 2274 &azResult, &nRow, 0, &zErrMsg | 2274 }else{ 2275 ); | 2275 zSql = sqlite3_mprintf( 2276 zShellStatic = 0; | 2276 "%z UNION ALL " 2277 } | 2277 "SELECT '%q.' || name FROM \"%w\".sqlite_master" 2278 if( zErrMsg ){ | 2278 " WHERE type IN ('table','view')" 2279 fprintf(stderr,"Error: %s\n", zErrMsg); | 2279 " AND name NOT LIKE 'sqlite_%%'" 2280 sqlite3_free(zErrMsg); | 2280 " AND name LIKE ?1", zSql, zDbName, zDbName); 2281 rc = 1; | 2281 } 2282 }else if( rc != SQLITE_OK ){ | 2282 } 2283 fprintf(stderr,"Error: querying sqlite_master and sqlite_temp_master\n"); | 2283 sqlite3_finalize(pStmt); 2284 rc = 1; | 2284 zSql = sqlite3_mprintf("%z ORDER BY 1", zSql); 2285 }else{ | 2285 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); > 2286 sqlite3_free(zSql); > 2287 if( rc ) return rc; > 2288 nRow = nAlloc = 0; > 2289 azResult = 0; > 2290 if( nArg>1 ){ > 2291 sqlite3_bind_text(pStmt, 1, azArg[1], -1, SQLITE_TRANSIENT); > 2292 }else{ > 2293 sqlite3_bind_text(pStmt, 1, "%", -1, SQLITE_STATIC); > 2294 } > 2295 while( sqlite3_step(pStmt)==SQLITE_ROW ){ > 2296 if( nRow>=nAlloc ){ > 2297 char **azNew; > 2298 int n = nAlloc*2 + 10; > 2299 azNew = sqlite3_realloc(azResult, sizeof(azResult[0])*n); > 2300 if( azNew==0 ){ > 2301 fprintf(stderr, "Error: out of memory\n"); > 2302 break; > 2303 } > 2304 nAlloc = n; > 2305 azResult = azNew; > 2306 } > 2307 azResult[nRow] = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 0)); > 2308 if( azResult[nRow] ) nRow++; > 2309 } > 2310 sqlite3_finalize(pStmt); > 2311 if( nRow>0 ){ 2286 int len, maxlen = 0; 2312 int len, maxlen = 0; 2287 int i, j; 2313 int i, j; 2288 int nPrintCol, nPrintRow; 2314 int nPrintCol, nPrintRow; 2289 for(i=1; i<=nRow; i++){ | 2315 for(i=0; i<nRow; i++){ 2290 if( azResult[i]==0 ) continue; < 2291 len = strlen30(azResult[i]); 2316 len = strlen30(azResult[i]); 2292 if( len>maxlen ) maxlen = len; 2317 if( len>maxlen ) maxlen = len; 2293 } 2318 } 2294 nPrintCol = 80/(maxlen+2); 2319 nPrintCol = 80/(maxlen+2); 2295 if( nPrintCol<1 ) nPrintCol = 1; 2320 if( nPrintCol<1 ) nPrintCol = 1; 2296 nPrintRow = (nRow + nPrintCol - 1)/nPrintCol; 2321 nPrintRow = (nRow + nPrintCol - 1)/nPrintCol; 2297 for(i=0; i<nPrintRow; i++){ 2322 for(i=0; i<nPrintRow; i++){ 2298 for(j=i+1; j<=nRow; j+=nPrintRow){ | 2323 for(j=i; j<nRow; j+=nPrintRow){ 2299 char *zSp = j<=nPrintRow ? "" : " "; | 2324 char *zSp = j<nPrintRow ? "" : " "; 2300 printf("%s%-*s", zSp, maxlen, azResult[j] ? azResult[j] : ""); 2325 printf("%s%-*s", zSp, maxlen, azResult[j] ? azResult[j] : ""); 2301 } 2326 } 2302 printf("\n"); 2327 printf("\n"); 2303 } 2328 } 2304 } 2329 } > 2330 for(ii=0; ii<nRow; ii++) sqlite3_free(azResult[ii]); 2305 sqlite3_free_table(azResult); | 2331 sqlite3_free(azResult); 2306 }else 2332 }else 2307 2333 2308 if( c=='t' && n>=8 && strncmp(azArg[0], "testctrl", n)==0 && nArg>=2 ){ 2334 if( c=='t' && n>=8 && strncmp(azArg[0], "testctrl", n)==0 && nArg>=2 ){ 2309 static const struct { 2335 static const struct { 2310 const char *zCtrlName; /* Name of a test-control option */ 2336 const char *zCtrlName; /* Name of a test-control option */ 2311 int ctrlCode; /* Integer code for that option */ 2337 int ctrlCode; /* Integer code for that option */ 2312 } aCtrl[] = { 2338 } aCtrl[] = { ................................................................................................................................................................................ 2433 if( HAS_TIMER && c=='t' && n>=5 && strncmp(azArg[0], "timer", n)==0 2459 if( HAS_TIMER && c=='t' && n>=5 && strncmp(azArg[0], "timer", n)==0 2434 && nArg==2 2460 && nArg==2 2435 ){ 2461 ){ 2436 enableTimer = booleanValue(azArg[1]); 2462 enableTimer = booleanValue(azArg[1]); 2437 }else 2463 }else 2438 2464 2439 if( c=='t' && strncmp(azArg[0], "trace", n)==0 && nArg>1 ){ 2465 if( c=='t' && strncmp(azArg[0], "trace", n)==0 && nArg>1 ){ > 2466 open_db(p); 2440 output_file_close(p->traceOut); 2467 output_file_close(p->traceOut); 2441 p->traceOut = output_file_open(azArg[1]); 2468 p->traceOut = output_file_open(azArg[1]); 2442 #ifndef SQLITE_OMIT_TRACE 2469 #ifndef SQLITE_OMIT_TRACE 2443 if( p->traceOut==0 ){ 2470 if( p->traceOut==0 ){ 2444 sqlite3_trace(p->db, 0, 0); 2471 sqlite3_trace(p->db, 0, 0); 2445 }else{ 2472 }else{ 2446 sqlite3_trace(p->db, sql_trace_callback, p->traceOut); 2473 sqlite3_trace(p->db, sql_trace_callback, p->traceOut); ................................................................................................................................................................................ 2568 int startline = 0; 2595 int startline = 0; 2569 2596 2570 while( errCnt==0 || !bail_on_error || (in==0 && stdin_is_interactive) ){ 2597 while( errCnt==0 || !bail_on_error || (in==0 && stdin_is_interactive) ){ 2571 fflush(p->out); 2598 fflush(p->out); 2572 free(zLine); 2599 free(zLine); 2573 zLine = one_input_line(zSql, in); 2600 zLine = one_input_line(zSql, in); 2574 if( zLine==0 ){ 2601 if( zLine==0 ){ 2575 break; /* We have reached EOF */ | 2602 /* End of input */ > 2603 if( stdin_is_interactive ) printf("\n"); > 2604 break; 2576 } 2605 } 2577 if( seenInterrupt ){ 2606 if( seenInterrupt ){ 2578 if( in!=0 ) break; 2607 if( in!=0 ) break; 2579 seenInterrupt = 0; 2608 seenInterrupt = 0; 2580 } 2609 } 2581 lineno++; 2610 lineno++; 2582 if( (zSql==0 || zSql[0]==0) && _all_whitespace(zLine) ) continue; 2611 if( (zSql==0 || zSql[0]==0) && _all_whitespace(zLine) ) continue;

Changes to src/sqlite3.c

655 ** 655 ** 656 ** See also: [sqlite3_libversion()], 656 ** See also: [sqlite3_libversion()], 657 ** [sqlite3_libversion_number()], [sqlite3_sourceid()], 657 ** [sqlite3_libversion_number()], [sqlite3_sourceid()], 658 ** [sqlite_version()] and [sqlite_source_id()]. 658 ** [sqlite_version()] and [sqlite_source_id()]. 659 */ 659 */ 660 #define SQLITE_VERSION "3.7.12" 660 #define SQLITE_VERSION "3.7.12" 661 #define SQLITE_VERSION_NUMBER 3007012 661 #define SQLITE_VERSION_NUMBER 3007012 662 #define SQLITE_SOURCE_ID "2012-04-17 09:09:33 8e2363ad76446e863d03ead91fd62 | 662 #define SQLITE_SOURCE_ID "2012-04-24 13:14:49 dfce8569765614462a3952d1761c1 663 663 664 /* 664 /* 665 ** CAPI3REF: Run-Time Library Version Numbers 665 ** CAPI3REF: Run-Time Library Version Numbers 666 ** KEYWORDS: sqlite3_version, sqlite3_sourceid 666 ** KEYWORDS: sqlite3_version, sqlite3_sourceid 667 ** 667 ** 668 ** These interfaces provide the same information as the [SQLITE_VERSION], 668 ** These interfaces provide the same information as the [SQLITE_VERSION], 669 ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros 669 ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros ................................................................................................................................................................................ 78622 return WRC_Prune; 78622 return WRC_Prune; 78623 } 78623 } 78624 } 78624 } 78625 } 78625 } 78626 return WRC_Continue; 78626 return WRC_Continue; 78627 } 78627 } 78628 static int analyzeAggregatesInSelect(Walker *pWalker, Select *pSelect){ 78628 static int analyzeAggregatesInSelect(Walker *pWalker, Select *pSelect){ > 78629 UNUSED_PARAMETER(pWalker); > 78630 UNUSED_PARAMETER(pSelect); 78629 return WRC_Continue; 78631 return WRC_Continue; 78630 } 78632 } 78631 78633 78632 /* 78634 /* 78633 ** Analyze the given expression looking for aggregate functions and 78635 ** Analyze the given expression looking for aggregate functions and 78634 ** for variables that need to be added to the pParse->aAgg[] array. 78636 ** for variables that need to be added to the pParse->aAgg[] array. 78635 ** Make additional entries to the pParse->aAgg[] array as necessary. 78637 ** Make additional entries to the pParse->aAgg[] array as necessary. ................................................................................................................................................................................ 104436 ** 104438 ** 104437 ** 1. The index is itself UNIQUE, and 104439 ** 1. The index is itself UNIQUE, and 104438 ** 104440 ** 104439 ** 2. All of the columns in the index are either part of the pDistinct 104441 ** 2. All of the columns in the index are either part of the pDistinct 104440 ** list, or else the WHERE clause contains a term of the form "col=X", 104442 ** list, or else the WHERE clause contains a term of the form "col=X", 104441 ** where X is a constant value. The collation sequences of the 104443 ** where X is a constant value. The collation sequences of the 104442 ** comparison and select-list expressions must match those of the index. 104444 ** comparison and select-list expressions must match those of the index. > 104445 ** > 104446 ** 3. All of those index columns for which the WHERE clause does not > 104447 ** contain a "col=X" term are subject to a NOT NULL constraint. 104443 */ 104448 */ 104444 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ 104449 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ 104445 if( pIdx->onError==OE_None ) continue; 104450 if( pIdx->onError==OE_None ) continue; 104446 for(i=0; i<pIdx->nColumn; i++){ 104451 for(i=0; i<pIdx->nColumn; i++){ 104447 int iCol = pIdx->aiColumn[i]; 104452 int iCol = pIdx->aiColumn[i]; 104448 if( 0==findTerm(pWC, iBase, iCol, ~(Bitmask)0, WO_EQ, pIdx) | 104453 if( 0==findTerm(pWC, iBase, iCol, ~(Bitmask)0, WO_EQ, pIdx) ){ 104449 && 0>findIndexCol(pParse, pDistinct, iBase, pIdx, i) | 104454 int iIdxCol = findIndexCol(pParse, pDistinct, iBase, pIdx, i); 104450 ){ | 104455 if( iIdxCol<0 || pTab->aCol[pIdx->aiColumn[i]].notNull==0 ){ 104451 break; | 104456 break; > 104457 } 104452 } 104458 } 104453 } 104459 } 104454 if( i==pIdx->nColumn ){ 104460 if( i==pIdx->nColumn ){ 104455 /* This index implies that the DISTINCT qualifier is redundant. */ 104461 /* This index implies that the DISTINCT qualifier is redundant. */ 104456 return 1; 104462 return 1; 104457 } 104463 } 104458 } 104464 } ................................................................................................................................................................................ 104592 if( j>=nTerm ){ 104598 if( j>=nTerm ){ 104593 /* All terms of the ORDER BY clause are covered by this index so 104599 /* All terms of the ORDER BY clause are covered by this index so 104594 ** this index can be used for sorting. */ 104600 ** this index can be used for sorting. */ 104595 return 1; 104601 return 1; 104596 } 104602 } 104597 if( pIdx->onError!=OE_None && i==pIdx->nColumn 104603 if( pIdx->onError!=OE_None && i==pIdx->nColumn 104598 && (wsFlags & WHERE_COLUMN_NULL)==0 104604 && (wsFlags & WHERE_COLUMN_NULL)==0 104599 && !referencesOtherTables(pOrderBy, pMaskSet, j, base) ){ | 104605 && !referencesOtherTables(pOrderBy, pMaskSet, j, base) > 104606 ){ > 104607 Column *aCol = pIdx->pTable->aCol; > 104608 int i; > 104609 104600 /* All terms of this index match some prefix of the ORDER BY clause | 104610 /* All terms of this index match some prefix of the ORDER BY clause, 104601 ** and the index is UNIQUE and no terms on the tail of the ORDER BY | 104611 ** the index is UNIQUE, and no terms on the tail of the ORDER BY 104602 ** clause reference other tables in a join. If this is all true then < 104603 ** the order by clause is superfluous. Not that if the matching < 104604 ** condition is IS NULL then the result is not necessarily unique < 104605 ** even on a UNIQUE index, so disallow those cases. */ < > 104612 ** refer to other tables in a join. So, assuming that the index entries > 104613 ** visited contain no NULL values, then this index delivers rows in > 104614 ** the required order. > 104615 ** > 104616 ** It is not possible for any of the first nEqCol index fields to be > 104617 ** NULL (since the corresponding "=" operator in the WHERE clause would > 104618 ** not be true). So if all remaining index columns have NOT NULL > 104619 ** constaints attached to them, we can be confident that the visited > 104620 ** index entries are free of NULLs. */ > 104621 for(i=nEqCol; i<pIdx->nColumn; i++){ > 104622 if( aCol[pIdx->aiColumn[i]].notNull==0 ) break; > 104623 } 104606 return 1; | 104624 return (i==pIdx->nColumn); 104607 } 104625 } 104608 return 0; 104626 return 0; 104609 } 104627 } 104610 104628 104611 /* 104629 /* 104612 ** Prepare a crude estimate of the logarithm of the input value. 104630 ** Prepare a crude estimate of the logarithm of the input value. 104613 ** The results need not be exact. This is only used for estimating 104631 ** The results need not be exact. This is only used for estimating

Changes to src/sqlite3.h

105 ** 105 ** 106 ** See also: [sqlite3_libversion()], 106 ** See also: [sqlite3_libversion()], 107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()], 107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()], 108 ** [sqlite_version()] and [sqlite_source_id()]. 108 ** [sqlite_version()] and [sqlite_source_id()]. 109 */ 109 */ 110 #define SQLITE_VERSION "3.7.12" 110 #define SQLITE_VERSION "3.7.12" 111 #define SQLITE_VERSION_NUMBER 3007012 111 #define SQLITE_VERSION_NUMBER 3007012 112 #define SQLITE_SOURCE_ID "2012-04-17 09:09:33 8e2363ad76446e863d03ead91fd62 | 112 #define SQLITE_SOURCE_ID "2012-04-24 13:14:49 dfce8569765614462a3952d1761c1 113 113 114 /* 114 /* 115 ** CAPI3REF: Run-Time Library Version Numbers 115 ** CAPI3REF: Run-Time Library Version Numbers 116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid 116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid 117 ** 117 ** 118 ** These interfaces provide the same information as the [SQLITE_VERSION], 118 ** These interfaces provide the same information as the [SQLITE_VERSION], 119 ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros 119 ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros