Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add xUpdate method to the echo test module. Currently untested. (CVS 3246) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
676de55b28f0b22cf78f5e71f4a960f3 |
User & Date: | danielk1977 2006-06-14 15:16:36.000 |
Context
2006-06-14
| ||
15:35 | Better documentation on the limits of user-defined functions. And a marginally better error message when those limits are exceeded. Ticket #1847. (CVS 3247) (check-in: 0d369ff071 user: drh tags: trunk) | |
15:16 | Add xUpdate method to the echo test module. Currently untested. (CVS 3246) (check-in: 676de55b28 user: danielk1977 tags: trunk) | |
15:14 | Fix segfault introduced in (3243). (CVS 3245) (check-in: e5fff87d00 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 | ** 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.17 2006/06/14 15:16:36 danielk1977 Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include "os.h" #include <stdlib.h> #include <string.h> |
︙ | ︙ | |||
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 | pIdxInfo->idxNum = hashString(zQuery); pIdxInfo->idxStr = zQuery; pIdxInfo->needToFreeIdxStr = 1; pIdxInfo->estimatedCost = 1.0; return SQLITE_OK; } /* ** A virtual table module that merely echos method calls into TCL ** variables. */ static sqlite3_module echoModule = { 0, /* iVersion */ "echo", /* zName */ 0, /* pAux */ echoCreate, echoConnect, echoBestIndex, echoDisconnect, echoDestroy, echoOpen, /* xOpen - open a cursor */ echoClose, /* xClose - close a cursor */ echoFilter, /* xFilter - configure scan constraints */ echoNext, /* xNext - advance a cursor */ echoColumn, /* xColumn - read data */ | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > | 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 505 506 507 508 509 510 511 512 513 514 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 | pIdxInfo->idxNum = hashString(zQuery); pIdxInfo->idxStr = zQuery; pIdxInfo->needToFreeIdxStr = 1; pIdxInfo->estimatedCost = 1.0; return SQLITE_OK; } int echoUpdate(sqlite3_vtab *tab, int nData, sqlite3_value **apData){ echo_vtab *pVtab = (echo_vtab *)tab; sqlite3 *db = pVtab->db; int rc = SQLITE_OK; assert( nData==pVtab->nCol+2 || nData==1 ); /* If apData[0] is an integer, delete the identified row */ if( sqlite3_value_type(apData[0])==SQLITE_INTEGER ){ const char *zFormat = "DELETE FROM %Q WHERE rowid = ?"; char *zDelete = sqlite3_mprintf(zFormat, pVtab->zTableName); if( !zDelete ){ rc = SQLITE_NOMEM; }else{ sqlite3_stmt *pStmt = 0; rc = sqlite3_prepare(db, zDelete, -1, &pStmt, 0); assert( rc!=SQLITE_OK || pStmt ); if( rc==SQLITE_OK ){ sqlite3_step(pStmt); rc = sqlite3_finalize(pStmt); } } } /* If there is more than a single argument, INSERT a new row */ if( rc==SQLITE_OK && nData>1 ){ int ii; char *zInsert = 0; char *zValues = 0; char *zQuery = 0; const char *zTab = pVtab->zTableName; zInsert = sqlite3_mprintf("INSERT OR REPLACE INTO %Q (rowid", zTab); zValues = sqlite3_mprintf("?"); for(ii=0; ii<pVtab->nCol && zInsert && zValues; ii++){ char *zNew = sqlite3_mprintf("%s, %Q", zInsert, pVtab->aCol[ii]); sqliteFree(zInsert); zInsert = zNew; zNew = sqlite3_mprintf("%s, ?", zValues); sqliteFree(zValues); zValues = zNew; } if( zInsert && zValues ){ zQuery = sqlite3_mprintf("%s) VALUES(%s)", zInsert, zValues); } if( zQuery ){ sqlite3_stmt *pStmt = 0; rc = sqlite3_prepare(db, zQuery, -1, &pStmt, 0); for(ii=1; rc==SQLITE_OK && ii<nData; ii++){ rc = sqlite3_bind_value(pStmt, ii, apData[ii]); } if( rc==SQLITE_OK ){ sqlite3_step(pStmt); rc = sqlite3_finalize(pStmt); }else{ sqlite3_finalize(pStmt); } } sqliteFree(zValues); sqliteFree(zInsert); sqliteFree(zQuery); if( rc==SQLITE_OK && (!zValues || !zInsert || !zQuery) ){ rc = SQLITE_NOMEM; } } return rc; } /* ** A virtual table module that merely echos method calls into TCL ** variables. */ static sqlite3_module echoModule = { 0, /* iVersion */ "echo", /* zName */ 0, /* pAux */ echoCreate, echoConnect, echoBestIndex, echoDisconnect, echoDestroy, echoOpen, /* xOpen - open a cursor */ echoClose, /* xClose - close a cursor */ echoFilter, /* xFilter - configure scan constraints */ echoNext, /* xNext - advance a cursor */ echoColumn, /* xColumn - read data */ echoRowid, /* xRowid - read data */ echoUpdate /* xUpdate - write data */ }; /* ** Decode a pointer to an sqlite3 object. */ static int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb){ *ppDb = (sqlite3*)sqlite3TextToPtr(zA); |
︙ | ︙ |
Changes to src/vdbeapi.c.
︙ | ︙ | |||
707 708 709 710 711 712 713 714 715 716 717 718 719 720 | const void *zData, int nData, void (*xDel)(void*) ){ return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF16NATIVE); } #endif /* SQLITE_OMIT_UTF16 */ /* ** Return the number of wildcards that can be potentially bound to. ** This routine is added to support DBD::SQLite. */ int sqlite3_bind_parameter_count(sqlite3_stmt *pStmt){ Vdbe *p = (Vdbe*)pStmt; | > > > > > > > > > | 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 | const void *zData, int nData, void (*xDel)(void*) ){ return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF16NATIVE); } #endif /* SQLITE_OMIT_UTF16 */ int sqlite3_bind_value(sqlite3_stmt *pStmt, int i, const sqlite3_value *pValue){ int rc; Vdbe *p = (Vdbe *)pStmt; rc = vdbeUnbind(p, i); if( rc==SQLITE_OK ){ sqlite3VdbeMemCopy(&p->aVar[i-1], pValue); } return rc; } /* ** Return the number of wildcards that can be potentially bound to. ** This routine is added to support DBD::SQLite. */ int sqlite3_bind_parameter_count(sqlite3_stmt *pStmt){ Vdbe *p = (Vdbe*)pStmt; |
︙ | ︙ |