The datatype of the i-th column in the result set is given by the

azColName(argc+1+i) parameter to the callback. (CVS 647)

FossilOrigin-Name: bdb006b809feb0f29342eb5138c0884d34e95599
This commit is contained in:
drh 2002-06-26 02:45:03 +00:00
parent 411995dc0d
commit b13632063d
5 changed files with 47 additions and 15 deletions

View File

@ -1,5 +1,5 @@
C Add\sthe\ssqlite_open_aux_file()\sAPI.\s(CVS\s646)
D 2002-06-25T19:31:18
C The\sdatatype\sof\sthe\si-th\scolumn\sin\sthe\sresult\sset\sis\sgiven\sby\sthe\nazColName(argc+1+i)\sparameter\sto\sthe\scallback.\s(CVS\s647)
D 2002-06-26T02:45:04
F Makefile.in 6291a33b87d2a395aafd7646ee1ed562c6f2c28c
F Makefile.template 4e11752e0b5c7a043ca50af4296ec562857ba495
F README a4c0ba11354ef6ba0776b400d057c59da47a4cc0
@ -23,7 +23,7 @@ F src/btree.h 8abeabfe6e0b1a990b64fa457592a6482f6674f3
F src/build.c c288c2428ad34542d6357619f4c30d0a761fe55f
F src/delete.c 44c45460b1e03033756e35adc6d569ffbf30b725
F src/encode.c 346b12b46148506c32038524b95c4631ab46d760
F src/expr.c cb50a72c491954d58be2f182366e45a1e252bf2e
F src/expr.c d49737db0c5b171b0a13204bcc09d1c9bc7daead
F src/func.c 5eae8227a8b0d276a64d51a3880a6e86f238fedf
F src/hash.c 6a6236b89c8c060c65dabd300a1c8ce7c10edb72
F src/hash.h cd0433998bc1a3759d244e1637fe5a3c13b53bf8
@ -37,7 +37,7 @@ F src/pager.h 6fddfddd3b73aa8abc081b973886320e3c614f0e
F src/parse.y c75ea2580de675bcb80ff8b7c10c0a15e02a21ab
F src/printf.c 236ed7a79386feed4456fa728fff8be793f1547c
F src/random.c 19e8e00fe0df32a742f115773f57651be327cabe
F src/select.c f7d74f20f5ecc335fbccba367eda727b9d6fb299
F src/select.c 92ffd8b5ef96c801f469b658a13bcaa22b1bac13
F src/shell.c 0b06e4421ddf34f30263a2674abe768a2b5fd538
F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e
F src/sqlite.h.in 75c5bbb066d0faf34424b7d1babf8b44d5b31af2
@ -52,7 +52,7 @@ F src/tokenize.c ac4c46f190346b87da54ec3e2605d160af80c619
F src/trigger.c d88ab4d68d68955c217b38fb6717e090fbbf54a4
F src/update.c 6f6a4dcd71cd9ff730b7f12c83de5498cde4924f
F src/util.c 876b259f9186e84b944b72e793dd3dad50e63e95
F src/vdbe.c 17cdbcb692da2fbfcbb536a44b9fef88a92f5656
F src/vdbe.c 2d9e418e45b75ac361e8e3ba96d84ce0a1ff9139
F src/vdbe.h a9292f2b5fcecef924fa255fb74609e9cbc776c2
F src/where.c 913fa33977c8dddfc259d9b2c38504b475738c43
F test/all.test e4d3821eeba751829b419cd47814bd20af4286d1
@ -137,7 +137,7 @@ F www/speed.tcl da8afcc1d3ccc5696cfb388a68982bc3d9f7f00f
F www/sqlite.tcl ac64065d0c5e2de0f71238d55b2c14bb5c5c194c
F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
P d5cb675432cbaeac2c1a8a08181613b9d1eb5ca1
R 23f9cfbf0d6380c4cbde26b796391b19
P 332164d6455658ca633a1dc49811d9fb0fd4b01c
R 3d4733b97443e83d7b5e9cd5d5bb7f60
U drh
Z f72865dbf4a454e4ffbff1c2543dcab0
Z 6ddcef67963fec9e5770a42b675dc0e1

