mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-14 00:22:38 +03:00
Use #ifdefs to omit unused code in the columnType() routine depending on
compile-time options. FossilOrigin-Name: 3fd5e33217a91402b3499fa0977469b91618a928
This commit is contained in:
12
manifest
12
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Further\srefinement\sof\sthe\sidea\sof\smultiplying\srun-time\scost\sestimates\sby\nthe\sestimated\srow\ssize.
|
C Use\s#ifdefs\sto\somit\sunused\scode\sin\sthe\scolumnType()\sroutine\sdepending\son\ncompile-time\soptions.
|
||||||
D 2013-10-08T18:40:37.532
|
D 2013-10-08T20:01:35.742
|
||||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||||
F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e
|
F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e
|
||||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||||
@@ -216,7 +216,7 @@ F src/printf.c da9119eb31a187a4b99f60aa4a225141c0ebb74b
|
|||||||
F src/random.c 0b2dbc37fdfbfa6bd455b091dfcef5bdb32dba68
|
F src/random.c 0b2dbc37fdfbfa6bd455b091dfcef5bdb32dba68
|
||||||
F src/resolve.c 7459801d02997b07e8b8da85ef255392ba1d022b
|
F src/resolve.c 7459801d02997b07e8b8da85ef255392ba1d022b
|
||||||
F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0
|
F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0
|
||||||
F src/select.c 9d111a1adef56151b4bbddbcaea6d117d374e17d
|
F src/select.c 15127b54cc11defb2cddef6914e1f384501a61c4
|
||||||
F src/shell.c 5ee50ca3e35453bbd6ccdf1bdd0f6bbe9738e9fb
|
F src/shell.c 5ee50ca3e35453bbd6ccdf1bdd0f6bbe9738e9fb
|
||||||
F src/sqlite.h.in ec40aa958a270416fb04b4f72210357bf163d2c5
|
F src/sqlite.h.in ec40aa958a270416fb04b4f72210357bf163d2c5
|
||||||
F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e
|
F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e
|
||||||
@@ -1121,7 +1121,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
|
|||||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||||
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
|
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
|
||||||
F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
|
F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
|
||||||
P cb34cfe57c2a664fbfae8106e95114400ea222d5
|
P 18bd6ba96d19de6047baebfa15b1f739577c9ec4
|
||||||
R 2b7915a92bd0315e781ed0d1390f4f69
|
R 967a79399191741c9ec3babe410d2a81
|
||||||
U drh
|
U drh
|
||||||
Z 27bbb4f4b3fe1d2932c4d2e467493b71
|
Z f2e723eade28ed7288d4d048e8169b82
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
18bd6ba96d19de6047baebfa15b1f739577c9ec4
|
3fd5e33217a91402b3499fa0977469b91618a928
|
||||||
78
src/select.c
78
src/select.c
@@ -1061,6 +1061,9 @@ static void generateSortTail(
|
|||||||
** Return a pointer to a string containing the 'declaration type' of the
|
** Return a pointer to a string containing the 'declaration type' of the
|
||||||
** expression pExpr. The string may be treated as static by the caller.
|
** expression pExpr. The string may be treated as static by the caller.
|
||||||
**
|
**
|
||||||
|
** Also try to estimate the size of the returned value and return that
|
||||||
|
** result in *pEstWidth.
|
||||||
|
**
|
||||||
** The declaration type is the exact datatype definition extracted from the
|
** The declaration type is the exact datatype definition extracted from the
|
||||||
** original CREATE TABLE statement if the expression is a column. The
|
** original CREATE TABLE statement if the expression is a column. The
|
||||||
** declaration type for a ROWID field is INTEGER. Exactly when an expression
|
** declaration type for a ROWID field is INTEGER. Exactly when an expression
|
||||||
@@ -1074,21 +1077,36 @@ static void generateSortTail(
|
|||||||
** SELECT abc FROM (SELECT col AS abc FROM tbl);
|
** SELECT abc FROM (SELECT col AS abc FROM tbl);
|
||||||
**
|
**
|
||||||
** The declaration type for any expression other than a column is NULL.
|
** The declaration type for any expression other than a column is NULL.
|
||||||
|
**
|
||||||
|
** This routine has either 3 or 6 parameters depending on whether or not
|
||||||
|
** the SQLITE_ENABLE_COLUMN_METADATA compile-time option is used.
|
||||||
*/
|
*/
|
||||||
static const char *columnType(
|
#ifdef SQLITE_ENABLE_COLUMN_METADATA
|
||||||
|
# define columnType(A,B,C,D,E,F) columnTypeImpl(A,B,C,D,E,F)
|
||||||
|
static const char *columnTypeImpl(
|
||||||
NameContext *pNC,
|
NameContext *pNC,
|
||||||
Expr *pExpr,
|
Expr *pExpr,
|
||||||
const char **pzOriginDb,
|
const char **pzOrigDb,
|
||||||
const char **pzOriginTab,
|
const char **pzOrigTab,
|
||||||
const char **pzOriginCol
|
const char **pzOrigCol,
|
||||||
|
u8 *pEstWidth
|
||||||
){
|
){
|
||||||
|
char const *zOrigDb = 0;
|
||||||
|
char const *zOrigTab = 0;
|
||||||
|
char const *zOrigCol = 0;
|
||||||
|
#else /* if !defined(SQLITE_ENABLE_COLUMN_METADATA) */
|
||||||
|
# define columnType(A,B,C,D,E,F) columnTypeImpl(A,B,F)
|
||||||
|
static const char *columnTypeImpl(
|
||||||
|
NameContext *pNC,
|
||||||
|
Expr *pExpr,
|
||||||
|
u8 *pEstWidth
|
||||||
|
){
|
||||||
|
#endif /* !defined(SQLITE_ENABLE_COLUMN_METADATA) */
|
||||||
char const *zType = 0;
|
char const *zType = 0;
|
||||||
char const *zOriginDb = 0;
|
|
||||||
char const *zOriginTab = 0;
|
|
||||||
char const *zOriginCol = 0;
|
|
||||||
int j;
|
int j;
|
||||||
if( NEVER(pExpr==0) || pNC->pSrcList==0 ) return 0;
|
u8 estWidth = 1;
|
||||||
|
|
||||||
|
if( NEVER(pExpr==0) || pNC->pSrcList==0 ) return 0;
|
||||||
switch( pExpr->op ){
|
switch( pExpr->op ){
|
||||||
case TK_AGG_COLUMN:
|
case TK_AGG_COLUMN:
|
||||||
case TK_COLUMN: {
|
case TK_COLUMN: {
|
||||||
@@ -1149,25 +1167,35 @@ static const char *columnType(
|
|||||||
sNC.pSrcList = pS->pSrc;
|
sNC.pSrcList = pS->pSrc;
|
||||||
sNC.pNext = pNC;
|
sNC.pNext = pNC;
|
||||||
sNC.pParse = pNC->pParse;
|
sNC.pParse = pNC->pParse;
|
||||||
zType = columnType(&sNC, p, &zOriginDb, &zOriginTab, &zOriginCol);
|
zType = columnType(&sNC, p,&zOrigDb,&zOrigTab,&zOrigCol, &estWidth);
|
||||||
}
|
}
|
||||||
}else if( ALWAYS(pTab->pSchema) ){
|
}else if( ALWAYS(pTab->pSchema) ){
|
||||||
/* A real table */
|
/* A real table */
|
||||||
assert( !pS );
|
assert( !pS );
|
||||||
if( iCol<0 ) iCol = pTab->iPKey;
|
if( iCol<0 ) iCol = pTab->iPKey;
|
||||||
assert( iCol==-1 || (iCol>=0 && iCol<pTab->nCol) );
|
assert( iCol==-1 || (iCol>=0 && iCol<pTab->nCol) );
|
||||||
|
#ifdef SQLITE_ENABLE_COLUMN_METADATA
|
||||||
if( iCol<0 ){
|
if( iCol<0 ){
|
||||||
zType = "INTEGER";
|
zType = "INTEGER";
|
||||||
zOriginCol = "rowid";
|
zOrigCol = "rowid";
|
||||||
}else{
|
}else{
|
||||||
zType = pTab->aCol[iCol].zType;
|
zType = pTab->aCol[iCol].zType;
|
||||||
zOriginCol = pTab->aCol[iCol].zName;
|
zOrigCol = pTab->aCol[iCol].zName;
|
||||||
|
estWidth = pTab->aCol[iCol].szEst;
|
||||||
}
|
}
|
||||||
zOriginTab = pTab->zName;
|
zOrigTab = pTab->zName;
|
||||||
if( pNC->pParse ){
|
if( pNC->pParse ){
|
||||||
int iDb = sqlite3SchemaToIndex(pNC->pParse->db, pTab->pSchema);
|
int iDb = sqlite3SchemaToIndex(pNC->pParse->db, pTab->pSchema);
|
||||||
zOriginDb = pNC->pParse->db->aDb[iDb].zName;
|
zOrigDb = pNC->pParse->db->aDb[iDb].zName;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
if( iCol<0 ){
|
||||||
|
zType = "INTEGER";
|
||||||
|
}else{
|
||||||
|
zType = pTab->aCol[iCol].zType;
|
||||||
|
estWidth = pTab->aCol[iCol].szEst;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1184,18 +1212,21 @@ static const char *columnType(
|
|||||||
sNC.pSrcList = pS->pSrc;
|
sNC.pSrcList = pS->pSrc;
|
||||||
sNC.pNext = pNC;
|
sNC.pNext = pNC;
|
||||||
sNC.pParse = pNC->pParse;
|
sNC.pParse = pNC->pParse;
|
||||||
zType = columnType(&sNC, p, &zOriginDb, &zOriginTab, &zOriginCol);
|
zType = columnType(&sNC, p, &zOrigDb, &zOrigTab, &zOrigCol, &estWidth);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if( pzOriginDb ){
|
#ifdef SQLITE_ENABLE_COLUMN_METADATA
|
||||||
assert( pzOriginTab && pzOriginCol );
|
if( pzOrigDb ){
|
||||||
*pzOriginDb = zOriginDb;
|
assert( pzOrigTab && pzOrigCol );
|
||||||
*pzOriginTab = zOriginTab;
|
*pzOrigDb = zOrigDb;
|
||||||
*pzOriginCol = zOriginCol;
|
*pzOrigTab = zOrigTab;
|
||||||
|
*pzOrigCol = zOrigCol;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
if( pEstWidth ) *pEstWidth = estWidth;
|
||||||
return zType;
|
return zType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1221,7 +1252,7 @@ static void generateColumnTypes(
|
|||||||
const char *zOrigDb = 0;
|
const char *zOrigDb = 0;
|
||||||
const char *zOrigTab = 0;
|
const char *zOrigTab = 0;
|
||||||
const char *zOrigCol = 0;
|
const char *zOrigCol = 0;
|
||||||
zType = columnType(&sNC, p, &zOrigDb, &zOrigTab, &zOrigCol);
|
zType = columnType(&sNC, p, &zOrigDb, &zOrigTab, &zOrigCol, 0);
|
||||||
|
|
||||||
/* The vdbe must make its own copy of the column-type and other
|
/* The vdbe must make its own copy of the column-type and other
|
||||||
** column specific strings, in case the schema is reset before this
|
** column specific strings, in case the schema is reset before this
|
||||||
@@ -1231,11 +1262,11 @@ static void generateColumnTypes(
|
|||||||
sqlite3VdbeSetColName(v, i, COLNAME_TABLE, zOrigTab, SQLITE_TRANSIENT);
|
sqlite3VdbeSetColName(v, i, COLNAME_TABLE, zOrigTab, SQLITE_TRANSIENT);
|
||||||
sqlite3VdbeSetColName(v, i, COLNAME_COLUMN, zOrigCol, SQLITE_TRANSIENT);
|
sqlite3VdbeSetColName(v, i, COLNAME_COLUMN, zOrigCol, SQLITE_TRANSIENT);
|
||||||
#else
|
#else
|
||||||
zType = columnType(&sNC, p, 0, 0, 0);
|
zType = columnType(&sNC, p, 0, 0, 0, 0);
|
||||||
#endif
|
#endif
|
||||||
sqlite3VdbeSetColName(v, i, COLNAME_DECLTYPE, zType, SQLITE_TRANSIENT);
|
sqlite3VdbeSetColName(v, i, COLNAME_DECLTYPE, zType, SQLITE_TRANSIENT);
|
||||||
}
|
}
|
||||||
#endif /* SQLITE_OMIT_DECLTYPE */
|
#endif /* !defined(SQLITE_OMIT_DECLTYPE) */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1445,8 +1476,7 @@ static void selectAddColumnTypeAndCollation(
|
|||||||
a = pSelect->pEList->a;
|
a = pSelect->pEList->a;
|
||||||
for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){
|
for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){
|
||||||
p = a[i].pExpr;
|
p = a[i].pExpr;
|
||||||
pCol->zType = sqlite3DbStrDup(db, columnType(&sNC, p, 0, 0, 0));
|
pCol->zType = sqlite3DbStrDup(db, columnType(&sNC, p,0,0,0, &pCol->szEst));
|
||||||
sqlite3AffinityType(pCol->zType, &pCol->szEst);
|
|
||||||
szAll += pCol->szEst;
|
szAll += pCol->szEst;
|
||||||
pCol->affinity = sqlite3ExprAffinity(p);
|
pCol->affinity = sqlite3ExprAffinity(p);
|
||||||
if( pCol->affinity==0 ) pCol->affinity = SQLITE_AFF_NONE;
|
if( pCol->affinity==0 ) pCol->affinity = SQLITE_AFF_NONE;
|
||||||
|
|||||||
Reference in New Issue
Block a user