aboutsummaryrefslogtreecommitdiff
path: root/src/select.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2002-06-26 02:45:03 +0000
committerdrh <drh@noemail.net>2002-06-26 02:45:03 +0000
commitb13632063d5cfa89a076f3c4ed3dda62008e9f67 (patch)
treefdef69a1e0657bfddfe51396072849c0baba15fd /src/select.c
parent411995dc0d1611c8aa2a00c48d0c9cf756a34d98 (diff)
downloadsqlite-b13632063d5cfa89a076f3c4ed3dda62008e9f67.tar.gz
sqlite-b13632063d5cfa89a076f3c4ed3dda62008e9f67.zip
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
Diffstat (limited to 'src/select.c')
-rw-r--r--src/select.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/select.c b/src/select.c
index 490ee00d1..0ac9bd3a9 100644
--- a/src/select.c
+++ b/src/select.c
@@ -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);
}
}