Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Clean up and clarify code in test8.c. (CVS 3289) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
4acf7594a6c47142e7112d2cd9766a56 |
User & Date: | danielk1977 2006-06-24 06:36:11.000 |
Context
2006-06-24
| ||
08:51 | Ensure whitespace specified as part of a virtual table constructor argument is correctly passed to the constructor function. (CVS 3290) (check-in: 4630e11d9a user: danielk1977 tags: trunk) | |
06:36 | Clean up and clarify code in test8.c. (CVS 3289) (check-in: 4acf7594a6 user: danielk1977 tags: trunk) | |
2006-06-23
| ||
14:43 | Modify the test cases in tkt1444.test that were failing. I am convinced that the test cases were incorrect. (CVS 3288) (check-in: 0534f6e15b user: danielk1977 tags: trunk) | |
Changes
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 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 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 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 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 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | ** 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.35 2006/06/24 06:36:11 danielk1977 Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include "os.h" #include <stdlib.h> #include <string.h> #ifndef SQLITE_OMIT_VIRTUALTABLE typedef struct echo_vtab echo_vtab; typedef struct echo_cursor echo_cursor; /* ** The test module defined in this file uses two global Tcl variables to ** commicate with test-scripts: ** ** $::echo_module ** $::echo_module_sync_fail ** ** The variable ::echo_module is a list. Each time one of the following ** methods is called, one or more elements are appended to the list. ** This is used for automated testing of virtual table modules. ** ** The ::echo_module_sync_fail variable is set by test scripts and read ** by code in this file. If it is set to the name of a real table in the ** the database, then all xSync operations on echo virtual tables that ** use the named table as a backing store will fail. */ /* ** An echo virtual-table object. ** ** echo.vtab.aIndex is an array of booleans. The nth entry is true if ** the nth column of the real table is the left-most column of an index ** (implicit or otherwise). In other words, if SQLite can optimize ** a query like "SELECT * FROM real_table WHERE col = ?". ** ** Member variable aCol[] contains copies of the column names of the real ** table. */ struct echo_vtab { sqlite3_vtab base; Tcl_Interp *interp; /* Tcl interpreter containing debug variables */ sqlite3 *db; /* Database connection */ char *zTableName; /* Name of the real table */ char *zLogName; /* Name of the log table */ int nCol; /* Number of columns in the real table */ int *aIndex; /* Array of size nCol. True if column has an index */ char **aCol; /* Array of size nCol. Column names */ }; /* An echo cursor object */ struct echo_cursor { sqlite3_vtab_cursor base; sqlite3_stmt *pStmt; }; /* ** Retrieve the column names for the table named zTab via database ** connection db. SQLITE_OK is returned on success, or an sqlite error ** code otherwise. ** ** If successful, the number of columns is written to *pnCol. *paCol is ** set to point at sqliteMalloc()'d space containing the array of ** nCol column names. The caller is responsible for calling sqliteFree ** on *paCol. */ static int getColumnNames( sqlite3 *db, const char *zTab, char ***paCol, int *pnCol ){ char **aCol = 0; char *zSql; sqlite3_stmt *pStmt = 0; int rc = SQLITE_OK; int nCol = 0; /* Prepare the statement "SELECT * FROM <tbl>". The column names ** of the result set of the compiled SELECT will be the same as ** the column names of table <tbl>. */ zSql = sqlite3MPrintf("SELECT * FROM %Q", zTab); if( !zSql ){ rc = SQLITE_NOMEM; goto out; } rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0); sqliteFree(zSql); if( rc==SQLITE_OK ){ int ii; int nBytes; char *zSpace; nCol = sqlite3_column_count(pStmt); /* 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 **)sqliteMalloc(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. */ zSpace = (char *)(&aCol[nCol]); for(ii=0; ii<nCol; ii++){ aCol[ii] = zSpace; zSpace += sprintf(zSpace, "%s", sqlite3_column_name(pStmt, ii)); zSpace++; } assert( (zSpace-nBytes)==(char *)aCol ); } *paCol = aCol; *pnCol = nCol; out: sqlite3_finalize(pStmt); return rc; } /* ** Parameter zTab is the name of a table in database db with nCol ** columns. This function allocates an array of integers nCol in ** size and populates it according to any implicit or explicit ** indices on table zTab. ** ** If successful, SQLITE_OK is returned and *paIndex set to point ** at the allocated array. Otherwise, an error code is returned. ** ** See comments associated with the member variable aIndex above ** "struct echo_vtab" for details of the contents of the array. */ static int getIndexArray( sqlite3 *db, /* Database connection */ const char *zTab, /* Name of table in database db */ int nCol, int **paIndex ){ sqlite3_stmt *pStmt = 0; int *aIndex = 0; int rc; char *zSql; /* Allocate space for the index array */ aIndex = (int *)sqliteMalloc(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("PRAGMA index_list(%s)", zTab); if( !zSql ){ rc = SQLITE_NOMEM; goto get_index_array_out; } rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0); sqliteFree(zSql); /* For each index, figure out the left-most column and set the ** corresponding entry in aIndex[] to 1. */ while( pStmt && sqlite3_step(pStmt)==SQLITE_ROW ){ const char *zIdx = sqlite3_column_text(pStmt, 1); sqlite3_stmt *pStmt2 = 0; zSql = sqlite3MPrintf("PRAGMA index_info(%s)", zIdx); if( !zSql ){ rc = SQLITE_NOMEM; goto get_index_array_out; } rc = sqlite3_prepare(db, zSql, -1, &pStmt2, 0); sqliteFree(zSql); if( pStmt2 && sqlite3_step(pStmt2)==SQLITE_ROW ){ int cid = sqlite3_column_int(pStmt2, 1); assert( cid>=0 && cid<nCol ); aIndex[cid] = 1; } if( pStmt2 ){ rc = sqlite3_finalize(pStmt2); } if( rc!=SQLITE_OK ){ goto get_index_array_out; } } get_index_array_out: if( pStmt ){ int rc2 = sqlite3_finalize(pStmt); if( rc==SQLITE_OK ){ rc = rc2; } } if( rc!=SQLITE_OK ){ sqliteFree(aIndex); aIndex = 0; } *paIndex = aIndex; return rc; } |
︙ | ︙ | |||
203 204 205 206 207 208 209 | sqlite3_stmt *pStmt = 0; sqlite3_prepare(db, "SELECT sql FROM sqlite_master WHERE type = 'table' AND name = ?", -1, &pStmt, 0); sqlite3_bind_text(pStmt, 1, argv[3], -1, 0); if( sqlite3_step(pStmt)==SQLITE_ROW ){ const char *zCreateTable = sqlite3_column_text(pStmt, 0); | < < | | > > > > < < < < > > > > > > > > > > > > > > > | > | > > > > > > > > > > | > > > > > > > > > > > | > | > > > > > > > > > < > > > < < < > > > | 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 | sqlite3_stmt *pStmt = 0; sqlite3_prepare(db, "SELECT sql FROM sqlite_master WHERE type = 'table' AND name = ?", -1, &pStmt, 0); sqlite3_bind_text(pStmt, 1, argv[3], -1, 0); if( sqlite3_step(pStmt)==SQLITE_ROW ){ const char *zCreateTable = sqlite3_column_text(pStmt, 0); sqlite3_declare_vtab(db, zCreateTable); rc = sqlite3_finalize(pStmt); } else { rc = sqlite3_finalize(pStmt); if( rc==SQLITE_OK ){ rc = SQLITE_ERROR; } } if( rc==SQLITE_OK ){ rc = getColumnNames(db, argv[3], &pVtab->aCol, &pVtab->nCol); } if( rc==SQLITE_OK ){ rc = getIndexArray(db, argv[3], pVtab->nCol, &pVtab->aIndex); } } return rc; } /* ** This function frees all runtime structures associated with the virtual ** table pVtab. */ static int echoDestructor(sqlite3_vtab *pVtab){ echo_vtab *p = (echo_vtab*)pVtab; sqliteFree(p->aIndex); sqliteFree(p->aCol); sqliteFree(p->zTableName); sqliteFree(p->zLogName); sqliteFree(p); return 0; } /* ** This function is called to do the work of the xConnect() method - ** to allocate the required in-memory structures for a newly connected ** virtual table. */ static int echoConstructor( sqlite3 *db, void *pAux, int argc, char **argv, sqlite3_vtab **ppVtab ){ int i; echo_vtab *pVtab; /* Allocate the sqlite3_vtab/echo_vtab structure itself */ pVtab = sqliteMalloc( sizeof(*pVtab) ); if( !pVtab ){ return SQLITE_NOMEM; } pVtab->interp = (Tcl_Interp *)pAux; pVtab->db = db; /* Allocate echo_vtab.zTableName */ pVtab->zTableName = sqlite3MPrintf("%s", argv[3]); if( !pVtab->zTableName ){ echoDestructor((sqlite3_vtab *)pVtab); return SQLITE_NOMEM; } /* Log the arguments to this function to Tcl var ::echo_module */ for(i=0; i<argc; i++){ appendToEchoModule(pVtab->interp, argv[i]); } /* Invoke sqlite3_declare_vtab and set up other members of the echo_vtab ** structure. If an error occurs, delete the sqlite3_vtab structure and ** return an error code. */ if( echoDeclareVtab(pVtab, db, argc, argv) ){ echoDestructor((sqlite3_vtab *)pVtab); return SQLITE_ERROR; } /* Success. Set *ppVtab and return */ *ppVtab = &pVtab->base; return SQLITE_OK; } /* ** Echo virtual table module xCreate method. */ static int echoCreate( sqlite3 *db, void *pAux, int argc, char **argv, sqlite3_vtab **ppVtab ){ int rc = SQLITE_OK; appendToEchoModule((Tcl_Interp *)(pAux), "xCreate"); rc = echoConstructor(db, pAux, argc, argv, ppVtab); /* If there were two arguments passed to the module at the SQL level ** (i.e. "CREATE VIRTUAL TABLE tbl USING echo(arg1, arg2)"), then ** the second argument is used as a table name. Attempt to create ** such a table with a single column, "logmsg". This table will ** be used to log calls to the xUpdate method. It will be deleted ** when the virtual table is DROPed. ** ** Note: The main point of this is to test that we can drop tables ** from within an xDestroy method call. */ if( rc==SQLITE_OK && argc==5 ){ char *zSql; echo_vtab *pVtab = *(echo_vtab **)ppVtab; pVtab->zLogName = sqlite3MPrintf("%s", argv[4]); zSql = sqlite3MPrintf("CREATE TABLE %Q(logmsg)", pVtab->zLogName); rc = sqlite3_exec(db, zSql, 0, 0, 0); sqliteFree(zSql); } return rc; } /* ** Echo virtual table module xConnect method. */ static int echoConnect( sqlite3 *db, void *pAux, int argc, char **argv, sqlite3_vtab **ppVtab ){ appendToEchoModule((Tcl_Interp *)(pAux), "xConnect"); return echoConstructor(db, pAux, argc, argv, ppVtab); } /* ** Echo virtual table module xDisconnect method. */ static int echoDisconnect(sqlite3_vtab *pVtab){ appendToEchoModule(((echo_vtab *)pVtab)->interp, "xDisconnect"); return echoDestructor(pVtab); } /* ** Echo virtual table module xDestroy method. */ static int echoDestroy(sqlite3_vtab *pVtab){ int rc = SQLITE_OK; echo_vtab *p = (echo_vtab *)pVtab; appendToEchoModule(((echo_vtab *)pVtab)->interp, "xDestroy"); /* Drop the "log" table, if one exists (see echoCreate() for details) */ if( p && p->zLogName ){ char *zSql; zSql = sqlite3MPrintf("DROP TABLE %Q", p->zLogName); rc = sqlite3_exec(p->db, zSql, 0, 0, 0); sqliteFree(zSql); } if( rc==SQLITE_OK ){ rc = echoDestructor(pVtab); } return rc; } /* ** Echo virtual table module xOpen method. */ static int echoOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){ echo_cursor *pCur; pCur = sqliteMalloc(sizeof(echo_cursor)); *ppCursor = (sqlite3_vtab_cursor *)pCur; return (pCur ? SQLITE_OK : SQLITE_NOMEM); } /* ** Echo virtual table module xClose method. */ static int echoClose(sqlite3_vtab_cursor *cur){ int rc; echo_cursor *pCur = (echo_cursor *)cur; sqlite3_stmt *pStmt = pCur->pStmt; pCur->pStmt = 0; sqliteFree(pCur); rc = sqlite3_finalize(pStmt); return rc; } /* ** Return non-zero if the cursor does not currently point to a valid record ** (i.e if the scan has finished), or zero otherwise. */ static int echoEof(sqlite3_vtab_cursor *cur){ return (((echo_cursor *)cur)->pStmt ? 0 : 1); } /* ** Echo virtual table module xNext method. */ static int echoNext(sqlite3_vtab_cursor *cur){ int rc; echo_cursor *pCur = (echo_cursor *)cur; 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. */ static int echoColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){ int iCol = i + 1; sqlite3_stmt *pStmt = ((echo_cursor *)cur)->pStmt; if( !pStmt ){ sqlite3_result_null(ctx); }else{ assert( sqlite3_data_count(pStmt)>iCol ); sqlite3_result_value(ctx, sqlite3_column_value(pStmt, iCol)); } return SQLITE_OK; } /* ** Echo virtual table module xRowid method. */ static int echoRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){ sqlite3_stmt *pStmt = ((echo_cursor *)cur)->pStmt; *pRowid = sqlite3_column_int64(pStmt, 0); return SQLITE_OK; } /* |
︙ | ︙ | |||
407 408 409 410 411 412 413 | int ii; for(ii=0; zString[ii]; ii++){ val = (val << 3) + (int)zString[ii]; } return val; } | | > > > > > > < > > > > < < < < < < < < < < | < | < < < < | < < < < < < < > < < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 515 516 517 518 519 520 521 522 523 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 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 | int ii; for(ii=0; zString[ii]; ii++){ val = (val << 3) + (int)zString[ii]; } return val; } /* ** Echo virtual table module xFilter method. */ static int echoFilter( sqlite3_vtab_cursor *pVtabCursor, int idxNum, const char *idxStr, int argc, sqlite3_value **argv ){ int rc; int i; echo_cursor *pCur = (echo_cursor *)pVtabCursor; echo_vtab *pVtab = (echo_vtab *)pVtabCursor->pVtab; sqlite3 *db = pVtab->db; /* Check that idxNum matches idxStr */ assert( idxNum==hashString(idxStr) ); /* Log arguments to the ::echo_module Tcl variable */ appendToEchoModule(pVtab->interp, "xFilter"); appendToEchoModule(pVtab->interp, idxStr); for(i=0; i<argc; i++){ appendToEchoModule(pVtab->interp, sqlite3_value_text(argv[i])); } sqlite3_finalize(pCur->pStmt); pCur->pStmt = 0; /* Prepare the SQL statement created by echoBestIndex and bind the ** runtime parameters passed to this function to it. */ rc = sqlite3_prepare(db, idxStr, -1, &pCur->pStmt, 0); assert( pCur->pStmt || rc!=SQLITE_OK ); for(i=0; rc==SQLITE_OK && i<argc; i++){ sqlite3_bind_value(pCur->pStmt, i+1, argv[i]); } /* If everything was successful, advance to the first row of the scan */ if( rc==SQLITE_OK ){ rc = echoNext(pVtabCursor); } return rc; } /* ** A helper function used by echoUpdate() and echoBestIndex() for ** manipulating strings in concert with the sqlite3_mprintf() function. ** ** Parameter pzStr points to a pointer to a string allocated with ** sqlite3_mprintf. The second parameter, zAppend, points to another ** string. The two strings are concatenated together and *pzStr ** set to point at the result. The initial buffer pointed to by *pzStr ** is deallocated via sqlite3_free(). ** ** If the third argument, doFree, is true, then sqlite3_free() is ** also called to free the buffer pointed to by zAppend. */ static void string_concat(char **pzStr, char *zAppend, int doFree){ char *zIn = *pzStr; if( zIn ){ char *zTemp = zIn; zIn = sqlite3_mprintf("%s%s", zIn, zAppend); sqlite3_free(zTemp); }else{ zIn = sqlite3_mprintf("%s", zAppend); } *pzStr = zIn; if( doFree ){ sqlite3_free(zAppend); } } /* ** The echo module implements the subset of query constraints and sort ** orders that may take advantage of SQLite indices on the underlying ** real table. For example, if the real table is declared as: ** ** CREATE TABLE real(a, b, c); ** CREATE INDEX real_index ON real(b); ** ** then the echo module handles WHERE or ORDER BY clauses that refer ** to the column "b", but not "a" or "c". If a multi-column index is ** present, only it's left most column is considered. ** ** This xBestIndex method encodes the proposed search strategy as ** an SQL query on the real table underlying the virtual echo module ** table and stores the query in sqlite3_index_info.idxStr. The SQL ** statement is of the form: ** ** SELECT rowid, * FROM <real-table> ?<where-clause>? ?<order-by-clause>? ** ** where the <where-clause> and <order-by-clause> are determined ** by the contents of the structure pointed to by the pIdxInfo argument. */ static int echoBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ int ii; char *zQuery = 0; char *zNew; int nArg = 0; const char *zSep = "WHERE"; |
︙ | ︙ | |||
539 540 541 542 543 544 545 | zOp = "<="; break; case SQLITE_INDEX_CONSTRAINT_GE: zOp = ">="; break; case SQLITE_INDEX_CONSTRAINT_MATCH: zOp = "LIKE"; break; } if( zOp[0]=='L' ){ | | | | | | | < | | 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 | zOp = "<="; break; case SQLITE_INDEX_CONSTRAINT_GE: zOp = ">="; break; case SQLITE_INDEX_CONSTRAINT_MATCH: zOp = "LIKE"; break; } if( zOp[0]=='L' ){ zNew = sqlite3_mprintf(" %s %s LIKE (SELECT '%%'||?||'%%')", zSep, zCol); } else { zNew = sqlite3_mprintf(" %s %s %s ?", zSep, zCol, zOp); } string_concat(&zQuery, zNew, 1); zSep = "AND"; pUsage->argvIndex = ++nArg; pUsage->omit = 1; } } /* If there is only one term in the ORDER BY clause, and it is ** on a column that this virtual table has an index for, then consume ** the ORDER BY clause. */ if( pIdxInfo->nOrderBy==1 && pVtab->aIndex[pIdxInfo->aOrderBy->iColumn] ){ char *zCol = pVtab->aCol[pIdxInfo->aOrderBy->iColumn]; char *zDir = pIdxInfo->aOrderBy->desc?"DESC":"ASC"; zNew = sqlite3_mprintf(" ORDER BY %s %s", zCol, zDir); string_concat(&zQuery, zNew, 1); pIdxInfo->orderByConsumed = 1; } appendToEchoModule(pVtab->interp, "xBestIndex");; appendToEchoModule(pVtab->interp, zQuery); pIdxInfo->idxNum = hashString(zQuery); |
︙ | ︙ | |||
584 585 586 587 588 589 590 | } } else { pIdxInfo->estimatedCost = (double)nRow; } return rc; } | < < < < < < < < < < < < < < < > > | 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 | } } else { pIdxInfo->estimatedCost = (double)nRow; } return rc; } /* ** The xUpdate method for echo module virtual tables. ** ** apData[0] apData[1] apData[2..] ** ** INTEGER DELETE ** ** INTEGER NULL (nCol args) UPDATE (do not set rowid) ** INTEGER INTEGER (nCol args) UPDATE (with SET rowid = <arg1>) ** |
︙ | ︙ | |||
755 756 757 758 759 760 761 | return echoTransactionCall(tab, "xCommit"); } static int echoRollback(sqlite3_vtab *tab){ return echoTransactionCall(tab, "xRollback"); } /* | | | | 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 | return echoTransactionCall(tab, "xCommit"); } static int echoRollback(sqlite3_vtab *tab){ return echoTransactionCall(tab, "xRollback"); } /* ** A virtual table module that merely "echos" the contents of another ** table (like an SQL VIEW). */ static sqlite3_module echoModule = { 0, /* iVersion */ "echo", /* zName */ echoCreate, echoConnect, echoBestIndex, |
︙ | ︙ | |||
788 789 790 791 792 793 794 | ** Decode a pointer to an sqlite3 object. */ static int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb){ *ppDb = (sqlite3*)sqlite3TextToPtr(zA); return TCL_OK; } | < < < > > > | 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 | ** Decode a pointer to an sqlite3 object. */ static int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb){ *ppDb = (sqlite3*)sqlite3TextToPtr(zA); return TCL_OK; } /* ** Register the echo virtual table module. */ static int register_echo_module( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ Tcl_Obj *CONST objv[] /* Command arguments */ ){ sqlite3 *db; if( objc!=2 ){ Tcl_WrongNumArgs(interp, 1, objv, "DB"); return TCL_ERROR; } if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; sqlite3_create_module(db, "echo", &echoModule, (void *)interp); return TCL_OK; } #endif /* ifndef SQLITE_OMIT_VIRTUALTABLE */ /* ** Register commands with the TCL interpreter. */ int Sqlitetest8_Init(Tcl_Interp *interp){ static struct { char *zName; Tcl_ObjCmdProc *xProc; void *clientData; } aObjCmd[] = { #ifndef SQLITE_OMIT_VIRTUALTABLE { "register_echo_module", register_echo_module, 0 }, #endif }; int i; for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){ Tcl_CreateObjCommand(interp, aObjCmd[i].zName, aObjCmd[i].xProc, aObjCmd[i].clientData, 0); } return TCL_OK; } |
Changes to src/vdbeInt.h.
︙ | ︙ | |||
81 82 83 84 85 86 87 | i64 iKey; /* Key for the NEW or OLD pseudo-table row */ u8 *pIncrKey; /* Pointer to pKeyInfo->incrKey */ KeyInfo *pKeyInfo; /* Info about index keys needed by index cursors */ int nField; /* Number of fields in the header */ i64 seqCount; /* Sequence counter */ #ifndef SQLITE_OMIT_VIRTUALTABLE sqlite3_vtab_cursor *pVtabCursor; /* The cursor for a virtual table */ | | | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | i64 iKey; /* Key for the NEW or OLD pseudo-table row */ u8 *pIncrKey; /* Pointer to pKeyInfo->incrKey */ KeyInfo *pKeyInfo; /* Info about index keys needed by index cursors */ int nField; /* Number of fields in the header */ i64 seqCount; /* Sequence counter */ #ifndef SQLITE_OMIT_VIRTUALTABLE sqlite3_vtab_cursor *pVtabCursor; /* The cursor for a virtual table */ const sqlite3_module *pModule; /* Module for cursor pVtabCursor */ #endif /* Cached information about the header for the data record that the ** cursor is currently pointing to. Only valid if cacheValid is true. ** aRow might point to (ephemeral) data for the current row, or it might ** be NULL. */ |
︙ | ︙ |