Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | 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) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
ff8b6f4ee8099a7170cb786b8ead9a3e |
User & Date: | drh 2002-07-10 21:26:01.000 |
Context
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: b98727246d 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: ff8b6f4ee8 user: drh tags: trunk) | |
2002-07-08
| ||
22:03 | Add support for TEMPORARY views. The code is here but it is mostly untested. (CVS 668) (check-in: 87cd10c1f6 user: drh tags: trunk) | |
Changes
Changes to src/printf.c.
︙ | ︙ | |||
695 696 697 698 699 700 701 | sMprintf.nAlloc = sizeof(zBuf); sMprintf.zText = zBuf; sMprintf.zBase = zBuf; va_start(ap,zFormat); vxprintf(mout,&sMprintf,zFormat,ap); va_end(ap); sMprintf.zText[sMprintf.nChar] = 0; | < | | < | < | < > | | | < < < | | < < | | 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 | sMprintf.nAlloc = sizeof(zBuf); sMprintf.zText = zBuf; sMprintf.zBase = zBuf; va_start(ap,zFormat); vxprintf(mout,&sMprintf,zFormat,ap); va_end(ap); sMprintf.zText[sMprintf.nChar] = 0; zNew = malloc( sMprintf.nChar+1 ); if( zNew ) strcpy(zNew,sMprintf.zText); if( sMprintf.zText!=sMprintf.zBase ){ sqliteFree(sMprintf.zText); } return zNew; } /* This is the varargs version of sqlite_mprintf. */ char *sqlite_vmprintf(const char *zFormat, va_list ap){ struct sgMprintf sMprintf; char *zNew; char zBuf[200]; sMprintf.nChar = 0; sMprintf.zText = zBuf; sMprintf.nAlloc = sizeof(zBuf); sMprintf.zBase = zBuf; vxprintf(mout,&sMprintf,zFormat,ap); sMprintf.zText[sMprintf.nChar] = 0; zNew = malloc( sMprintf.nChar+1 ); if( zNew ) strcpy(zNew,sMprintf.zText); if( sMprintf.zText!=sMprintf.zBase ){ sqliteFree(sMprintf.zText); } return zNew; } /* ** The following four routines implement the varargs versions of the ** sqlite_exec() and sqlite_get_table() interfaces. See the sqlite.h ** header files for a more detailed description of how these interfaces ** work. |
︙ | ︙ | |||
768 769 770 771 772 773 774 | va_list ap /* Arguments to the format string. */ ){ char *zSql; int rc; zSql = sqlite_vmprintf(sqlFormat, ap); rc = sqlite_exec(db, zSql, xCallback, pArg, errmsg); | | | 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 | va_list ap /* Arguments to the format string. */ ){ char *zSql; int rc; zSql = sqlite_vmprintf(sqlFormat, ap); rc = sqlite_exec(db, zSql, xCallback, pArg, errmsg); free(zSql); return rc; } int sqlite_get_table_printf( sqlite *db, /* An open database */ const char *sqlFormat, /* printf-style format string for the SQL */ char ***resultp, /* Result written to a char *[] that this points to */ int *nrow, /* Number of result rows written here */ |
︙ | ︙ | |||
802 803 804 805 806 807 808 | va_list ap /* Arguments to the format string */ ){ char *zSql; int rc; zSql = sqlite_vmprintf(sqlFormat, ap); rc = sqlite_get_table(db, zSql, resultp, nrow, ncolumn, errmsg); | | | 794 795 796 797 798 799 800 801 802 803 | va_list ap /* Arguments to the format string */ ){ char *zSql; int rc; zSql = sqlite_vmprintf(sqlFormat, ap); rc = sqlite_get_table(db, zSql, resultp, nrow, ncolumn, errmsg); free(zSql); return rc; } |
Changes to src/select.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that are called by the parser ** to handle SELECT statements in SQLite. ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** 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 $ */ #include "sqliteInt.h" /* ** Allocate a new Select structure and return a pointer to that ** structure. */ |
︙ | ︙ | |||
622 623 624 625 626 627 628 | 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; | < < < < | > > > > | > > > > | 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 | 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; char *zCol; int iCol = p->iColumn; if( iCol<0 ) iCol = pTab->iPKey; assert( iCol==-1 || (iCol>=0 && iCol<pTab->nCol) ); if( iCol<0 ){ zCol = "_ROWID_"; zType = "INTEGER"; }else{ zCol = pTab->aCol[iCol].zName; zType = pTab->aCol[iCol].zType; } if( p->span.z && p->span.z[0] && !showFullNames ){ int addr = sqliteVdbeAddOp(v,OP_ColumnName, i, 0); sqliteVdbeChangeP3(v, -1, p->span.z, p->span.n); sqliteVdbeCompressSpace(v, addr); }else if( pTabList->nSrc>1 || showFullNames ){ char *zName = 0; char *zTab; zTab = pTabList->a[p->iTable - base].zAlias; if( showFullNames || zTab==0 ) zTab = pTab->zName; sqliteSetString(&zName, zTab, ".", zCol, 0); sqliteVdbeAddOp(v, OP_ColumnName, i, 0); sqliteVdbeChangeP3(v, -1, zName, strlen(zName)); sqliteFree(zName); }else{ sqliteVdbeAddOp(v, OP_ColumnName, i, 0); sqliteVdbeChangeP3(v, -1, zCol, 0); } }else if( p->span.z && p->span.z[0] && !showFullNames ){ int addr = sqliteVdbeAddOp(v,OP_ColumnName, i, 0); sqliteVdbeChangeP3(v, -1, p->span.z, p->span.n); sqliteVdbeCompressSpace(v, addr); }else if( p->span.z && p->span.z[0] ){ int addr = sqliteVdbeAddOp(v,OP_ColumnName, i, 0); sqliteVdbeChangeP3(v, -1, p->span.z, p->span.n); sqliteVdbeCompressSpace(v, addr); }else{ char zName[30]; assert( p->op!=TK_COLUMN || pTabList==0 ); |
︙ | ︙ |
Changes to src/shell.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains code to implement the "sqlite" command line ** utility for accessing SQLite databases. ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains code to implement the "sqlite" command line ** utility for accessing SQLite databases. ** ** $Id: shell.c,v 1.60 2002/07/10 21:26:01 drh Exp $ */ #include <stdlib.h> #include <string.h> #include <stdio.h> #include "sqlite.h" #include <ctype.h> |
︙ | ︙ | |||
488 489 490 491 492 493 494 | ".nullvalue STRING Print STRING instead of nothing for NULL data\n" ".openaux FILENAME Use FILENAME to hold TEMP tables\n" ".output FILENAME Send output to FILENAME\n" ".output stdout Send output to the screen\n" ".prompt MAIN CONTINUE Replace the standard prompts\n" ".quit Exit this program\n" ".read FILENAME Execute SQL in FILENAME\n" | < < | 488 489 490 491 492 493 494 495 496 497 498 499 500 501 | ".nullvalue STRING Print STRING instead of nothing for NULL data\n" ".openaux FILENAME Use FILENAME to hold TEMP tables\n" ".output FILENAME Send output to FILENAME\n" ".output stdout Send output to the screen\n" ".prompt MAIN CONTINUE Replace the standard prompts\n" ".quit Exit this program\n" ".read FILENAME Execute SQL in FILENAME\n" ".schema ?TABLE? Show the CREATE statements\n" ".separator STRING Change separator string for \"list\" mode\n" ".show Show the current values for various settings\n" ".tables ?PATTERN? List names of tables matching a pattern\n" ".timeout MS Try opening locked tables for MS milliseconds\n" ".width NUM NUM ... Set column widths for \"column\" mode\n" ; |
︙ | ︙ | |||
748 749 750 751 752 753 754 | FILE *alt = fopen(azArg[1], "r"); if( alt==0 ){ fprintf(stderr,"can't open \"%s\"\n", azArg[1]); }else{ process_input(p, alt); fclose(alt); } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 746 747 748 749 750 751 752 753 754 755 756 757 758 759 | FILE *alt = fopen(azArg[1], "r"); if( alt==0 ){ fprintf(stderr,"can't open \"%s\"\n", azArg[1]); }else{ process_input(p, alt); fclose(alt); } }else if( c=='s' && strncmp(azArg[0], "schema", n)==0 ){ struct callback_data data; char *zErrMsg = 0; memcpy(&data, p, sizeof(data)); data.showHeader = 0; |
︙ | ︙ |
Changes to src/tclsqlite.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 | /* ** 2001 September 15 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** A TCL Interface to SQLite ** | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | /* ** 2001 September 15 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** A TCL Interface to SQLite ** ** $Id: tclsqlite.c,v 1.37 2002/07/10 21:26:01 drh Exp $ */ #ifndef NO_TCL /* Omit this whole file if TCL is unavailable */ #include "sqliteInt.h" #include "tcl.h" #include <stdlib.h> #include <string.h> |
︙ | ︙ | |||
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | cbData->azColName[i] = malloc( Tcl_DStringLength(&dCol) + 1 ); if( cbData->azColName[i] ){ strcpy(cbData->azColName[i], Tcl_DStringValue(&dCol)); }else{ return 1; } if( cbData->zArray[0] ){ Tcl_SetVar2(cbData->interp, cbData->zArray, "*", Tcl_DStringValue(&dCol), TCL_LIST_ELEMENT|TCL_APPEND_VALUE); } Tcl_DStringFree(&dCol); } } if( azCol!=0 ){ if( cbData->zArray[0] ){ for(i=0; i<nCol; i++){ char *z = azCol[i]; | > > > > > > > > > > > | 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | cbData->azColName[i] = malloc( Tcl_DStringLength(&dCol) + 1 ); if( cbData->azColName[i] ){ strcpy(cbData->azColName[i], Tcl_DStringValue(&dCol)); }else{ 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); } Tcl_DStringFree(&dCol); } } if( azCol!=0 ){ if( cbData->zArray[0] ){ for(i=0; i<nCol; i++){ char *z = azCol[i]; |
︙ | ︙ | |||
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | char ** azN /* Name for each column */ ){ CallbackData *cbData = (CallbackData*)clientData; int i, rc; if( azCol==0 || (cbData->once && cbData->zArray[0]) ){ Tcl_SetVar2(cbData->interp, cbData->zArray, "*", "", 0); for(i=0; i<nCol; i++){ Tcl_SetVar2(cbData->interp, cbData->zArray, "*", azN[i], TCL_LIST_ELEMENT|TCL_APPEND_VALUE); } cbData->once = 0; } if( azCol!=0 ){ if( cbData->zArray[0] ){ for(i=0; i<nCol; i++){ char *z = azCol[i]; | > > > > > | 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | char ** azN /* Name for each column */ ){ CallbackData *cbData = (CallbackData*)clientData; int i, rc; 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); } cbData->once = 0; } if( azCol!=0 ){ if( cbData->zArray[0] ){ for(i=0; i<nCol; i++){ char *z = azCol[i]; |
︙ | ︙ |
Changes to src/test1.c.
︙ | ︙ | |||
9 10 11 12 13 14 15 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing the printf() interface to SQLite. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing the printf() interface to SQLite. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** ** $Id: test1.c,v 1.12 2002/07/10 21:26:01 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include <stdlib.h> #include <string.h> /* |
︙ | ︙ | |||
327 328 329 330 331 332 333 | return TCL_ERROR; } for(i=2; i<5; i++){ if( Tcl_GetInt(interp, argv[i], &a[i-2]) ) return TCL_ERROR; } z = sqlite_mprintf(argv[1], a[0], a[1], a[2]); Tcl_AppendResult(interp, z, 0); | | | 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | return TCL_ERROR; } for(i=2; i<5; i++){ if( Tcl_GetInt(interp, argv[i], &a[i-2]) ) return TCL_ERROR; } z = sqlite_mprintf(argv[1], a[0], a[1], a[2]); Tcl_AppendResult(interp, z, 0); sqlite_freemem(z); return TCL_OK; } /* ** Usage: sqlite_mprintf_str FORMAT INTEGER INTEGER STRING ** ** Call mprintf with two integer arguments and one string argument |
︙ | ︙ | |||
354 355 356 357 358 359 360 | return TCL_ERROR; } for(i=2; i<4; i++){ if( Tcl_GetInt(interp, argv[i], &a[i-2]) ) return TCL_ERROR; } z = sqlite_mprintf(argv[1], a[0], a[1], argc>4 ? argv[4] : NULL); Tcl_AppendResult(interp, z, 0); | | | 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 | return TCL_ERROR; } for(i=2; i<4; i++){ if( Tcl_GetInt(interp, argv[i], &a[i-2]) ) return TCL_ERROR; } z = sqlite_mprintf(argv[1], a[0], a[1], argc>4 ? argv[4] : NULL); Tcl_AppendResult(interp, z, 0); sqlite_freemem(z); return TCL_OK; } /* ** Usage: sqlite_mprintf_str FORMAT INTEGER INTEGER DOUBLE ** ** Call mprintf with two integer arguments and one double argument |
︙ | ︙ | |||
383 384 385 386 387 388 389 | } for(i=2; i<4; i++){ if( Tcl_GetInt(interp, argv[i], &a[i-2]) ) return TCL_ERROR; } if( Tcl_GetDouble(interp, argv[4], &r) ) return TCL_ERROR; z = sqlite_mprintf(argv[1], a[0], a[1], r); Tcl_AppendResult(interp, z, 0); | | | 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 | } for(i=2; i<4; i++){ if( Tcl_GetInt(interp, argv[i], &a[i-2]) ) return TCL_ERROR; } if( Tcl_GetDouble(interp, argv[4], &r) ) return TCL_ERROR; z = sqlite_mprintf(argv[1], a[0], a[1], r); Tcl_AppendResult(interp, z, 0); sqlite_freemem(z); return TCL_OK; } /* ** Usage: sqlite_malloc_fail N ** ** Rig sqliteMalloc() to fail on the N-th call. Turn off this mechanism |
︙ | ︙ |
Changes to src/threadtest.c.
︙ | ︙ | |||
21 22 23 24 25 26 27 | #include "sqlite.h" #include <pthread.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> | < < | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #include "sqlite.h" #include <pthread.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> /* ** Come here to die. */ static void Exit(int rc){ exit(rc); } |
︙ | ︙ | |||
96 97 98 99 100 101 102 | rc = sqlite_exec(db, zSql, db_query_callback, &sResult, &zErrMsg); if( zErrMsg ){ fprintf(stderr,"%s: query failed: %s - %s\n", zFile, zSql, zErrMsg); free(zErrMsg); free(zSql); Exit(1); } | | | 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | rc = sqlite_exec(db, zSql, db_query_callback, &sResult, &zErrMsg); if( zErrMsg ){ fprintf(stderr,"%s: query failed: %s - %s\n", zFile, zSql, zErrMsg); free(zErrMsg); free(zSql); Exit(1); } sqlite_freemem(zSql); if( sResult.azElem==0 ){ db_query_callback(&sResult, 0, 0, 0); } sResult.azElem[sResult.nElem] = 0; return sResult.azElem; } |
︙ | ︙ | |||
119 120 121 122 123 124 125 | va_start(ap, zFormat); zSql = sqlite_vmprintf(zFormat, ap); va_end(ap); rc = sqlite_exec(db, zSql, 0, 0, &zErrMsg); if( zErrMsg ){ fprintf(stderr,"%s: command failed: %s - %s\n", zFile, zSql, zErrMsg); free(zErrMsg); | | | | | 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | va_start(ap, zFormat); zSql = sqlite_vmprintf(zFormat, ap); va_end(ap); rc = sqlite_exec(db, zSql, 0, 0, &zErrMsg); if( zErrMsg ){ fprintf(stderr,"%s: command failed: %s - %s\n", zFile, zSql, zErrMsg); free(zErrMsg); sqlite_freemem(zSql); Exit(1); } sqlite_freemem(zSql); } /* ** Free the results of a db_query() call. */ void db_query_free(char **az){ int i; for(i=0; az[i]; i++){ sqlite_freemem(az[i]); } free(az); } /* ** Check results */ |
︙ | ︙ |