Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Turn of the reporting of datatypes in the 4th callback argument unless the SHOW_DATATYPES pragma is ON. Eliminate the NULL pointer that used to separate the beginning of datatypes from the end of column names so that the callback can test to see whether or not datatypes are provided. This is an incompatible changes, but since the prior behavior was never documented, we will let it in. (CVS 670) |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
b98727246d5fcc1b097b577be498a77e |
User & Date: | drh 2002-07-11 12:18:16 |
Context
2002-07-13
| ||
03:11 | Fix for ticket #95: Do not allow automatically created indices (associated with UNIQUE or PRIMARY KEY constraints) to be dropped. (CVS 671) check-in: 0603eb74 user: drh tags: trunk | |
2002-07-11
| ||
12:18 | Turn of the reporting of datatypes in the 4th callback argument unless the SHOW_DATATYPES pragma is ON. Eliminate the NULL pointer that used to separate the beginning of datatypes from the end of column names so that the callback can test to see whether or not datatypes are provided. This is an incompatible changes, but since the prior behavior was never documented, we will let it in. (CVS 670) check-in: b9872724 user: drh tags: trunk | |
2002-07-10
| ||
21:26 | When reporting back the datatype of columns, use the text of the datatype as it appears in the CREATE TABLE statement, if available. Also: removed the ".reindex" command from the shell. (CVS 669) check-in: ff8b6f4e user: drh tags: trunk | |
Changes
Changes to src/build.c.
21 21 ** COPY 22 22 ** VACUUM 23 23 ** BEGIN TRANSACTION 24 24 ** COMMIT 25 25 ** ROLLBACK 26 26 ** PRAGMA 27 27 ** 28 -** $Id: build.c,v 1.102 2002/07/08 22:03:32 drh Exp $ 28 +** $Id: build.c,v 1.103 2002/07/11 12:18:16 drh Exp $ 29 29 */ 30 30 #include "sqliteInt.h" 31 31 #include <ctype.h> 32 32 33 33 /* 34 34 ** This routine is called when a new SQL statement is beginning to 35 35 ** be parsed. Check to see if the schema for the database needs ................................................................................ 2039 2039 if( sqliteStrICmp(zLeft, "full_column_names")==0 ){ 2040 2040 if( getBoolean(zRight) ){ 2041 2041 db->flags |= SQLITE_FullColNames; 2042 2042 }else{ 2043 2043 db->flags &= ~SQLITE_FullColNames; 2044 2044 } 2045 2045 }else 2046 + 2047 + if( sqliteStrICmp(zLeft, "show_datatypes")==0 ){ 2048 + if( getBoolean(zRight) ){ 2049 + db->flags |= SQLITE_ReportTypes; 2050 + }else{ 2051 + db->flags &= ~SQLITE_ReportTypes; 2052 + } 2053 + }else 2046 2054 2047 2055 if( sqliteStrICmp(zLeft, "result_set_details")==0 ){ 2048 2056 if( getBoolean(zRight) ){ 2049 2057 db->flags |= SQLITE_ResultDetails; 2050 2058 }else{ 2051 2059 db->flags &= ~SQLITE_ResultDetails; 2052 2060 }
Changes to src/select.c.
8 8 ** May you find forgiveness for yourself and forgive others. 9 9 ** May you share freely, never taking more than you give. 10 10 ** 11 11 ************************************************************************* 12 12 ** This file contains C code routines that are called by the parser 13 13 ** to handle SELECT statements in SQLite. 14 14 ** 15 -** $Id: select.c,v 1.104 2002/07/10 21:26:01 drh Exp $ 15 +** $Id: select.c,v 1.105 2002/07/11 12:18:17 drh Exp $ 16 16 */ 17 17 #include "sqliteInt.h" 18 18 19 19 /* 20 20 ** Allocate a new Select structure and return a pointer to that 21 21 ** structure. 22 22 */ ................................................................................ 608 608 SrcList *pTabList, /* List of tables */ 609 609 ExprList *pEList /* Expressions defining the result set */ 610 610 ){ 611 611 Vdbe *v = pParse->pVdbe; 612 612 int i; 613 613 if( pParse->colNamesSet || v==0 || sqlite_malloc_failed ) return; 614 614 pParse->colNamesSet = 1; 615 - sqliteVdbeAddOp(v, OP_ColumnCount, pEList->nExpr*2+1, 0); 615 + if( pParse->db->flags & SQLITE_ReportTypes ){ 616 + sqliteVdbeAddOp(v, OP_ColumnCount, pEList->nExpr*2, 0); 617 + }else{ 618 + sqliteVdbeAddOp(v, OP_ColumnCount, pEList->nExpr, 0); 619 + } 616 620 for(i=0; i<pEList->nExpr; i++){ 617 621 Expr *p; 618 622 char *zType = 0; 619 623 int showFullNames; 620 624 if( pEList->a[i].zName ){ 621 625 char *zName = pEList->a[i].zName; 622 626 sqliteVdbeAddOp(v, OP_ColumnName, i, 0); ................................................................................ 668 672 }else{ 669 673 char zName[30]; 670 674 assert( p->op!=TK_COLUMN || pTabList==0 ); 671 675 sprintf(zName, "column%d", i+1); 672 676 sqliteVdbeAddOp(v, OP_ColumnName, i, 0); 673 677 sqliteVdbeChangeP3(v, -1, zName, strlen(zName)); 674 678 } 675 - if( zType==0 ){ 676 - if( sqliteExprType(p)==SQLITE_SO_TEXT ){ 677 - zType = "TEXT"; 678 - }else{ 679 - zType = "NUMERIC"; 679 + if( pParse->db->flags & SQLITE_ReportTypes ){ 680 + if( zType==0 ){ 681 + if( sqliteExprType(p)==SQLITE_SO_TEXT ){ 682 + zType = "TEXT"; 683 + }else{ 684 + zType = "NUMERIC"; 685 + } 680 686 } 687 + sqliteVdbeAddOp(v, OP_ColumnName, i + pEList->nExpr, 0); 688 + sqliteVdbeChangeP3(v, -1, zType, P3_STATIC); 681 689 } 682 - sqliteVdbeAddOp(v, OP_ColumnName, i + pEList->nExpr + 1, 0); 683 - sqliteVdbeChangeP3(v, -1, zType, P3_STATIC); 684 690 } 685 691 } 686 692 687 693 /* 688 694 ** Name of the connection operator, used for error messages. 689 695 */ 690 696 static const char *selectOpName(int id){
Changes to src/sqliteInt.h.
7 7 ** May you do good and not evil. 8 8 ** May you find forgiveness for yourself and forgive others. 9 9 ** May you share freely, never taking more than you give. 10 10 ** 11 11 ************************************************************************* 12 12 ** Internal interface definitions for SQLite. 13 13 ** 14 -** @(#) $Id: sqliteInt.h,v 1.135 2002/07/08 22:03:32 drh Exp $ 14 +** @(#) $Id: sqliteInt.h,v 1.136 2002/07/11 12:18:17 drh Exp $ 15 15 */ 16 16 #include "sqlite.h" 17 17 #include "hash.h" 18 18 #include "vdbe.h" 19 19 #include "parse.h" 20 20 #include "btree.h" 21 21 #include <stdio.h> ................................................................................ 226 226 /* DELETE, or UPDATE and return */ 227 227 /* the count using a callback. */ 228 228 #define SQLITE_NullCallback 0x00000080 /* Invoke the callback once if the */ 229 229 /* result set is empty */ 230 230 #define SQLITE_ResultDetails 0x00000100 /* Details added to result set */ 231 231 #define SQLITE_UnresetViews 0x00000200 /* True if one or more views have */ 232 232 /* defined column names */ 233 +#define SQLITE_ReportTypes 0x00000400 /* Include information on datatypes */ 234 + /* in 4th argument of callback */ 233 235 234 236 /* 235 237 ** Possible values for the sqlite.magic field. 236 238 ** The numbers are obtained at random and have no special meaning, other 237 239 ** than being distinct from one another. 238 240 */ 239 241 #define SQLITE_MAGIC_OPEN 0xa029a697 /* Database is open */
Changes to src/tclsqlite.c.
7 7 ** May you do good and not evil. 8 8 ** May you find forgiveness for yourself and forgive others. 9 9 ** May you share freely, never taking more than you give. 10 10 ** 11 11 ************************************************************************* 12 12 ** A TCL Interface to SQLite 13 13 ** 14 -** $Id: tclsqlite.c,v 1.37 2002/07/10 21:26:01 drh Exp $ 14 +** $Id: tclsqlite.c,v 1.38 2002/07/11 12:18:17 drh Exp $ 15 15 */ 16 16 #ifndef NO_TCL /* Omit this whole file if TCL is unavailable */ 17 17 18 18 #include "sqliteInt.h" 19 19 #include "tcl.h" 20 20 #include <stdlib.h> 21 21 #include <string.h> ................................................................................ 89 89 cbData->azColName[i] = malloc( Tcl_DStringLength(&dCol) + 1 ); 90 90 if( cbData->azColName[i] ){ 91 91 strcpy(cbData->azColName[i], Tcl_DStringValue(&dCol)); 92 92 }else{ 93 93 return 1; 94 94 } 95 95 if( cbData->zArray[0] ){ 96 - Tcl_DString dType; 97 - Tcl_DStringInit(&dType); 98 96 Tcl_SetVar2(cbData->interp, cbData->zArray, "*", 99 97 Tcl_DStringValue(&dCol), TCL_LIST_ELEMENT|TCL_APPEND_VALUE); 100 - Tcl_DStringAppend(&dType, "typeof:", -1); 101 - Tcl_DStringAppend(&dType, Tcl_DStringValue(&dCol), -1); 102 - Tcl_DStringFree(&dCol); 103 - Tcl_ExternalToUtfDString(NULL, azN[i+argc+1], -1, &dCol); 104 - Tcl_SetVar2(cbData->interp, cbData->zArray, 105 - Tcl_DStringValue(&dType), Tcl_DStringValue(&dCol), 106 - TCL_LIST_ELEMENT|TCL_APPEND_VALUE); 107 - Tcl_DStringFree(&dType); 98 + if( azN[nCol]!=0 } { 99 + Tcl_DString dType; 100 + Tcl_DStringInit(&dType); 101 + Tcl_DStringAppend(&dType, "typeof:", -1); 102 + Tcl_DStringAppend(&dType, Tcl_DStringValue(&dCol), -1); 103 + Tcl_DStringFree(&dCol); 104 + Tcl_ExternalToUtfDString(NULL, azN[i+nCol], -1, &dCol); 105 + Tcl_SetVar2(cbData->interp, cbData->zArray, 106 + Tcl_DStringValue(&dType), Tcl_DStringValue(&dCol), 107 + TCL_LIST_ELEMENT|TCL_APPEND_VALUE); 108 + Tcl_DStringFree(&dType); 109 + } 108 110 } 109 111 110 112 Tcl_DStringFree(&dCol); 111 113 } 112 114 } 113 115 if( azCol!=0 ){ 114 116 if( cbData->zArray[0] ){ ................................................................................ 159 161 char ** azN /* Name for each column */ 160 162 ){ 161 163 CallbackData *cbData = (CallbackData*)clientData; 162 164 int i, rc; 163 165 if( azCol==0 || (cbData->once && cbData->zArray[0]) ){ 164 166 Tcl_SetVar2(cbData->interp, cbData->zArray, "*", "", 0); 165 167 for(i=0; i<nCol; i++){ 166 - char *z; 167 168 Tcl_SetVar2(cbData->interp, cbData->zArray, "*", azN[i], 168 169 TCL_LIST_ELEMENT|TCL_APPEND_VALUE); 169 - z = sqlite_mprintf("typeof:%s", azN[i]); 170 - Tcl_SetVar2(cbData->interp, cbData->zArray, z, azN[i+nCol+1], 171 - TCL_LIST_ELEMENT|TCL_APPEND_VALUE); 172 - sqlite_freemem(z); 170 + if( azN[nCol] ){ 171 + char *z = sqlite_mprintf("typeof:%s", azN[i]); 172 + Tcl_SetVar2(cbData->interp, cbData->zArray, z, azN[i+nCol], 173 + TCL_LIST_ELEMENT|TCL_APPEND_VALUE); 174 + sqlite_freemem(z); 175 + } 173 176 } 174 177 cbData->once = 0; 175 178 } 176 179 if( azCol!=0 ){ 177 180 if( cbData->zArray[0] ){ 178 181 for(i=0; i<nCol; i++){ 179 182 char *z = azCol[i];