aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/build.c10
-rw-r--r--src/select.c24
-rw-r--r--src/sqliteInt.h4
-rw-r--r--src/tclsqlite.c35
4 files changed, 46 insertions, 27 deletions
diff --git a/src/build.c b/src/build.c
index 74bd54817..1f2fc7829 100644
--- a/src/build.c
+++ b/src/build.c
@@ -25,7 +25,7 @@
** ROLLBACK
** PRAGMA
**
-** $Id: build.c,v 1.102 2002/07/08 22:03:32 drh Exp $
+** $Id: build.c,v 1.103 2002/07/11 12:18:16 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -2044,6 +2044,14 @@ void sqlitePragma(Parse *pParse, Token *pLeft, Token *pRight, int minusFlag){
}
}else
+ if( sqliteStrICmp(zLeft, "show_datatypes")==0 ){
+ if( getBoolean(zRight) ){
+ db->flags |= SQLITE_ReportTypes;
+ }else{
+ db->flags &= ~SQLITE_ReportTypes;
+ }
+ }else
+
if( sqliteStrICmp(zLeft, "result_set_details")==0 ){
if( getBoolean(zRight) ){
db->flags |= SQLITE_ResultDetails;
diff --git a/src/select.c b/src/select.c
index 73c1f6a3d..61be40e9c 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.104 2002/07/10 21:26:01 drh Exp $
+** $Id: select.c,v 1.105 2002/07/11 12:18:17 drh Exp $
*/
#include "sqliteInt.h"
@@ -612,7 +612,11 @@ static void generateColumnNames(
int i;
if( pParse->colNamesSet || v==0 || sqlite_malloc_failed ) return;
pParse->colNamesSet = 1;
- sqliteVdbeAddOp(v, OP_ColumnCount, pEList->nExpr*2+1, 0);
+ if( pParse->db->flags & SQLITE_ReportTypes ){
+ sqliteVdbeAddOp(v, OP_ColumnCount, pEList->nExpr*2, 0);
+ }else{
+ sqliteVdbeAddOp(v, OP_ColumnCount, pEList->nExpr, 0);
+ }
for(i=0; i<pEList->nExpr; i++){
Expr *p;
char *zType = 0;
@@ -672,15 +676,17 @@ 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";
+ 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);
}
- sqliteVdbeAddOp(v, OP_ColumnName, i + pEList->nExpr + 1, 0);
- sqliteVdbeChangeP3(v, -1, zType, P3_STATIC);
}
}
diff --git a/src/sqliteInt.h b/src/sqliteInt.h
index 5f9056745..910bd5b5d 100644
--- a/src/sqliteInt.h
+++ b/src/sqliteInt.h
@@ -11,7 +11,7 @@
*************************************************************************
** Internal interface definitions for SQLite.
**
-** @(#) $Id: sqliteInt.h,v 1.135 2002/07/08 22:03:32 drh Exp $
+** @(#) $Id: sqliteInt.h,v 1.136 2002/07/11 12:18:17 drh Exp $
*/
#include "sqlite.h"
#include "hash.h"
@@ -230,6 +230,8 @@ struct sqlite {
#define SQLITE_ResultDetails 0x00000100 /* Details added to result set */
#define SQLITE_UnresetViews 0x00000200 /* True if one or more views have */
/* defined column names */
+#define SQLITE_ReportTypes 0x00000400 /* Include information on datatypes */
+ /* in 4th argument of callback */
/*
** Possible values for the sqlite.magic field.
diff --git a/src/tclsqlite.c b/src/tclsqlite.c
index b8e2a5ee3..93cf71846 100644
--- a/src/tclsqlite.c
+++ b/src/tclsqlite.c
@@ -11,7 +11,7 @@
*************************************************************************
** A TCL Interface to SQLite
**
-** $Id: tclsqlite.c,v 1.37 2002/07/10 21:26:01 drh Exp $
+** $Id: tclsqlite.c,v 1.38 2002/07/11 12:18:17 drh Exp $
*/
#ifndef NO_TCL /* Omit this whole file if TCL is unavailable */
@@ -93,18 +93,20 @@ static int DbEvalCallback(
return 1;
}
if( cbData->zArray[0] ){
- Tcl_DString dType;
- Tcl_DStringInit(&dType);
Tcl_SetVar2(cbData->interp, cbData->zArray, "*",
Tcl_DStringValue(&dCol), TCL_LIST_ELEMENT|TCL_APPEND_VALUE);
- Tcl_DStringAppend(&dType, "typeof:", -1);
- Tcl_DStringAppend(&dType, Tcl_DStringValue(&dCol), -1);
- Tcl_DStringFree(&dCol);
- Tcl_ExternalToUtfDString(NULL, azN[i+argc+1], -1, &dCol);
- Tcl_SetVar2(cbData->interp, cbData->zArray,
- Tcl_DStringValue(&dType), Tcl_DStringValue(&dCol),
- TCL_LIST_ELEMENT|TCL_APPEND_VALUE);
- Tcl_DStringFree(&dType);
+ if( azN[nCol]!=0 } {
+ Tcl_DString dType;
+ Tcl_DStringInit(&dType);
+ Tcl_DStringAppend(&dType, "typeof:", -1);
+ Tcl_DStringAppend(&dType, Tcl_DStringValue(&dCol), -1);
+ Tcl_DStringFree(&dCol);
+ Tcl_ExternalToUtfDString(NULL, azN[i+nCol], -1, &dCol);
+ Tcl_SetVar2(cbData->interp, cbData->zArray,
+ Tcl_DStringValue(&dType), Tcl_DStringValue(&dCol),
+ TCL_LIST_ELEMENT|TCL_APPEND_VALUE);
+ Tcl_DStringFree(&dType);
+ }
}
Tcl_DStringFree(&dCol);
@@ -163,13 +165,14 @@ static int DbEvalCallback(
if( azCol==0 || (cbData->once && cbData->zArray[0]) ){
Tcl_SetVar2(cbData->interp, cbData->zArray, "*", "", 0);
for(i=0; i<nCol; i++){
- char *z;
Tcl_SetVar2(cbData->interp, cbData->zArray, "*", azN[i],
TCL_LIST_ELEMENT|TCL_APPEND_VALUE);
- z = sqlite_mprintf("typeof:%s", azN[i]);
- Tcl_SetVar2(cbData->interp, cbData->zArray, z, azN[i+nCol+1],
- TCL_LIST_ELEMENT|TCL_APPEND_VALUE);
- sqlite_freemem(z);
+ if( azN[nCol] ){
+ char *z = sqlite_mprintf("typeof:%s", azN[i]);
+ Tcl_SetVar2(cbData->interp, cbData->zArray, z, azN[i+nCol],
+ TCL_LIST_ELEMENT|TCL_APPEND_VALUE);
+ sqlite_freemem(z);
+ }
}
cbData->once = 0;
}