Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix some more small problems introduced by recent refactoring. (CVS 4235) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
5e2795d0eb8ea2a076b3014cfa9096aa |
User & Date: | danielk1977 2007-08-16 11:36:15.000 |
Context
2007-08-16
| ||
12:24 | Combine sqlite3DbOfVdbe() and sqlite3VdbeDb() into a single function. (CVS 4236) (check-in: ba80ee59a7 user: drh tags: trunk) | |
11:36 | Fix some more small problems introduced by recent refactoring. (CVS 4235) (check-in: 5e2795d0eb user: danielk1977 tags: trunk) | |
10:36 | Replace a few sqlite3_malloc() calls that should be sqlite3MallocZero(). (CVS 4234) (check-in: 384d0ca9bc user: danielk1977 tags: trunk) | |
Changes
Changes to src/expr.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 routines used for analyzing expressions and ** for generating VDBE code that evaluates expressions 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 routines used for analyzing expressions and ** for generating VDBE code that evaluates expressions in SQLite. ** ** $Id: expr.c,v 1.306 2007/08/16 11:36:15 danielk1977 Exp $ */ #include "sqliteInt.h" #include <ctype.h> /* ** Return the 'affinity' of the expression pExpr if any. ** |
︙ | ︙ | |||
524 525 526 527 528 529 530 531 532 533 534 535 536 537 | ExprList *sqlite3ExprListDup(sqlite3 *db, ExprList *p){ ExprList *pNew; struct ExprList_item *pItem, *pOldItem; int i; if( p==0 ) return 0; pNew = sqlite3DbMallocRaw(db, sizeof(*pNew) ); if( pNew==0 ) return 0; pNew->nExpr = pNew->nAlloc = p->nExpr; pNew->a = pItem = sqlite3DbMallocRaw(db, p->nExpr*sizeof(p->a[0]) ); if( pItem==0 ){ sqlite3_free(pNew); return 0; } pOldItem = p->a; | > | 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 | ExprList *sqlite3ExprListDup(sqlite3 *db, ExprList *p){ ExprList *pNew; struct ExprList_item *pItem, *pOldItem; int i; if( p==0 ) return 0; pNew = sqlite3DbMallocRaw(db, sizeof(*pNew) ); if( pNew==0 ) return 0; pNew->iECursor = 0; pNew->nExpr = pNew->nAlloc = p->nExpr; pNew->a = pItem = sqlite3DbMallocRaw(db, p->nExpr*sizeof(p->a[0]) ); if( pItem==0 ){ sqlite3_free(pNew); return 0; } pOldItem = p->a; |
︙ | ︙ |
Changes to src/test3.c.
︙ | ︙ | |||
9 10 11 12 13 14 15 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing the btree.c module in 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 btree.c module in SQLite. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** ** $Id: test3.c,v 1.78 2007/08/16 11:36:15 danielk1977 Exp $ */ #include "sqliteInt.h" #include "pager.h" #include "btree.h" #include "tcl.h" #include <stdlib.h> #include <string.h> |
︙ | ︙ | |||
1054 1055 1056 1057 1058 1059 1060 | }else{ n = atoi(argv[2]); } zBuf = sqlite3_malloc( n+1 ); rc = sqlite3BtreeData(pCur, 0, n, zBuf); if( rc ){ Tcl_AppendResult(interp, errorName(rc), 0); | | | 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 | }else{ n = atoi(argv[2]); } zBuf = sqlite3_malloc( n+1 ); rc = sqlite3BtreeData(pCur, 0, n, zBuf); if( rc ){ Tcl_AppendResult(interp, errorName(rc), 0); sqlite3_free(zBuf); return TCL_ERROR; } zBuf[n] = 0; Tcl_AppendResult(interp, zBuf, 0); sqlite3_free(zBuf); return SQLITE_OK; } |
︙ | ︙ |
Changes to src/test8.c.
︙ | ︙ | |||
9 10 11 12 13 14 15 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing the virtual table interfaces. 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 virtual table interfaces. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** ** $Id: test8.c,v 1.51 2007/08/16 11:36:15 danielk1977 Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include "os.h" #include <stdlib.h> #include <string.h> |
︙ | ︙ | |||
159 160 161 162 163 164 165 | /* Figure out how much space to allocate for the array of column names ** (including space for the strings themselves). Then allocate it. */ nBytes = sizeof(char *) * nCol; for(ii=0; ii<nCol; ii++){ nBytes += (strlen(sqlite3_column_name(pStmt, ii)) + 1); } | | | 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | /* Figure out how much space to allocate for the array of column names ** (including space for the strings themselves). Then allocate it. */ nBytes = sizeof(char *) * nCol; for(ii=0; ii<nCol; ii++){ nBytes += (strlen(sqlite3_column_name(pStmt, ii)) + 1); } aCol = (char **)sqlite3MallocZero(nBytes); if( !aCol ){ rc = SQLITE_NOMEM; goto out; } /* Copy the column names into the allocated space and set up the ** pointers in the aCol[] array. |
︙ | ︙ | |||
209 210 211 212 213 214 215 | ){ sqlite3_stmt *pStmt = 0; int *aIndex = 0; int rc; char *zSql; /* Allocate space for the index array */ | | | 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | ){ sqlite3_stmt *pStmt = 0; int *aIndex = 0; int rc; char *zSql; /* Allocate space for the index array */ aIndex = (int *)sqlite3MallocZero(sizeof(int) * nCol); if( !aIndex ){ rc = SQLITE_NOMEM; goto get_index_array_out; } /* Compile an sqlite pragma to loop through all indices on table zTab */ zSql = sqlite3MPrintf(0, "PRAGMA index_list(%s)", zTab); |
︙ | ︙ | |||
360 361 362 363 364 365 366 | sqlite3_vtab **ppVtab, char **pzErr ){ int i; echo_vtab *pVtab; /* Allocate the sqlite3_vtab/echo_vtab structure itself */ | | | 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | sqlite3_vtab **ppVtab, char **pzErr ){ int i; echo_vtab *pVtab; /* Allocate the sqlite3_vtab/echo_vtab structure itself */ pVtab = sqlite3MallocZero( sizeof(*pVtab) ); if( !pVtab ){ return SQLITE_NOMEM; } pVtab->interp = (Tcl_Interp *)pAux; pVtab->db = db; /* Allocate echo_vtab.zThis */ |
︙ | ︙ | |||
494 495 496 497 498 499 500 | } /* ** Echo virtual table module xOpen method. */ static int echoOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){ echo_cursor *pCur; | | | 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 | } /* ** Echo virtual table module xOpen method. */ static int echoOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){ echo_cursor *pCur; pCur = sqlite3MallocZero(sizeof(echo_cursor)); *ppCursor = (sqlite3_vtab_cursor *)pCur; return (pCur ? SQLITE_OK : SQLITE_NOMEM); } /* ** Echo virtual table module xClose method. */ |
︙ | ︙ | |||
524 525 526 527 528 529 530 | return (((echo_cursor *)cur)->pStmt ? 0 : 1); } /* ** Echo virtual table module xNext method. */ static int echoNext(sqlite3_vtab_cursor *cur){ | | < > > | | | | | > | 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 | return (((echo_cursor *)cur)->pStmt ? 0 : 1); } /* ** Echo virtual table module xNext method. */ static int echoNext(sqlite3_vtab_cursor *cur){ int rc = SQLITE_OK; echo_cursor *pCur = (echo_cursor *)cur; if( pCur->pStmt ){ rc = sqlite3_step(pCur->pStmt); if( rc==SQLITE_ROW ){ rc = SQLITE_OK; }else{ rc = sqlite3_finalize(pCur->pStmt); pCur->pStmt = 0; } } return rc; } /* ** Echo virtual table module xColumn method. |
︙ | ︙ |
Changes to src/test_tclvar.c.
︙ | ︙ | |||
12 13 14 15 16 17 18 | ** Code for testing the virtual table interfaces. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** ** The emphasis of this file is a virtual table that provides ** access to TCL variables. ** | | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ** Code for testing the virtual table interfaces. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** ** The emphasis of this file is a virtual table that provides ** access to TCL variables. ** ** $Id: test_tclvar.c,v 1.13 2007/08/16 11:36:15 danielk1977 Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include "os.h" #include <stdlib.h> #include <string.h> |
︙ | ︙ | |||
54 55 56 57 58 59 60 | int argc, const char *const*argv, sqlite3_vtab **ppVtab, char **pzErr ){ tclvar_vtab *pVtab; static const char zSchema[] = "CREATE TABLE whatever(name TEXT, arrayname TEXT, value TEXT)"; | | | | 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | int argc, const char *const*argv, sqlite3_vtab **ppVtab, char **pzErr ){ tclvar_vtab *pVtab; static const char zSchema[] = "CREATE TABLE whatever(name TEXT, arrayname TEXT, value TEXT)"; pVtab = sqlite3MallocZero( sizeof(*pVtab) ); if( pVtab==0 ) return SQLITE_NOMEM; *ppVtab = &pVtab->base; pVtab->interp = (Tcl_Interp *)pAux; sqlite3_declare_vtab(db, zSchema); return SQLITE_OK; } /* Note that for this virtual table, the xCreate and xConnect ** methods are identical. */ static int tclvarDisconnect(sqlite3_vtab *pVtab){ sqlite3_free(pVtab); return SQLITE_OK; } /* The xDisconnect and xDestroy methods are also the same */ /* ** Open a new tclvar cursor. */ static int tclvarOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){ tclvar_cursor *pCur; pCur = sqlite3MallocZero(sizeof(tclvar_cursor)); *ppCursor = &pCur->base; return SQLITE_OK; } /* ** Close a tclvar cursor. */ |
︙ | ︙ |
Changes to src/vdbeapi.c.
︙ | ︙ | |||
390 391 392 393 394 395 396 397 398 399 400 401 402 403 | ){ struct AuxData *pAuxData; VdbeFunc *pVdbeFunc; if( iArg<0 ) goto failed; pVdbeFunc = pCtx->pVdbeFunc; if( !pVdbeFunc || pVdbeFunc->nAux<=iArg ){ int nMalloc = sizeof(VdbeFunc) + sizeof(struct AuxData)*iArg; pVdbeFunc = sqlite3_realloc(pVdbeFunc, nMalloc); if( !pVdbeFunc ){ pCtx->db->mallocFailed = 1; goto failed; } pCtx->pVdbeFunc = pVdbeFunc; | > | < | 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 | ){ struct AuxData *pAuxData; VdbeFunc *pVdbeFunc; if( iArg<0 ) goto failed; pVdbeFunc = pCtx->pVdbeFunc; if( !pVdbeFunc || pVdbeFunc->nAux<=iArg ){ int nAux = (pVdbeFunc ? pVdbeFunc->nAux : 0); int nMalloc = sizeof(VdbeFunc) + sizeof(struct AuxData)*iArg; pVdbeFunc = sqlite3_realloc(pVdbeFunc, nMalloc); if( !pVdbeFunc ){ pCtx->db->mallocFailed = 1; goto failed; } pCtx->pVdbeFunc = pVdbeFunc; memset(&pVdbeFunc->apAux[nAux], 0, sizeof(struct AuxData)*(iArg+1-nAux)); pVdbeFunc->nAux = iArg+1; pVdbeFunc->pFunc = pCtx->pFunc; } pAuxData = &pVdbeFunc->apAux[iArg]; if( pAuxData->pAux && pAuxData->xDelete ){ pAuxData->xDelete(pAuxData->pAux); |
︙ | ︙ |
Changes to src/where.c.
︙ | ︙ | |||
12 13 14 15 16 17 18 | ** This module contains C code that generates VDBE code used to process ** the WHERE clause of SQL statements. This module is reponsible for ** generating the code that loops through a table looking for applicable ** rows. Indices are selected and used to speed the search when doing ** so is applicable. Because this module is responsible for selecting ** indices, you might also think of this module as the "query optimizer". ** | | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ** This module contains C code that generates VDBE code used to process ** the WHERE clause of SQL statements. This module is reponsible for ** generating the code that loops through a table looking for applicable ** rows. Indices are selected and used to speed the search when doing ** so is applicable. Because this module is responsible for selecting ** indices, you might also think of this module as the "query optimizer". ** ** $Id: where.c,v 1.257 2007/08/16 11:36:15 danielk1977 Exp $ */ #include "sqliteInt.h" /* ** The number of bits in a Bitmask. "BMS" means "BitMask Size". */ #define BMS (sizeof(Bitmask)*8) |
︙ | ︙ | |||
1256 1257 1258 1259 1260 1261 1262 | if( i==pOrderBy->nExpr ){ nOrderBy = pOrderBy->nExpr; } } /* Allocate the sqlite3_index_info structure */ | | | 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 | if( i==pOrderBy->nExpr ){ nOrderBy = pOrderBy->nExpr; } } /* Allocate the sqlite3_index_info structure */ pIdxInfo = sqlite3MallocZero( sizeof(*pIdxInfo) + (sizeof(*pIdxCons) + sizeof(*pUsage))*nTerm + sizeof(*pIdxOrderBy)*nOrderBy ); if( pIdxInfo==0 ){ pParse->db->mallocFailed = 1; sqlite3ErrorMsg(pParse, "out of memory"); return 0.0; } |
︙ | ︙ |