** 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... */
| 8767 | ** argv[...] -> column names... |
| 8768 | */ |
| 8769 | static int expertConnect( |
| 8770 | sqlite3 *db, |
| 8771 | void *pAux, |
| 8772 | int argc, const char *const*argv, |
| 8773 | sqlite3_vtab **ppVtab, |
| 8774 | char **pzErr |
| 8775 | ){ |
| 8776 | sqlite3expert *pExpert = (sqlite3expert*)pAux; |
| 8777 | ExpertVtab *p = 0; |
| 8778 | int rc; |
| 8779 | |
| 8780 | if( argc!=4 ){ |
| 8781 | *pzErr = sqlite3_mprintf("internal error!"); |
| 8782 | rc = SQLITE_ERROR; |
| 8783 | }else{ |
| 8784 | char *zCreateTable = expertDequote(argv[3]); |
| 8785 | if( zCreateTable ){ |
| 8786 | rc = sqlite3_declare_vtab(db, zCreateTable); |
| 8787 | if( rc==SQLITE_OK ){ |
| 8788 | p = idxMalloc(&rc, sizeof(ExpertVtab)); |
| 8789 | } |
| 8790 | if( rc==SQLITE_OK ){ |
| 8791 | p->pExpert = pExpert; |
| 8792 | p->pTab = pExpert->pTable; |
| 8793 | assert( sqlite3_stricmp(p->pTab->zName, argv[2])==0 ); |
| 8794 | } |
| 8795 | sqlite3_free(zCreateTable); |
| 8796 | }else{ |
| 8797 | rc = SQLITE_NOMEM; |
| 8798 | } |
| 8799 | } |
| 8800 | |
| 8801 | *ppVtab = (sqlite3_vtab*)p; |
| 8802 | return rc; |
| 8803 | } |
| 8804 | |
| 8805 | static int expertDisconnect(sqlite3_vtab *pVtab){ |
| 8806 | ExpertVtab *p = (ExpertVtab*)pVtab; |
nothing calls this directly
no test coverage detected