Fossil SCM

Update to the latest SQLite version 3.7.12 beta.

drh 2012-04-24 13:36 trunk
Commit 6cfd8ecc05c82f1e60e302015ee4c26d2d128134
3 files changed +69 -40 +31 -13 +1 -1
+69 -40
--- src/shell.c
+++ src/shell.c
@@ -497,11 +497,11 @@
497497
*/
498498
static void output_hex_blob(FILE *out, const void *pBlob, int nBlob){
499499
int i;
500500
char *zBlob = (char *)pBlob;
501501
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); }
503503
fprintf(out,"'");
504504
}
505505
506506
/*
507507
** Output the given string as a quoted string using SQL quoting conventions.
@@ -2246,65 +2246,91 @@
22462246
if( c=='s' && strncmp(azArg[0], "stats", n)==0 && nArg>1 && nArg<3 ){
22472247
p->statsOn = booleanValue(azArg[1]);
22482248
}else
22492249
22502250
if( c=='t' && n>1 && strncmp(azArg[0], "tables", n)==0 && nArg<3 ){
2251
+ sqlite3_stmt *pStmt;
22512252
char **azResult;
2252
- int nRow;
2253
- char *zErrMsg;
2253
+ int nRow, nAlloc;
2254
+ char *zSql = 0;
2255
+ int ii;
22542256
open_db(p);
2255
- if( nArg==1 ){
2256
- rc = sqlite3_get_table(p->db,
2257
- "SELECT name FROM sqlite_master "
2258
- "WHERE type IN ('table','view') AND name NOT LIKE 'sqlite_%' "
2259
- "UNION ALL "
2260
- "SELECT name FROM sqlite_temp_master "
2261
- "WHERE type IN ('table','view') "
2262
- "ORDER BY 1",
2263
- &azResult, &nRow, 0, &zErrMsg
2264
- );
2265
- }else{
2266
- zShellStatic = azArg[1];
2267
- rc = sqlite3_get_table(p->db,
2268
- "SELECT name FROM sqlite_master "
2269
- "WHERE type IN ('table','view') AND name LIKE shellstatic() "
2270
- "UNION ALL "
2271
- "SELECT name FROM sqlite_temp_master "
2272
- "WHERE type IN ('table','view') AND name LIKE shellstatic() "
2273
- "ORDER BY 1",
2274
- &azResult, &nRow, 0, &zErrMsg
2275
- );
2276
- zShellStatic = 0;
2277
- }
2278
- if( zErrMsg ){
2279
- fprintf(stderr,"Error: %s\n", zErrMsg);
2280
- sqlite3_free(zErrMsg);
2281
- rc = 1;
2282
- }else if( rc != SQLITE_OK ){
2283
- fprintf(stderr,"Error: querying sqlite_master and sqlite_temp_master\n");
2284
- rc = 1;
2285
- }else{
2257
+ rc = sqlite3_prepare_v2(p->db, "PRAGMA database_list", -1, &pStmt, 0);
2258
+ if( rc ) return rc;
2259
+ zSql = sqlite3_mprintf(
2260
+ "SELECT name FROM sqlite_master"
2261
+ " WHERE type IN ('table','view')"
2262
+ " AND name NOT LIKE 'sqlite_%%'"
2263
+ " AND name LIKE ?1");
2264
+ while( sqlite3_step(pStmt)==SQLITE_ROW ){
2265
+ const char *zDbName = (const char*)sqlite3_column_text(pStmt, 1);
2266
+ if( zDbName==0 || strcmp(zDbName,"main")==0 ) continue;
2267
+ if( strcmp(zDbName,"temp")==0 ){
2268
+ zSql = sqlite3_mprintf(
2269
+ "%z UNION ALL "
2270
+ "SELECT 'temp.' || name FROM sqlite_temp_master"
2271
+ " WHERE type IN ('table','view')"
2272
+ " AND name NOT LIKE 'sqlite_%%'"
2273
+ " AND name LIKE ?1", zSql);
2274
+ }else{
2275
+ zSql = sqlite3_mprintf(
2276
+ "%z UNION ALL "
2277
+ "SELECT '%q.' || name FROM \"%w\".sqlite_master"
2278
+ " WHERE type IN ('table','view')"
2279
+ " AND name NOT LIKE 'sqlite_%%'"
2280
+ " AND name LIKE ?1", zSql, zDbName, zDbName);
2281
+ }
2282
+ }
2283
+ sqlite3_finalize(pStmt);
2284
+ zSql = sqlite3_mprintf("%z ORDER BY 1", zSql);
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 ){
22862312
int len, maxlen = 0;
22872313
int i, j;
22882314
int nPrintCol, nPrintRow;
2289
- for(i=1; i<=nRow; i++){
2290
- if( azResult[i]==0 ) continue;
2315
+ for(i=0; i<nRow; i++){
22912316
len = strlen30(azResult[i]);
22922317
if( len>maxlen ) maxlen = len;
22932318
}
22942319
nPrintCol = 80/(maxlen+2);
22952320
if( nPrintCol<1 ) nPrintCol = 1;
22962321
nPrintRow = (nRow + nPrintCol - 1)/nPrintCol;
22972322
for(i=0; i<nPrintRow; i++){
2298
- for(j=i+1; j<=nRow; j+=nPrintRow){
2299
- char *zSp = j<=nPrintRow ? "" : " ";
2323
+ for(j=i; j<nRow; j+=nPrintRow){
2324
+ char *zSp = j<nPrintRow ? "" : " ";
23002325
printf("%s%-*s", zSp, maxlen, azResult[j] ? azResult[j] : "");
23012326
}
23022327
printf("\n");
23032328
}
23042329
}
2305
- sqlite3_free_table(azResult);
2330
+ for(ii=0; ii<nRow; ii++) sqlite3_free(azResult[ii]);
2331
+ sqlite3_free(azResult);
23062332
}else
23072333
23082334
if( c=='t' && n>=8 && strncmp(azArg[0], "testctrl", n)==0 && nArg>=2 ){
23092335
static const struct {
23102336
const char *zCtrlName; /* Name of a test-control option */
@@ -2435,10 +2461,11 @@
24352461
){
24362462
enableTimer = booleanValue(azArg[1]);
24372463
}else
24382464
24392465
if( c=='t' && strncmp(azArg[0], "trace", n)==0 && nArg>1 ){
2466
+ open_db(p);
24402467
output_file_close(p->traceOut);
24412468
p->traceOut = output_file_open(azArg[1]);
24422469
#ifndef SQLITE_OMIT_TRACE
24432470
if( p->traceOut==0 ){
24442471
sqlite3_trace(p->db, 0, 0);
@@ -2570,11 +2597,13 @@
25702597
while( errCnt==0 || !bail_on_error || (in==0 && stdin_is_interactive) ){
25712598
fflush(p->out);
25722599
free(zLine);
25732600
zLine = one_input_line(zSql, in);
25742601
if( zLine==0 ){
2575
- break; /* We have reached EOF */
2602
+ /* End of input */
2603
+ if( stdin_is_interactive ) printf("\n");
2604
+ break;
25762605
}
25772606
if( seenInterrupt ){
25782607
if( in!=0 ) break;
25792608
seenInterrupt = 0;
25802609
}
25812610
--- src/shell.c
+++ src/shell.c
@@ -497,11 +497,11 @@
497 */
498 static void output_hex_blob(FILE *out, const void *pBlob, int nBlob){
499 int i;
500 char *zBlob = (char *)pBlob;
501 fprintf(out,"X'");
502 for(i=0; i<nBlob; i++){ fprintf(out,"%02x",zBlob[i]); }
503 fprintf(out,"'");
504 }
505
506 /*
507 ** Output the given string as a quoted string using SQL quoting conventions.
@@ -2246,65 +2246,91 @@
2246 if( c=='s' && strncmp(azArg[0], "stats", n)==0 && nArg>1 && nArg<3 ){
2247 p->statsOn = booleanValue(azArg[1]);
2248 }else
2249
2250 if( c=='t' && n>1 && strncmp(azArg[0], "tables", n)==0 && nArg<3 ){
 
2251 char **azResult;
2252 int nRow;
2253 char *zErrMsg;
 
2254 open_db(p);
2255 if( nArg==1 ){
2256 rc = sqlite3_get_table(p->db,
2257 "SELECT name FROM sqlite_master "
2258 "WHERE type IN ('table','view') AND name NOT LIKE 'sqlite_%' "
2259 "UNION ALL "
2260 "SELECT name FROM sqlite_temp_master "
2261 "WHERE type IN ('table','view') "
2262 "ORDER BY 1",
2263 &azResult, &nRow, 0, &zErrMsg
2264 );
2265 }else{
2266 zShellStatic = azArg[1];
2267 rc = sqlite3_get_table(p->db,
2268 "SELECT name FROM sqlite_master "
2269 "WHERE type IN ('table','view') AND name LIKE shellstatic() "
2270 "UNION ALL "
2271 "SELECT name FROM sqlite_temp_master "
2272 "WHERE type IN ('table','view') AND name LIKE shellstatic() "
2273 "ORDER BY 1",
2274 &azResult, &nRow, 0, &zErrMsg
2275 );
2276 zShellStatic = 0;
2277 }
2278 if( zErrMsg ){
2279 fprintf(stderr,"Error: %s\n", zErrMsg);
2280 sqlite3_free(zErrMsg);
2281 rc = 1;
2282 }else if( rc != SQLITE_OK ){
2283 fprintf(stderr,"Error: querying sqlite_master and sqlite_temp_master\n");
2284 rc = 1;
2285 }else{
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2286 int len, maxlen = 0;
2287 int i, j;
2288 int nPrintCol, nPrintRow;
2289 for(i=1; i<=nRow; i++){
2290 if( azResult[i]==0 ) continue;
2291 len = strlen30(azResult[i]);
2292 if( len>maxlen ) maxlen = len;
2293 }
2294 nPrintCol = 80/(maxlen+2);
2295 if( nPrintCol<1 ) nPrintCol = 1;
2296 nPrintRow = (nRow + nPrintCol - 1)/nPrintCol;
2297 for(i=0; i<nPrintRow; i++){
2298 for(j=i+1; j<=nRow; j+=nPrintRow){
2299 char *zSp = j<=nPrintRow ? "" : " ";
2300 printf("%s%-*s", zSp, maxlen, azResult[j] ? azResult[j] : "");
2301 }
2302 printf("\n");
2303 }
2304 }
2305 sqlite3_free_table(azResult);
 
2306 }else
2307
2308 if( c=='t' && n>=8 && strncmp(azArg[0], "testctrl", n)==0 && nArg>=2 ){
2309 static const struct {
2310 const char *zCtrlName; /* Name of a test-control option */
@@ -2435,10 +2461,11 @@
2435 ){
2436 enableTimer = booleanValue(azArg[1]);
2437 }else
2438
2439 if( c=='t' && strncmp(azArg[0], "trace", n)==0 && nArg>1 ){
 
2440 output_file_close(p->traceOut);
2441 p->traceOut = output_file_open(azArg[1]);
2442 #ifndef SQLITE_OMIT_TRACE
2443 if( p->traceOut==0 ){
2444 sqlite3_trace(p->db, 0, 0);
@@ -2570,11 +2597,13 @@
2570 while( errCnt==0 || !bail_on_error || (in==0 && stdin_is_interactive) ){
2571 fflush(p->out);
2572 free(zLine);
2573 zLine = one_input_line(zSql, in);
2574 if( zLine==0 ){
2575 break; /* We have reached EOF */
 
 
2576 }
2577 if( seenInterrupt ){
2578 if( in!=0 ) break;
2579 seenInterrupt = 0;
2580 }
2581
--- src/shell.c
+++ src/shell.c
@@ -497,11 +497,11 @@
497 */
498 static void output_hex_blob(FILE *out, const void *pBlob, int nBlob){
499 int i;
500 char *zBlob = (char *)pBlob;
501 fprintf(out,"X'");
502 for(i=0; i<nBlob; i++){ fprintf(out,"%02x",zBlob[i]&0xff); }
503 fprintf(out,"'");
504 }
505
506 /*
507 ** Output the given string as a quoted string using SQL quoting conventions.
@@ -2246,65 +2246,91 @@
2246 if( c=='s' && strncmp(azArg[0], "stats", n)==0 && nArg>1 && nArg<3 ){
2247 p->statsOn = booleanValue(azArg[1]);
2248 }else
2249
2250 if( c=='t' && n>1 && strncmp(azArg[0], "tables", n)==0 && nArg<3 ){
2251 sqlite3_stmt *pStmt;
2252 char **azResult;
2253 int nRow, nAlloc;
2254 char *zSql = 0;
2255 int ii;
2256 open_db(p);
2257 rc = sqlite3_prepare_v2(p->db, "PRAGMA database_list", -1, &pStmt, 0);
2258 if( rc ) return rc;
2259 zSql = sqlite3_mprintf(
2260 "SELECT name FROM sqlite_master"
2261 " WHERE type IN ('table','view')"
2262 " AND name NOT LIKE 'sqlite_%%'"
2263 " AND name LIKE ?1");
2264 while( sqlite3_step(pStmt)==SQLITE_ROW ){
2265 const char *zDbName = (const char*)sqlite3_column_text(pStmt, 1);
2266 if( zDbName==0 || strcmp(zDbName,"main")==0 ) continue;
2267 if( strcmp(zDbName,"temp")==0 ){
2268 zSql = sqlite3_mprintf(
2269 "%z UNION ALL "
2270 "SELECT 'temp.' || name FROM sqlite_temp_master"
2271 " WHERE type IN ('table','view')"
2272 " AND name NOT LIKE 'sqlite_%%'"
2273 " AND name LIKE ?1", zSql);
2274 }else{
2275 zSql = sqlite3_mprintf(
2276 "%z UNION ALL "
2277 "SELECT '%q.' || name FROM \"%w\".sqlite_master"
2278 " WHERE type IN ('table','view')"
2279 " AND name NOT LIKE 'sqlite_%%'"
2280 " AND name LIKE ?1", zSql, zDbName, zDbName);
2281 }
2282 }
2283 sqlite3_finalize(pStmt);
2284 zSql = sqlite3_mprintf("%z ORDER BY 1", zSql);
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 ){
2312 int len, maxlen = 0;
2313 int i, j;
2314 int nPrintCol, nPrintRow;
2315 for(i=0; i<nRow; i++){
 
2316 len = strlen30(azResult[i]);
2317 if( len>maxlen ) maxlen = len;
2318 }
2319 nPrintCol = 80/(maxlen+2);
2320 if( nPrintCol<1 ) nPrintCol = 1;
2321 nPrintRow = (nRow + nPrintCol - 1)/nPrintCol;
2322 for(i=0; i<nPrintRow; i++){
2323 for(j=i; j<nRow; j+=nPrintRow){
2324 char *zSp = j<nPrintRow ? "" : " ";
2325 printf("%s%-*s", zSp, maxlen, azResult[j] ? azResult[j] : "");
2326 }
2327 printf("\n");
2328 }
2329 }
2330 for(ii=0; ii<nRow; ii++) sqlite3_free(azResult[ii]);
2331 sqlite3_free(azResult);
2332 }else
2333
2334 if( c=='t' && n>=8 && strncmp(azArg[0], "testctrl", n)==0 && nArg>=2 ){
2335 static const struct {
2336 const char *zCtrlName; /* Name of a test-control option */
@@ -2435,10 +2461,11 @@
2461 ){
2462 enableTimer = booleanValue(azArg[1]);
2463 }else
2464
2465 if( c=='t' && strncmp(azArg[0], "trace", n)==0 && nArg>1 ){
2466 open_db(p);
2467 output_file_close(p->traceOut);
2468 p->traceOut = output_file_open(azArg[1]);
2469 #ifndef SQLITE_OMIT_TRACE
2470 if( p->traceOut==0 ){
2471 sqlite3_trace(p->db, 0, 0);
@@ -2570,11 +2597,13 @@
2597 while( errCnt==0 || !bail_on_error || (in==0 && stdin_is_interactive) ){
2598 fflush(p->out);
2599 free(zLine);
2600 zLine = one_input_line(zSql, in);
2601 if( zLine==0 ){
2602 /* End of input */
2603 if( stdin_is_interactive ) printf("\n");
2604 break;
2605 }
2606 if( seenInterrupt ){
2607 if( in!=0 ) break;
2608 seenInterrupt = 0;
2609 }
2610
+31 -13
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -657,11 +657,11 @@
657657
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
658658
** [sqlite_version()] and [sqlite_source_id()].
659659
*/
660660
#define SQLITE_VERSION "3.7.12"
661661
#define SQLITE_VERSION_NUMBER 3007012
662
-#define SQLITE_SOURCE_ID "2012-04-17 09:09:33 8e2363ad76446e863d03ead91fd621e59d5cb495"
662
+#define SQLITE_SOURCE_ID "2012-04-24 13:14:49 dfce8569765614462a3952d1761c10d579984665"
663663
664664
/*
665665
** CAPI3REF: Run-Time Library Version Numbers
666666
** KEYWORDS: sqlite3_version, sqlite3_sourceid
667667
**
@@ -78624,10 +78624,12 @@
7862478624
}
7862578625
}
7862678626
return WRC_Continue;
7862778627
}
7862878628
static int analyzeAggregatesInSelect(Walker *pWalker, Select *pSelect){
78629
+ UNUSED_PARAMETER(pWalker);
78630
+ UNUSED_PARAMETER(pSelect);
7862978631
return WRC_Continue;
7863078632
}
7863178633
7863278634
/*
7863378635
** Analyze the given expression looking for aggregate functions and
@@ -104438,19 +104440,23 @@
104438104440
**
104439104441
** 2. All of the columns in the index are either part of the pDistinct
104440104442
** list, or else the WHERE clause contains a term of the form "col=X",
104441104443
** where X is a constant value. The collation sequences of the
104442104444
** 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.
104443104448
*/
104444104449
for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
104445104450
if( pIdx->onError==OE_None ) continue;
104446104451
for(i=0; i<pIdx->nColumn; i++){
104447104452
int iCol = pIdx->aiColumn[i];
104448
- if( 0==findTerm(pWC, iBase, iCol, ~(Bitmask)0, WO_EQ, pIdx)
104449
- && 0>findIndexCol(pParse, pDistinct, iBase, pIdx, i)
104450
- ){
104451
- break;
104453
+ if( 0==findTerm(pWC, iBase, iCol, ~(Bitmask)0, WO_EQ, pIdx) ){
104454
+ int iIdxCol = findIndexCol(pParse, pDistinct, iBase, pIdx, i);
104455
+ if( iIdxCol<0 || pTab->aCol[pIdx->aiColumn[i]].notNull==0 ){
104456
+ break;
104457
+ }
104452104458
}
104453104459
}
104454104460
if( i==pIdx->nColumn ){
104455104461
/* This index implies that the DISTINCT qualifier is redundant. */
104456104462
return 1;
@@ -104594,18 +104600,30 @@
104594104600
** this index can be used for sorting. */
104595104601
return 1;
104596104602
}
104597104603
if( pIdx->onError!=OE_None && i==pIdx->nColumn
104598104604
&& (wsFlags & WHERE_COLUMN_NULL)==0
104599
- && !referencesOtherTables(pOrderBy, pMaskSet, j, base) ){
104600
- /* 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
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. */
104606
- return 1;
104605
+ && !referencesOtherTables(pOrderBy, pMaskSet, j, base)
104606
+ ){
104607
+ Column *aCol = pIdx->pTable->aCol;
104608
+ int i;
104609
+
104610
+ /* All terms of this index match some prefix of the ORDER BY clause,
104611
+ ** the index is UNIQUE, and no terms on the tail of the ORDER BY
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
+ }
104624
+ return (i==pIdx->nColumn);
104607104625
}
104608104626
return 0;
104609104627
}
104610104628
104611104629
/*
104612104630
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -657,11 +657,11 @@
657 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
658 ** [sqlite_version()] and [sqlite_source_id()].
659 */
660 #define SQLITE_VERSION "3.7.12"
661 #define SQLITE_VERSION_NUMBER 3007012
662 #define SQLITE_SOURCE_ID "2012-04-17 09:09:33 8e2363ad76446e863d03ead91fd621e59d5cb495"
663
664 /*
665 ** CAPI3REF: Run-Time Library Version Numbers
666 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
667 **
@@ -78624,10 +78624,12 @@
78624 }
78625 }
78626 return WRC_Continue;
78627 }
78628 static int analyzeAggregatesInSelect(Walker *pWalker, Select *pSelect){
 
 
78629 return WRC_Continue;
78630 }
78631
78632 /*
78633 ** Analyze the given expression looking for aggregate functions and
@@ -104438,19 +104440,23 @@
104438 **
104439 ** 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",
104441 ** where X is a constant value. The collation sequences of the
104442 ** comparison and select-list expressions must match those of the index.
 
 
 
104443 */
104444 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
104445 if( pIdx->onError==OE_None ) continue;
104446 for(i=0; i<pIdx->nColumn; i++){
104447 int iCol = pIdx->aiColumn[i];
104448 if( 0==findTerm(pWC, iBase, iCol, ~(Bitmask)0, WO_EQ, pIdx)
104449 && 0>findIndexCol(pParse, pDistinct, iBase, pIdx, i)
104450 ){
104451 break;
 
104452 }
104453 }
104454 if( i==pIdx->nColumn ){
104455 /* This index implies that the DISTINCT qualifier is redundant. */
104456 return 1;
@@ -104594,18 +104600,30 @@
104594 ** this index can be used for sorting. */
104595 return 1;
104596 }
104597 if( pIdx->onError!=OE_None && i==pIdx->nColumn
104598 && (wsFlags & WHERE_COLUMN_NULL)==0
104599 && !referencesOtherTables(pOrderBy, pMaskSet, j, base) ){
104600 /* 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
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. */
104606 return 1;
 
 
 
 
 
 
 
 
 
 
 
 
104607 }
104608 return 0;
104609 }
104610
104611 /*
104612
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -657,11 +657,11 @@
657 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
658 ** [sqlite_version()] and [sqlite_source_id()].
659 */
660 #define SQLITE_VERSION "3.7.12"
661 #define SQLITE_VERSION_NUMBER 3007012
662 #define SQLITE_SOURCE_ID "2012-04-24 13:14:49 dfce8569765614462a3952d1761c10d579984665"
663
664 /*
665 ** CAPI3REF: Run-Time Library Version Numbers
666 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
667 **
@@ -78624,10 +78624,12 @@
78624 }
78625 }
78626 return WRC_Continue;
78627 }
78628 static int analyzeAggregatesInSelect(Walker *pWalker, Select *pSelect){
78629 UNUSED_PARAMETER(pWalker);
78630 UNUSED_PARAMETER(pSelect);
78631 return WRC_Continue;
78632 }
78633
78634 /*
78635 ** Analyze the given expression looking for aggregate functions and
@@ -104438,19 +104440,23 @@
104440 **
104441 ** 2. All of the columns in the index are either part of the pDistinct
104442 ** list, or else the WHERE clause contains a term of the form "col=X",
104443 ** where X is a constant value. The collation sequences of the
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.
104448 */
104449 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
104450 if( pIdx->onError==OE_None ) continue;
104451 for(i=0; i<pIdx->nColumn; i++){
104452 int iCol = pIdx->aiColumn[i];
104453 if( 0==findTerm(pWC, iBase, iCol, ~(Bitmask)0, WO_EQ, pIdx) ){
104454 int iIdxCol = findIndexCol(pParse, pDistinct, iBase, pIdx, i);
104455 if( iIdxCol<0 || pTab->aCol[pIdx->aiColumn[i]].notNull==0 ){
104456 break;
104457 }
104458 }
104459 }
104460 if( i==pIdx->nColumn ){
104461 /* This index implies that the DISTINCT qualifier is redundant. */
104462 return 1;
@@ -104594,18 +104600,30 @@
104600 ** this index can be used for sorting. */
104601 return 1;
104602 }
104603 if( pIdx->onError!=OE_None && i==pIdx->nColumn
104604 && (wsFlags & WHERE_COLUMN_NULL)==0
104605 && !referencesOtherTables(pOrderBy, pMaskSet, j, base)
104606 ){
104607 Column *aCol = pIdx->pTable->aCol;
104608 int i;
104609
104610 /* All terms of this index match some prefix of the ORDER BY clause,
104611 ** the index is UNIQUE, and no terms on the tail of the ORDER BY
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 }
104624 return (i==pIdx->nColumn);
104625 }
104626 return 0;
104627 }
104628
104629 /*
104630
+1 -1
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107107
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108108
** [sqlite_version()] and [sqlite_source_id()].
109109
*/
110110
#define SQLITE_VERSION "3.7.12"
111111
#define SQLITE_VERSION_NUMBER 3007012
112
-#define SQLITE_SOURCE_ID "2012-04-17 09:09:33 8e2363ad76446e863d03ead91fd621e59d5cb495"
112
+#define SQLITE_SOURCE_ID "2012-04-24 13:14:49 dfce8569765614462a3952d1761c10d579984665"
113113
114114
/*
115115
** CAPI3REF: Run-Time Library Version Numbers
116116
** KEYWORDS: sqlite3_version, sqlite3_sourceid
117117
**
118118
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.7.12"
111 #define SQLITE_VERSION_NUMBER 3007012
112 #define SQLITE_SOURCE_ID "2012-04-17 09:09:33 8e2363ad76446e863d03ead91fd621e59d5cb495"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
118
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.7.12"
111 #define SQLITE_VERSION_NUMBER 3007012
112 #define SQLITE_SOURCE_ID "2012-04-24 13:14:49 dfce8569765614462a3952d1761c10d579984665"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
118

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button