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

Document the SHOW_DATATYPES pragma and add tests for it to the test suite.

Make sure datatypes are show even for aliased columns.
Tickets #220 and #221. (CVS 822)

FossilOrigin-Name: e84d3afe7b9153d003fdcca98221f446c004ffa2
This commit is contained in:
drh
2003-01-11 14:19:51 +00:00
parent 836faa4843
commit 5a38705ecb
7 changed files with 160 additions and 44 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.118 2003/01/11 13:30:58 drh Exp $
** $Id: select.c,v 1.119 2003/01/11 14:19:52 drh Exp $
*/
#include "sqliteInt.h"
@@ -689,25 +689,29 @@ static void generateColumnNames(
int i;
if( pParse->colNamesSet || v==0 || sqlite_malloc_failed ) return;
pParse->colNamesSet = 1;
#if 0
if( pParse->db->flags & SQLITE_ReportTypes ){
sqliteVdbeAddOp(v, OP_ColumnCount, pEList->nExpr*2, 0);
}else{
sqliteVdbeAddOp(v, OP_ColumnCount, pEList->nExpr, 0);
}
#endif
for(i=0; i<pEList->nExpr; i++){
Expr *p;
char *zType = 0;
int showFullNames;
p = pEList->a[i].pExpr;
if( p==0 ) continue;
if( pParse->db->flags & SQLITE_ReportTypes ){
if( zType==0 ){
if( sqliteExprType(p)==SQLITE_SO_TEXT ){
zType = "TEXT";
}else{
zType = "NUMERIC";
}
}
sqliteVdbeAddOp(v, OP_ColumnName, i + pEList->nExpr, 0);
sqliteVdbeChangeP3(v, -1, zType, P3_STATIC);
}
if( pEList->a[i].zName ){
char *zName = pEList->a[i].zName;
sqliteVdbeAddOp(v, OP_ColumnName, i, 0);
sqliteVdbeChangeP3(v, -1, zName, strlen(zName));
continue;
}
p = pEList->a[i].pExpr;
if( p==0 ) continue;
showFullNames = (pParse->db->flags & SQLITE_FullColNames)!=0;
if( p->op==TK_COLUMN && pTabList ){
Table *pTab = pTabList->a[p->iTable - base].pTab;
@@ -751,17 +755,6 @@ static void generateColumnNames(
sqliteVdbeAddOp(v, OP_ColumnName, i, 0);
sqliteVdbeChangeP3(v, -1, zName, strlen(zName));
}
if( pParse->db->flags & SQLITE_ReportTypes ){
if( zType==0 ){
if( sqliteExprType(p)==SQLITE_SO_TEXT ){
zType = "TEXT";
}else{
zType = "NUMERIC";
}
}
sqliteVdbeAddOp(v, OP_ColumnName, i + pEList->nExpr, 0);
sqliteVdbeChangeP3(v, -1, zType, P3_STATIC);
}
}
}