** This function is the implementation of both the xConnect and xCreate ** methods of the r-tree virtual table. ** ** argv[0] -> module name ** argv[1] -> database name ** argv[2] -> table name ** argv[...] -> column names... */
| 10610 | ** argv[...] -> column names... |
| 10611 | */ |
| 10612 | static int expertConnect( |
| 10613 | sqlite3 *db, |
| 10614 | void *pAux, |
| 10615 | int argc, const char *const*argv, |
| 10616 | sqlite3_vtab **ppVtab, |
| 10617 | char **pzErr |
| 10618 | ){ |
| 10619 | sqlite3expert *pExpert = (sqlite3expert*)pAux; |
| 10620 | ExpertVtab *p = 0; |
| 10621 | int rc; |
| 10622 | |
| 10623 | if( argc!=4 ){ |
| 10624 | *pzErr = sqlite3_mprintf("internal error!"); |
| 10625 | rc = SQLITE_ERROR; |
| 10626 | }else{ |
| 10627 | char *zCreateTable = expertDequote(argv[3]); |
| 10628 | if( zCreateTable ){ |
| 10629 | rc = sqlite3_declare_vtab(db, zCreateTable); |
| 10630 | if( rc==SQLITE_OK ){ |
| 10631 | p = idxMalloc(&rc, sizeof(ExpertVtab)); |
| 10632 | } |
| 10633 | if( rc==SQLITE_OK ){ |
| 10634 | p->pExpert = pExpert; |
| 10635 | p->pTab = pExpert->pTable; |
| 10636 | assert( sqlite3_stricmp(p->pTab->zName, argv[2])==0 ); |
| 10637 | } |
| 10638 | sqlite3_free(zCreateTable); |
| 10639 | }else{ |
| 10640 | rc = SQLITE_NOMEM; |
| 10641 | } |
| 10642 | } |
| 10643 | |
| 10644 | *ppVtab = (sqlite3_vtab*)p; |
| 10645 | return rc; |
| 10646 | } |
| 10647 | |
| 10648 | static int expertDisconnect(sqlite3_vtab *pVtab){ |
| 10649 | ExpertVtab *p = (ExpertVtab*)pVtab; |
nothing calls this directly
no test coverage detected