MCPcopy Create free account
hub / github.com/GoogleChrome/samples / theModule

Function theModule

sqlite-wasm-cos/sqlite3.mjs:17977–18087  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17975 const dbg = 1 ? ()=>{} : (...args)=>debug("vtab",...args);
17976
17977 const theModule = function f(){
17978 return f.mod ??= new sqlite3.capi.sqlite3_module().setupModule({
17979 catchExceptions: true,
17980 methods: {
17981 xConnect: function(pDb, pAux, argc, argv, ppVtab, pzErr){
17982 dbg("xConnect");
17983 try{
17984 const xcol = [];
17985 Object.keys(cols).forEach((k)=>{
17986 xcol.push(k+" "+cols[k].type);
17987 });
17988 const rc = capi.sqlite3_declare_vtab(
17989 pDb, "CREATE TABLE ignored("+xcol.join(',')+")"
17990 );
17991 if(0===rc){
17992 const t = VT.xVtab.create(ppVtab);
17993 util.assert(
17994 (t === VT.xVtab.get(wasm.peekPtr(ppVtab))),
17995 "output pointer check failed"
17996 );
17997 }
17998 return rc;
17999 }catch(e){
18000 return VT.xError('xConnect', e, capi.SQLITE_ERROR);
18001 }
18002 },
18003 xCreate: wasm.ptr.null, // eponymous only
18004 //xCreate: true, // copy xConnect, i.e. also eponymous only
18005 xDisconnect: function(pVtab){
18006 dbg("xDisconnect",...arguments);
18007 VT.xVtab.dispose(pVtab);
18008 return 0;
18009 },
18010 xOpen: function(pVtab, ppCursor){
18011 dbg("xOpen",...arguments);
18012 VT.xCursor.create(ppCursor);
18013 return 0;
18014 },
18015 xClose: function(pCursor){
18016 dbg("xClose",...arguments);
18017 const c = VT.xCursor.unget(pCursor);
18018 delete c.vTabState;
18019 c.dispose();
18020 return 0;
18021 },
18022 xNext: function(pCursor){
18023 dbg("xNext",...arguments);
18024 const c = VT.xCursor.get(pCursor);
18025 ++cursorState(c).rowid;
18026 return 0;
18027 },
18028 xColumn: function(pCursor, pCtx, iCol){
18029 dbg("xColumn",...arguments);
18030 //const c = VT.xCursor.get(pCursor);
18031 const st = cursorState(pCursor);
18032 const store = st.row();
18033 util.assert(store, "Unexpected xColumn call");
18034 switch(iCol){

Callers 1

sqlite3InitModuleFunction · 0.70

Calls 4

dbgFunction · 0.85
cursorStateFunction · 0.70
storageGetDbSizeFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected