1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-14 00:22:38 +03:00

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

@@ -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);
}
}