mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-15 11:41:13 +03:00
Add support for ORDER BY clauses to schemalint.tcl.
FossilOrigin-Name: 93bdf70e859915ff3696ba0fc68f91ceb2e1a971
This commit is contained in:
19
manifest
19
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Add\sa\shack\sto\sdebug\sout\sa\sdescription\sof\sthe\sWHERE\sclause\sof\sa\sSELECT\s(or\sother)\sstatement.\sUse\sthis\sin\sscript\stool/schemalint.tcl\sto\sautomatically\srecommend\sindexes\sthat\smight\sspeed\sup\sspecific\squeries.
|
C Add\ssupport\sfor\sORDER\sBY\sclauses\sto\sschemalint.tcl.
|
||||||
D 2015-11-11T18:08:58.267
|
D 2015-11-20T20:55:27.428
|
||||||
F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1
|
F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1
|
||||||
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
||||||
F Makefile.msc e928e68168df69b353300ac87c10105206653a03
|
F Makefile.msc e928e68168df69b353300ac87c10105206653a03
|
||||||
@@ -416,7 +416,7 @@ F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb
|
|||||||
F src/wal.c 18b0ed49830cf04fe2d68224b41838a73ac6cd24
|
F src/wal.c 18b0ed49830cf04fe2d68224b41838a73ac6cd24
|
||||||
F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4
|
F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4
|
||||||
F src/walker.c 2e14d17f592d176b6dc879c33fbdec4fbccaa2ba
|
F src/walker.c 2e14d17f592d176b6dc879c33fbdec4fbccaa2ba
|
||||||
F src/where.c 6176426332d5a67df4222adfeae8c22a933f8c84
|
F src/where.c 5804902239731a7025240f4338d98cdc57315636
|
||||||
F src/whereInt.h 7892bb54cf9ca0ae5c7e6094491b94c9286dc647
|
F src/whereInt.h 7892bb54cf9ca0ae5c7e6094491b94c9286dc647
|
||||||
F src/wherecode.c 4c96182e7b25e4be54008dee2da5b9c2f8480b9b
|
F src/wherecode.c 4c96182e7b25e4be54008dee2da5b9c2f8480b9b
|
||||||
F src/whereexpr.c e63244ca06c503e5f3c5b7f3c9aea0db826089ed
|
F src/whereexpr.c e63244ca06c503e5f3c5b7f3c9aea0db826089ed
|
||||||
@@ -972,7 +972,7 @@ F test/schema2.test 906408621ea881fdb496d878b1822572a34e32c5
|
|||||||
F test/schema3.test 1bc1008e1f8cb5654b248c55f27249366eb7ed38
|
F test/schema3.test 1bc1008e1f8cb5654b248c55f27249366eb7ed38
|
||||||
F test/schema4.test e6a66e20cc69f0e306667c08be7fda3d11707dc5
|
F test/schema4.test e6a66e20cc69f0e306667c08be7fda3d11707dc5
|
||||||
F test/schema5.test 29699b4421f183c8f0e88bd28ce7d75d13ea653e
|
F test/schema5.test 29699b4421f183c8f0e88bd28ce7d75d13ea653e
|
||||||
F test/schemalint.test 22f26e6e9d8fe437b6344a97c91fd14c95e813a7
|
F test/schemalint.test 7fba0e262353c8c3dd5ee406cb11cf90f8b566fe
|
||||||
F test/securedel.test 21749c32ccc30f1ea9e4b9f33295a6521ec20fa0
|
F test/securedel.test 21749c32ccc30f1ea9e4b9f33295a6521ec20fa0
|
||||||
F test/securedel2.test 2d54c28e46eb1fd6902089958b20b1b056c6f1c5
|
F test/securedel2.test 2d54c28e46eb1fd6902089958b20b1b056c6f1c5
|
||||||
F test/select1.test be62204d2bd9a5a8a149e9974cfddce893d8f686
|
F test/select1.test be62204d2bd9a5a8a149e9974cfddce893d8f686
|
||||||
@@ -1379,7 +1379,7 @@ F tool/replace.tcl 7727c60a04299b65a92f5e1590896fea0f25b9e0
|
|||||||
F tool/restore_jrnl.tcl 6957a34f8f1f0f8285e07536225ec3b292a9024a
|
F tool/restore_jrnl.tcl 6957a34f8f1f0f8285e07536225ec3b292a9024a
|
||||||
F tool/rollback-test.c 9fc98427d1e23e84429d7e6d07d9094fbdec65a5
|
F tool/rollback-test.c 9fc98427d1e23e84429d7e6d07d9094fbdec65a5
|
||||||
F tool/run-speed-test.sh 0ae485af4fe9f826e2b494be8c81f8ca9e222a4a
|
F tool/run-speed-test.sh 0ae485af4fe9f826e2b494be8c81f8ca9e222a4a
|
||||||
F tool/schemalint.tcl 2eb60e950e91061c27d771582fe87e9518d0988d
|
F tool/schemalint.tcl 160fe2ed74df02e859ab32a522fa1f2e8e0c4230
|
||||||
F tool/showdb.c d4476e000a64eca9f5e2c2f68741e747b9778e8d
|
F tool/showdb.c d4476e000a64eca9f5e2c2f68741e747b9778e8d
|
||||||
F tool/showjournal.c 5bad7ae8784a43d2b270d953060423b8bd480818
|
F tool/showjournal.c 5bad7ae8784a43d2b270d953060423b8bd480818
|
||||||
F tool/showlocks.c 9920bcc64f58378ff1118caead34147201f48c68
|
F tool/showlocks.c 9920bcc64f58378ff1118caead34147201f48c68
|
||||||
@@ -1404,10 +1404,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f
|
|||||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||||
F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
|
F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
|
||||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||||
P 2518d5c971c4b32d9227b3bb7259162e3e27b00b
|
P c6fa01c28ef7ceea2963a92dfffe62eed451b05c
|
||||||
R 9a794d90ebfe5dc636fc86a7e99d61d5
|
R 6fc6a71e3dbe84052a5d99204cd615ee
|
||||||
T *branch * schemalint
|
|
||||||
T *sym-schemalint *
|
|
||||||
T -sym-trunk *
|
|
||||||
U dan
|
U dan
|
||||||
Z 95ad0fe90f5fe7059fb61a18885ffca1
|
Z 64248603e4a564821f72e660b22a8811
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
c6fa01c28ef7ceea2963a92dfffe62eed451b05c
|
93bdf70e859915ff3696ba0fc68f91ceb2e1a971
|
||||||
33
src/where.c
33
src/where.c
@@ -3957,6 +3957,7 @@ static char *whereAppendSingleTerm(
|
|||||||
|
|
||||||
static char *whereTraceWC(
|
static char *whereTraceWC(
|
||||||
Parse *pParse,
|
Parse *pParse,
|
||||||
|
int bInitialSpace,
|
||||||
struct SrcList_item *pItem,
|
struct SrcList_item *pItem,
|
||||||
char *zIn,
|
char *zIn,
|
||||||
WhereClause *pWC
|
WhereClause *pWC
|
||||||
@@ -3966,7 +3967,7 @@ static char *whereTraceWC(
|
|||||||
char *zBuf = zIn;
|
char *zBuf = zIn;
|
||||||
int iCol;
|
int iCol;
|
||||||
int ii;
|
int ii;
|
||||||
int bFirst = 1;
|
int bFirst = !bInitialSpace;
|
||||||
|
|
||||||
/* List of WO_SINGLE constraints */
|
/* List of WO_SINGLE constraints */
|
||||||
for(iCol=0; iCol<pTab->nCol; iCol++){
|
for(iCol=0; iCol<pTab->nCol; iCol++){
|
||||||
@@ -3990,7 +3991,7 @@ static char *whereTraceWC(
|
|||||||
if( pTerm->eOperator & (WO_OR|WO_AND) ){
|
if( pTerm->eOperator & (WO_OR|WO_AND) ){
|
||||||
const char *zFmt = ((pTerm->eOperator&WO_OR) ? "%z%s{or " : "%z%s{");
|
const char *zFmt = ((pTerm->eOperator&WO_OR) ? "%z%s{or " : "%z%s{");
|
||||||
zBuf = whereAppendPrintf(db, zFmt, zBuf, bFirst ? "" : " ");
|
zBuf = whereAppendPrintf(db, zFmt, zBuf, bFirst ? "" : " ");
|
||||||
zBuf = whereTraceWC(pParse, pItem, zBuf, &pTerm->u.pOrInfo->wc);
|
zBuf = whereTraceWC(pParse, 0, pItem, zBuf, &pTerm->u.pOrInfo->wc);
|
||||||
zBuf = whereAppendPrintf(db, "%z}", zBuf);
|
zBuf = whereAppendPrintf(db, "%z}", zBuf);
|
||||||
bFirst = 0;
|
bFirst = 0;
|
||||||
}
|
}
|
||||||
@@ -4005,6 +4006,7 @@ static void whereTraceBuilder(
|
|||||||
){
|
){
|
||||||
sqlite3 *db = pParse->db;
|
sqlite3 *db = pParse->db;
|
||||||
if( db->xTrace ){
|
if( db->xTrace ){
|
||||||
|
ExprList *pOrderBy = p->pOrderBy;
|
||||||
WhereInfo *pWInfo = p->pWInfo;
|
WhereInfo *pWInfo = p->pWInfo;
|
||||||
int nTablist = pWInfo->pTabList->nSrc;
|
int nTablist = pWInfo->pTabList->nSrc;
|
||||||
int ii;
|
int ii;
|
||||||
@@ -4035,10 +4037,33 @@ static void whereTraceBuilder(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
zBuf = whereAppendPrintf(db, "%z} ", zBuf);
|
zBuf = whereAppendPrintf(db, "%z}",zBuf);
|
||||||
|
|
||||||
/* Append the contents of WHERE clause */
|
/* Append the contents of WHERE clause */
|
||||||
zBuf = whereTraceWC(pParse, pItem, zBuf, p->pWC);
|
zBuf = whereTraceWC(pParse, 1, pItem, zBuf, p->pWC);
|
||||||
|
|
||||||
|
/* Append the ORDER BY clause, if any */
|
||||||
|
if( pOrderBy ){
|
||||||
|
int i;
|
||||||
|
int bFirst = 1;
|
||||||
|
for(i=0; i<pOrderBy->nExpr; i++){
|
||||||
|
Expr *pExpr = pOrderBy->a[i].pExpr;
|
||||||
|
CollSeq *pColl = sqlite3ExprCollSeq(pParse, pExpr);
|
||||||
|
|
||||||
|
pExpr = sqlite3ExprSkipCollate(pExpr);
|
||||||
|
if( pExpr->op==TK_COLUMN && pExpr->iTable==pItem->iCursor ){
|
||||||
|
if( pExpr->iColumn>=0 ){
|
||||||
|
const char *zName = pTab->aCol[pExpr->iColumn].zName;
|
||||||
|
zBuf = whereAppendPrintf(db, "%z%s%s %s %s", zBuf,
|
||||||
|
bFirst ? " {orderby " : " ", zName, pColl->zName,
|
||||||
|
(pOrderBy->a[i].sortOrder ? "DESC" : "ASC")
|
||||||
|
);
|
||||||
|
bFirst = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( bFirst==0 ) zBuf = whereAppendPrintf(db, "%z}", zBuf);
|
||||||
|
}
|
||||||
|
|
||||||
/* Pass the buffer to the xTrace() callback, then free it */
|
/* Pass the buffer to the xTrace() callback, then free it */
|
||||||
db->xTrace(db->pTraceArg, zBuf);
|
db->xTrace(db->pTraceArg, zBuf);
|
||||||
|
|||||||
@@ -77,5 +77,24 @@ do_trace_test 2.3 {
|
|||||||
{t1 {cols a b c} {or {{eq c BINARY 0}} {{eq a BINARY 0} {eq b BINARY 0}}}}
|
{t1 {cols a b c} {or {{eq c BINARY 0}} {{eq a BINARY 0} {eq b BINARY 0}}}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
# Cases involving ORDER BY.
|
||||||
|
#
|
||||||
|
do_trace_test 3.1 {
|
||||||
|
SELECT * FROM t1 ORDER BY a;
|
||||||
|
} {{t1 {cols a b c} {orderby a BINARY ASC}}}
|
||||||
|
|
||||||
|
do_trace_test 3.2 {
|
||||||
|
SELECT * FROM t1 WHERE a=? ORDER BY b;
|
||||||
|
} {{t1 {cols a b c} {eq a BINARY 0} {orderby b BINARY ASC}}}
|
||||||
|
|
||||||
|
do_trace_test 3.3 {
|
||||||
|
SELECT min(a) FROM t1;
|
||||||
|
} {{t1 {cols a} {orderby a BINARY ASC}}}
|
||||||
|
|
||||||
|
do_trace_test 3.4 {
|
||||||
|
SELECT max(a) FROM t1;
|
||||||
|
} {{t1 {cols a} {orderby a BINARY DESC}}}
|
||||||
|
|
||||||
finish_test
|
finish_test
|
||||||
|
|
||||||
|
|||||||
@@ -115,6 +115,9 @@ proc expand_eq_list {L} {
|
|||||||
return $ll
|
return $ll
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------------
|
||||||
|
# Formulate a CREATE INDEX statement that creates an index on table $tname.
|
||||||
|
#
|
||||||
proc eqset_to_index {tname eqset {range {}}} {
|
proc eqset_to_index {tname eqset {range {}}} {
|
||||||
global G
|
global G
|
||||||
set lCols [list]
|
set lCols [list]
|
||||||
@@ -167,6 +170,10 @@ proc find_trial_indexes {} {
|
|||||||
set tname [lindex $t 0]
|
set tname [lindex $t 0]
|
||||||
catch { array unset mask }
|
catch { array unset mask }
|
||||||
|
|
||||||
|
if {[lindex $t end 0]=="orderby"} {
|
||||||
|
set orderby [lrange [lindex $t end] 1 end]
|
||||||
|
}
|
||||||
|
|
||||||
foreach lCons [expand_or_cons [lrange $t 2 end]] {
|
foreach lCons [expand_or_cons [lrange $t 2 end]] {
|
||||||
set constraints [list]
|
set constraints [list]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user