mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-08 03:22:21 +03:00
General code cleanup resulting in smaller footprint. (CVS 2595)
FossilOrigin-Name: 98338abf9e8cfbf8efa81cff0e40ea37e34fd9b2
This commit is contained in:
14
manifest
14
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Split\sthe\ssqlite3_complete()\sAPI\sout\sinto\sa\sseparate\ssource\sfile\sso\sthat\nin\sstatic\slinks\swhere\sit\sis\snot\sused\sit\swill\snot\stake\sup\sspace\sin\sthe\nresulting\sbinary.\s(CVS\s2594)
|
C General\scode\scleanup\sresulting\sin\ssmaller\sfootprint.\s(CVS\s2595)
|
||||||
D 2005-08-14T17:53:21
|
D 2005-08-14T20:47:16
|
||||||
F Makefile.in b109ddb46a5550d0732dcd6caca01c123f6d5cdd
|
F Makefile.in b109ddb46a5550d0732dcd6caca01c123f6d5cdd
|
||||||
F Makefile.linux-gcc 06be33b2a9ad4f005a5f42b22c4a19dab3cbb5c7
|
F Makefile.linux-gcc 06be33b2a9ad4f005a5f42b22c4a19dab3cbb5c7
|
||||||
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
||||||
@@ -40,7 +40,7 @@ F src/complete.c 4de937dfdd4c79a501772ab2035b26082f337a79
|
|||||||
F src/date.c 7444b0900a28da77e57e3337a636873cff0ae940
|
F src/date.c 7444b0900a28da77e57e3337a636873cff0ae940
|
||||||
F src/delete.c be1fc25c9e109cd8cbab42a43ee696263da7c04b
|
F src/delete.c be1fc25c9e109cd8cbab42a43ee696263da7c04b
|
||||||
F src/experimental.c 50c1e3b34f752f4ac10c36f287db095c2b61766d
|
F src/experimental.c 50c1e3b34f752f4ac10c36f287db095c2b61766d
|
||||||
F src/expr.c cad7f9197587db4897192cf21a8629b3b102c682
|
F src/expr.c 24eda6c0502250f3a4259be94d6962f87cd47d87
|
||||||
F src/func.c 5b12db87f0bc7d978eaf87c7a348ada5d1934da4
|
F src/func.c 5b12db87f0bc7d978eaf87c7a348ada5d1934da4
|
||||||
F src/hash.c 2b1b13f7400e179631c83a1be0c664608c8f021f
|
F src/hash.c 2b1b13f7400e179631c83a1be0c664608c8f021f
|
||||||
F src/hash.h 1b0c445e1c89ff2aaad9b4605ba61375af001e84
|
F src/hash.h 1b0c445e1c89ff2aaad9b4605ba61375af001e84
|
||||||
@@ -63,7 +63,7 @@ F src/pragma.c 69413fbdc0c6aaa493a776ea52c1b3e6cf35dfb2
|
|||||||
F src/prepare.c fa0f6068d9b8ec6d5c419c65d4d8ff747d49c5c6
|
F src/prepare.c fa0f6068d9b8ec6d5c419c65d4d8ff747d49c5c6
|
||||||
F src/printf.c 772b15c3395fa60bdbf3aaa03d480ecde38bf192
|
F src/printf.c 772b15c3395fa60bdbf3aaa03d480ecde38bf192
|
||||||
F src/random.c 90adff4e73a3b249eb4f1fc2a6ff9cf78c7233a4
|
F src/random.c 90adff4e73a3b249eb4f1fc2a6ff9cf78c7233a4
|
||||||
F src/select.c c611471052773b94af771693686bd5bcdbbb0dba
|
F src/select.c f441648eb191dcf1e67ae61475ea3b40a0eeb787
|
||||||
F src/shell.c 86c16f0d534aa51cc82cf9f66903d4eb681580e7
|
F src/shell.c 86c16f0d534aa51cc82cf9f66903d4eb681580e7
|
||||||
F src/sqlite.h.in a3b75a6b2e66865fba4ec1b698d00c7d95fe27a2
|
F src/sqlite.h.in a3b75a6b2e66865fba4ec1b698d00c7d95fe27a2
|
||||||
F src/sqliteInt.h 40370b51b902b4789ca6d4a016d00fa981803661
|
F src/sqliteInt.h 40370b51b902b4789ca6d4a016d00fa981803661
|
||||||
@@ -293,7 +293,7 @@ F www/tclsqlite.tcl 3df553505b6efcad08f91e9b975deb2e6c9bb955
|
|||||||
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
||||||
F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
|
F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
|
||||||
F www/whentouse.tcl 528299b8316726dbcc5548e9aa0648c8b1bd055b
|
F www/whentouse.tcl 528299b8316726dbcc5548e9aa0648c8b1bd055b
|
||||||
P 94efd7908880c7d99c08ebc9a3437cfbefc42f7e
|
P 62b87751dea56c565bcc2aca88a2edda7dfc2a57
|
||||||
R aba4d0123b815fe8fae7c07e56c29e43
|
R 8a2d641a343930304c476f8e7d5941a6
|
||||||
U drh
|
U drh
|
||||||
Z a0b138cf78bbb402904383cc3a8c7ee1
|
Z 4e9e4effacefcf4b222166a8ff8d216c
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
62b87751dea56c565bcc2aca88a2edda7dfc2a57
|
98338abf9e8cfbf8efa81cff0e40ea37e34fd9b2
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
** This file contains routines used for analyzing expressions and
|
** This file contains routines used for analyzing expressions and
|
||||||
** for generating VDBE code that evaluates expressions in SQLite.
|
** for generating VDBE code that evaluates expressions in SQLite.
|
||||||
**
|
**
|
||||||
** $Id: expr.c,v 1.216 2005/08/12 22:58:53 drh Exp $
|
** $Id: expr.c,v 1.217 2005/08/14 20:47:16 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@@ -1789,11 +1789,9 @@ int sqlite3ExprCodeExprList(
|
|||||||
){
|
){
|
||||||
struct ExprList_item *pItem;
|
struct ExprList_item *pItem;
|
||||||
int i, n;
|
int i, n;
|
||||||
Vdbe *v;
|
|
||||||
if( pList==0 ) return 0;
|
if( pList==0 ) return 0;
|
||||||
v = sqlite3GetVdbe(pParse);
|
|
||||||
n = pList->nExpr;
|
n = pList->nExpr;
|
||||||
for(pItem=pList->a, i=0; i<n; i++, pItem++){
|
for(pItem=pList->a, i=n; i>0; i--, pItem++){
|
||||||
sqlite3ExprCode(pParse, pItem->pExpr);
|
sqlite3ExprCode(pParse, pItem->pExpr);
|
||||||
}
|
}
|
||||||
return n;
|
return n;
|
||||||
|
|||||||
67
src/select.c
67
src/select.c
@@ -12,7 +12,7 @@
|
|||||||
** This file contains C code routines that are called by the parser
|
** This file contains C code routines that are called by the parser
|
||||||
** to handle SELECT statements in SQLite.
|
** to handle SELECT statements in SQLite.
|
||||||
**
|
**
|
||||||
** $Id: select.c,v 1.253 2005/07/08 17:13:47 drh Exp $
|
** $Id: select.c,v 1.254 2005/08/14 20:47:16 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ int sqlite3JoinType(Parse *pParse, Token *pA, Token *pB, Token *pC){
|
|||||||
Token *apAll[3];
|
Token *apAll[3];
|
||||||
Token *p;
|
Token *p;
|
||||||
static const struct {
|
static const struct {
|
||||||
const char *zKeyword;
|
const char zKeyword[8];
|
||||||
u8 nChar;
|
u8 nChar;
|
||||||
u8 code;
|
u8 code;
|
||||||
} keywords[] = {
|
} keywords[] = {
|
||||||
@@ -155,6 +155,15 @@ static void setToken(Token *p, const char *z){
|
|||||||
p->dyn = 0;
|
p->dyn = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Create an expression node for an identifier with the name of zName
|
||||||
|
*/
|
||||||
|
static Expr *createIdExpr(const char *zName){
|
||||||
|
Token dummy;
|
||||||
|
setToken(&dummy, zName);
|
||||||
|
return sqlite3Expr(TK_ID, 0, 0, &dummy);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Add a term to the WHERE expression in *ppExpr that requires the
|
** Add a term to the WHERE expression in *ppExpr that requires the
|
||||||
@@ -168,24 +177,20 @@ static void addWhereTerm(
|
|||||||
const char *zAlias2, /* Alias for second table. May be NULL */
|
const char *zAlias2, /* Alias for second table. May be NULL */
|
||||||
Expr **ppExpr /* Add the equality term to this expression */
|
Expr **ppExpr /* Add the equality term to this expression */
|
||||||
){
|
){
|
||||||
Token dummy;
|
|
||||||
Expr *pE1a, *pE1b, *pE1c;
|
Expr *pE1a, *pE1b, *pE1c;
|
||||||
Expr *pE2a, *pE2b, *pE2c;
|
Expr *pE2a, *pE2b, *pE2c;
|
||||||
Expr *pE;
|
Expr *pE;
|
||||||
|
|
||||||
setToken(&dummy, zCol);
|
pE1a = createIdExpr(zCol);
|
||||||
pE1a = sqlite3Expr(TK_ID, 0, 0, &dummy);
|
pE2a = createIdExpr(zCol);
|
||||||
pE2a = sqlite3Expr(TK_ID, 0, 0, &dummy);
|
|
||||||
if( zAlias1==0 ){
|
if( zAlias1==0 ){
|
||||||
zAlias1 = pTab1->zName;
|
zAlias1 = pTab1->zName;
|
||||||
}
|
}
|
||||||
setToken(&dummy, zAlias1);
|
pE1b = createIdExpr(zAlias1);
|
||||||
pE1b = sqlite3Expr(TK_ID, 0, 0, &dummy);
|
|
||||||
if( zAlias2==0 ){
|
if( zAlias2==0 ){
|
||||||
zAlias2 = pTab2->zName;
|
zAlias2 = pTab2->zName;
|
||||||
}
|
}
|
||||||
setToken(&dummy, zAlias2);
|
pE2b = createIdExpr(zAlias2);
|
||||||
pE2b = sqlite3Expr(TK_ID, 0, 0, &dummy);
|
|
||||||
pE1c = sqlite3Expr(TK_DOT, pE1b, pE1a, 0);
|
pE1c = sqlite3Expr(TK_DOT, pE1b, pE1a, 0);
|
||||||
pE2c = sqlite3Expr(TK_DOT, pE2b, pE2a, 0);
|
pE2c = sqlite3Expr(TK_DOT, pE2b, pE2a, 0);
|
||||||
pE = sqlite3Expr(TK_EQ, pE1c, pE2c, 0);
|
pE = sqlite3Expr(TK_EQ, pE1c, pE2c, 0);
|
||||||
@@ -321,10 +326,7 @@ void sqlite3SelectDelete(Select *p){
|
|||||||
** stack into the sorter.
|
** stack into the sorter.
|
||||||
*/
|
*/
|
||||||
static void pushOntoSorter(Parse *pParse, Vdbe *v, ExprList *pOrderBy){
|
static void pushOntoSorter(Parse *pParse, Vdbe *v, ExprList *pOrderBy){
|
||||||
int i;
|
sqlite3ExprCodeExprList(pParse, pOrderBy);
|
||||||
for(i=0; i<pOrderBy->nExpr; i++){
|
|
||||||
sqlite3ExprCode(pParse, pOrderBy->a[i].pExpr);
|
|
||||||
}
|
|
||||||
sqlite3VdbeAddOp(v, OP_MakeRecord, pOrderBy->nExpr, 0);
|
sqlite3VdbeAddOp(v, OP_MakeRecord, pOrderBy->nExpr, 0);
|
||||||
sqlite3VdbeAddOp(v, OP_SortInsert, 0, 0);
|
sqlite3VdbeAddOp(v, OP_SortInsert, 0, 0);
|
||||||
}
|
}
|
||||||
@@ -402,9 +404,7 @@ static int selectInnerLoop(
|
|||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
nColumn = pEList->nExpr;
|
nColumn = pEList->nExpr;
|
||||||
for(i=0; i<pEList->nExpr; i++){
|
sqlite3ExprCodeExprList(pParse, pEList);
|
||||||
sqlite3ExprCode(pParse, pEList->a[i].pExpr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the DISTINCT keyword was present on the SELECT statement
|
/* If the DISTINCT keyword was present on the SELECT statement
|
||||||
@@ -412,14 +412,15 @@ static int selectInnerLoop(
|
|||||||
** part of the result.
|
** part of the result.
|
||||||
*/
|
*/
|
||||||
if( hasDistinct ){
|
if( hasDistinct ){
|
||||||
|
int n = pEList->nExpr;
|
||||||
#if NULL_ALWAYS_DISTINCT
|
#if NULL_ALWAYS_DISTINCT
|
||||||
sqlite3VdbeAddOp(v, OP_IsNull, -pEList->nExpr, sqlite3VdbeCurrentAddr(v)+7);
|
sqlite3VdbeAddOp(v, OP_IsNull, -pEList->nExpr, sqlite3VdbeCurrentAddr(v)+7);
|
||||||
#endif
|
#endif
|
||||||
/* Deliberately leave the affinity string off of the following
|
/* Deliberately leave the affinity string off of the following
|
||||||
** OP_MakeRecord */
|
** OP_MakeRecord */
|
||||||
sqlite3VdbeAddOp(v, OP_MakeRecord, pEList->nExpr * -1, 0);
|
sqlite3VdbeAddOp(v, OP_MakeRecord, -n, 0);
|
||||||
sqlite3VdbeAddOp(v, OP_Distinct, distinct, sqlite3VdbeCurrentAddr(v)+3);
|
sqlite3VdbeAddOp(v, OP_Distinct, distinct, sqlite3VdbeCurrentAddr(v)+3);
|
||||||
sqlite3VdbeAddOp(v, OP_Pop, pEList->nExpr+1, 0);
|
sqlite3VdbeAddOp(v, OP_Pop, n+1, 0);
|
||||||
sqlite3VdbeAddOp(v, OP_Goto, 0, iContinue);
|
sqlite3VdbeAddOp(v, OP_Goto, 0, iContinue);
|
||||||
VdbeComment((v, "# skip indistinct records"));
|
VdbeComment((v, "# skip indistinct records"));
|
||||||
sqlite3VdbeAddOp(v, OP_IdxInsert, distinct, 0);
|
sqlite3VdbeAddOp(v, OP_IdxInsert, distinct, 0);
|
||||||
@@ -511,29 +512,21 @@ static int selectInnerLoop(
|
|||||||
}
|
}
|
||||||
#endif /* #ifndef SQLITE_OMIT_SUBQUERY */
|
#endif /* #ifndef SQLITE_OMIT_SUBQUERY */
|
||||||
|
|
||||||
/* Send the data to the callback function.
|
/* Send the data to the callback function or to a subroutine. In the
|
||||||
|
** case of a subroutine, the subroutine itself is responsible for
|
||||||
|
** popping the data from the stack.
|
||||||
*/
|
*/
|
||||||
|
case SRT_Subroutine:
|
||||||
case SRT_Callback:
|
case SRT_Callback:
|
||||||
case SRT_Sorter: {
|
case SRT_Sorter: {
|
||||||
if( pOrderBy ){
|
if( pOrderBy ){
|
||||||
sqlite3VdbeAddOp(v, OP_MakeRecord, nColumn, 0);
|
sqlite3VdbeAddOp(v, OP_MakeRecord, nColumn, 0);
|
||||||
pushOntoSorter(pParse, v, pOrderBy);
|
pushOntoSorter(pParse, v, pOrderBy);
|
||||||
}else{
|
}else if( eDest==SRT_Subroutine ){
|
||||||
assert( eDest==SRT_Callback );
|
|
||||||
sqlite3VdbeAddOp(v, OP_Callback, nColumn, 0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Invoke a subroutine to handle the results. The subroutine itself
|
|
||||||
** is responsible for popping the results off of the stack.
|
|
||||||
*/
|
|
||||||
case SRT_Subroutine: {
|
|
||||||
if( pOrderBy ){
|
|
||||||
sqlite3VdbeAddOp(v, OP_MakeRecord, nColumn, 0);
|
|
||||||
pushOntoSorter(pParse, v, pOrderBy);
|
|
||||||
}else{
|
|
||||||
sqlite3VdbeAddOp(v, OP_Gosub, 0, iParm);
|
sqlite3VdbeAddOp(v, OP_Gosub, 0, iParm);
|
||||||
|
}else{
|
||||||
|
assert( eDest!=SRT_Sorter );
|
||||||
|
sqlite3VdbeAddOp(v, OP_Callback, nColumn, 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -2766,9 +2759,7 @@ int sqlite3Select(
|
|||||||
int lbl1 = 0;
|
int lbl1 = 0;
|
||||||
pParse->fillAgg = 1;
|
pParse->fillAgg = 1;
|
||||||
if( pGroupBy ){
|
if( pGroupBy ){
|
||||||
for(i=0; i<pGroupBy->nExpr; i++){
|
sqlite3ExprCodeExprList(pParse, pGroupBy);
|
||||||
sqlite3ExprCode(pParse, pGroupBy->a[i].pExpr);
|
|
||||||
}
|
|
||||||
/* No affinity string is attached to the following OP_MakeRecord
|
/* No affinity string is attached to the following OP_MakeRecord
|
||||||
** because we do not need to do any coercion of datatypes. */
|
** because we do not need to do any coercion of datatypes. */
|
||||||
sqlite3VdbeAddOp(v, OP_MakeRecord, pGroupBy->nExpr, 0);
|
sqlite3VdbeAddOp(v, OP_MakeRecord, pGroupBy->nExpr, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user