View File

@ -1 +1 @@
332164d6455658ca633a1dc49811d9fb0fd4b01c
bdb006b809feb0f29342eb5138c0884d34e95599

View File

@ -12,7 +12,7 @@
** This file contains routines used for analyzing expressions and
** for generating VDBE code that evaluates expressions in SQLite.
**
** $Id: expr.c,v 1.73 2002/06/20 11:36:49 drh Exp $
** $Id: expr.c,v 1.74 2002/06/26 02:45:04 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@ -889,6 +889,22 @@ int sqliteExprType(Expr *p){
p = p->pSelect->pEList->a[0].pExpr;
break;
case TK_CASE: {
if( p->pRight && sqliteExprType(p->pRight)==SQLITE_SO_NUM ){
return SQLITE_SO_NUM;
}
if( p->pList ){
int i;
ExprList *pList = p->pList;
for(i=1; i<pList->nExpr; i+=2){
if( sqliteExprType(pList->a[i].pExpr)==SQLITE_SO_NUM ){
return SQLITE_SO_NUM;
}
}
}
return SQLITE_SO_TEXT;
}
default:
assert( p->op==TK_ABORT ); /* Can't Happen */
break;

View File

@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite.
**
** $Id: select.c,v 1.99 2002/06/24 22:01:58 drh Exp $
** $Id: select.c,v 1.100 2002/06/26 02:45:04 drh Exp $
*/
#include "sqliteInt.h"
@ -562,9 +562,10 @@ static void generateColumnNames(
int i;
if( pParse->colNamesSet || v==0 || sqlite_malloc_failed ) return;
pParse->colNamesSet = 1;
sqliteVdbeAddOp(v, OP_ColumnCount, pEList->nExpr, 0);
sqliteVdbeAddOp(v, OP_ColumnCount, pEList->nExpr*2+1, 0);
for(i=0; i<pEList->nExpr; i++){
Expr *p;
char *zType = 0;
int showFullNames;
if( pEList->a[i].zName ){
char *zName = pEList->a[i].zName;
@ -585,7 +586,13 @@ static void generateColumnNames(
int iCol = p->iColumn;
if( iCol<0 ) iCol = pTab->iPKey;
assert( iCol==-1 || (iCol>=0 && iCol<pTab->nCol) );
zCol = iCol<0 ? "_ROWID_" : pTab->aCol[iCol].zName;
if( iCol<0 ){
zCol = "_ROWID_";
zType = "INTEGER";
}else{
zCol = pTab->aCol[iCol].zName;
zType = pTab->aCol[iCol].zType;
}
if( pTabList->nSrc>1 || showFullNames ){
char *zName = 0;
char *zTab;
@ -611,6 +618,15 @@ static void generateColumnNames(
sqliteVdbeAddOp(v, OP_ColumnName, i, 0);
sqliteVdbeChangeP3(v, -1, zName, strlen(zName));
}
if( zType==0 ){
if( sqliteExprType(p)==SQLITE_SO_TEXT ){
zType = "TEXT";
}else{
zType = "NUMERIC";
}
}
sqliteVdbeAddOp(v, OP_ColumnName, i + pEList->nExpr + 1, 0);
sqliteVdbeChangeP3(v, -1, zType, P3_STATIC);
}
}

View File

@ -30,7 +30,7 @@
** But other routines are also provided to help in building up
** a program instruction by instruction.
**
** $Id: vdbe.c,v 1.160 2002/06/25 13:16:04 drh Exp $
** $Id: vdbe.c,v 1.161 2002/06/26 02:45:04 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@ -1578,7 +1578,7 @@ case OP_ColumnCount: {
** a coredump.
*/
case OP_ColumnName: {
p->azColName[pOp->p1] = pOp->p3 ? pOp->p3 : "";
p->azColName[pOp->p1] = pOp->p3;
p->nCallback = 0;
break;
}