Lines Matching full:pdb

133   SqliteDb *pDb;        /* Database connection that owns this function */  member
216 SqliteDb *pDb; /* Associated database connection */ member
236 ** Close all incrblob channels opened using database connection pDb.
239 static void closeIncrblobChannels(SqliteDb *pDb){ in closeIncrblobChannels() argument
243 for(p=pDb->pIncrblob; p; p=pNext){ in closeIncrblobChannels()
250 Tcl_UnregisterChannel(pDb->interp, p->channel); in closeIncrblobChannels()
263 sqlite3 *db = p->pDb->db; in incrblobClose()
272 if( p->pDb->pIncrblob==p ){ in incrblobClose()
273 p->pDb->pIncrblob = p->pNext; in incrblobClose()
417 SqliteDb *pDb, in createIncrblobChannel() argument
425 sqlite3 *db = pDb->db; in createIncrblobChannel()
436 Tcl_SetResult(interp, (char *)sqlite3_errmsg(pDb->db), TCL_VOLATILE); in createIncrblobChannel()
449 p->pNext = pDb->pIncrblob; in createIncrblobChannel()
454 pDb->pIncrblob = p; in createIncrblobChannel()
455 p->pDb = pDb; in createIncrblobChannel()
461 #define closeIncrblobChannels(pDb) argument
496 static SqlFunc *findSqlFunc(SqliteDb *pDb, const char *zName){ in findSqlFunc() argument
502 for(p=pDb->pFunc; p; p=p->pNext){ in findSqlFunc()
508 pNew->interp = pDb->interp; in findSqlFunc()
509 pNew->pDb = pDb; in findSqlFunc()
511 pNew->pNext = pDb->pFunc; in findSqlFunc()
512 pDb->pFunc = pNew; in findSqlFunc()
532 static void flushStmtCache(SqliteDb *pDb){ in flushStmtCache() argument
536 for(pPreStmt = pDb->stmtList; pPreStmt; pPreStmt=pNext){ in flushStmtCache()
540 pDb->nStmt = 0; in flushStmtCache()
541 pDb->stmtLast = 0; in flushStmtCache()
542 pDb->stmtList = 0; in flushStmtCache()
549 static void addDatabaseRef(SqliteDb *pDb){ in addDatabaseRef() argument
550 pDb->nRef++; in addDatabaseRef()
557 static void delDatabaseRef(SqliteDb *pDb){ in delDatabaseRef() argument
558 assert( pDb->nRef>0 ); in delDatabaseRef()
559 pDb->nRef--; in delDatabaseRef()
560 if( pDb->nRef==0 ){ in delDatabaseRef()
561 flushStmtCache(pDb); in delDatabaseRef()
562 closeIncrblobChannels(pDb); in delDatabaseRef()
563 sqlite3_close(pDb->db); in delDatabaseRef()
564 while( pDb->pFunc ){ in delDatabaseRef()
565 SqlFunc *pFunc = pDb->pFunc; in delDatabaseRef()
566 pDb->pFunc = pFunc->pNext; in delDatabaseRef()
567 assert( pFunc->pDb==pDb ); in delDatabaseRef()
571 while( pDb->pCollate ){ in delDatabaseRef()
572 SqlCollate *pCollate = pDb->pCollate; in delDatabaseRef()
573 pDb->pCollate = pCollate->pNext; in delDatabaseRef()
576 if( pDb->zBusy ){ in delDatabaseRef()
577 Tcl_Free(pDb->zBusy); in delDatabaseRef()
579 if( pDb->zTrace ){ in delDatabaseRef()
580 Tcl_Free(pDb->zTrace); in delDatabaseRef()
582 if( pDb->zTraceV2 ){ in delDatabaseRef()
583 Tcl_Free(pDb->zTraceV2); in delDatabaseRef()
585 if( pDb->zProfile ){ in delDatabaseRef()
586 Tcl_Free(pDb->zProfile); in delDatabaseRef()
588 if( pDb->zBindFallback ){ in delDatabaseRef()
589 Tcl_Free(pDb->zBindFallback); in delDatabaseRef()
591 if( pDb->zAuth ){ in delDatabaseRef()
592 Tcl_Free(pDb->zAuth); in delDatabaseRef()
594 if( pDb->zNull ){ in delDatabaseRef()
595 Tcl_Free(pDb->zNull); in delDatabaseRef()
597 if( pDb->pUpdateHook ){ in delDatabaseRef()
598 Tcl_DecrRefCount(pDb->pUpdateHook); in delDatabaseRef()
600 if( pDb->pPreUpdateHook ){ in delDatabaseRef()
601 Tcl_DecrRefCount(pDb->pPreUpdateHook); in delDatabaseRef()
603 if( pDb->pRollbackHook ){ in delDatabaseRef()
604 Tcl_DecrRefCount(pDb->pRollbackHook); in delDatabaseRef()
606 if( pDb->pWalHook ){ in delDatabaseRef()
607 Tcl_DecrRefCount(pDb->pWalHook); in delDatabaseRef()
609 if( pDb->pCollateNeeded ){ in delDatabaseRef()
610 Tcl_DecrRefCount(pDb->pCollateNeeded); in delDatabaseRef()
612 Tcl_Free((char*)pDb); in delDatabaseRef()
621 SqliteDb *pDb = (SqliteDb*)db; in DbDeleteCmd() local
622 delDatabaseRef(pDb); in DbDeleteCmd()
630 SqliteDb *pDb = (SqliteDb*)cd; in DbBusyHandler() local
635 rc = Tcl_VarEval(pDb->interp, pDb->zBusy, " ", zVal, (char*)0); in DbBusyHandler()
636 if( rc!=TCL_OK || atoi(Tcl_GetStringResult(pDb->interp)) ){ in DbBusyHandler()
647 SqliteDb *pDb = (SqliteDb*)cd; in DbProgressHandler() local
650 assert( pDb->zProgress ); in DbProgressHandler()
651 rc = Tcl_Eval(pDb->interp, pDb->zProgress); in DbProgressHandler()
652 if( rc!=TCL_OK || atoi(Tcl_GetStringResult(pDb->interp)) ){ in DbProgressHandler()
663 ** block of SQL is executed. The TCL script in pDb->zTrace is executed.
666 SqliteDb *pDb = (SqliteDb*)cd; in DbTraceHandler() local
670 Tcl_DStringAppend(&str, pDb->zTrace, -1); in DbTraceHandler()
672 Tcl_Eval(pDb->interp, Tcl_DStringValue(&str)); in DbTraceHandler()
674 Tcl_ResetResult(pDb->interp); in DbTraceHandler()
682 ** The TCL script in pDb->zTraceV2 is executed, with the arguments for
691 SqliteDb *pDb = (SqliteDb*)cd; in DbTraceV2Handler() local
699 pCmd = Tcl_NewStringObj(pDb->zTraceV2, -1); in DbTraceV2Handler()
701 Tcl_ListObjAppendElement(pDb->interp, pCmd, in DbTraceV2Handler()
703 Tcl_ListObjAppendElement(pDb->interp, pCmd, in DbTraceV2Handler()
705 Tcl_EvalObjEx(pDb->interp, pCmd, TCL_EVAL_DIRECT); in DbTraceV2Handler()
707 Tcl_ResetResult(pDb->interp); in DbTraceV2Handler()
714 pCmd = Tcl_NewStringObj(pDb->zTraceV2, -1); in DbTraceV2Handler()
716 Tcl_ListObjAppendElement(pDb->interp, pCmd, in DbTraceV2Handler()
718 Tcl_ListObjAppendElement(pDb->interp, pCmd, in DbTraceV2Handler()
720 Tcl_EvalObjEx(pDb->interp, pCmd, TCL_EVAL_DIRECT); in DbTraceV2Handler()
722 Tcl_ResetResult(pDb->interp); in DbTraceV2Handler()
728 pCmd = Tcl_NewStringObj(pDb->zTraceV2, -1); in DbTraceV2Handler()
730 Tcl_ListObjAppendElement(pDb->interp, pCmd, in DbTraceV2Handler()
732 Tcl_EvalObjEx(pDb->interp, pCmd, TCL_EVAL_DIRECT); in DbTraceV2Handler()
734 Tcl_ResetResult(pDb->interp); in DbTraceV2Handler()
740 pCmd = Tcl_NewStringObj(pDb->zTraceV2, -1); in DbTraceV2Handler()
742 Tcl_ListObjAppendElement(pDb->interp, pCmd, in DbTraceV2Handler()
744 Tcl_EvalObjEx(pDb->interp, pCmd, TCL_EVAL_DIRECT); in DbTraceV2Handler()
746 Tcl_ResetResult(pDb->interp); in DbTraceV2Handler()
758 ** SQL has executed. The TCL script in pDb->zProfile is evaluated.
761 SqliteDb *pDb = (SqliteDb*)cd; in DbProfileHandler() local
767 Tcl_DStringAppend(&str, pDb->zProfile, -1); in DbProfileHandler()
770 Tcl_Eval(pDb->interp, Tcl_DStringValue(&str)); in DbProfileHandler()
772 Tcl_ResetResult(pDb->interp); in DbProfileHandler()
778 ** TCL script in pDb->zCommit is executed. If it returns non-zero or
783 SqliteDb *pDb = (SqliteDb*)cd; in DbCommitHandler() local
786 rc = Tcl_Eval(pDb->interp, pDb->zCommit); in DbCommitHandler()
787 if( rc!=TCL_OK || atoi(Tcl_GetStringResult(pDb->interp)) ){ in DbCommitHandler()
794 SqliteDb *pDb = (SqliteDb*)clientData; in DbRollbackHandler() local
795 assert(pDb->pRollbackHook); in DbRollbackHandler()
796 if( TCL_OK!=Tcl_EvalObjEx(pDb->interp, pDb->pRollbackHook, 0) ){ in DbRollbackHandler()
797 Tcl_BackgroundError(pDb->interp); in DbRollbackHandler()
812 SqliteDb *pDb = (SqliteDb*)clientData; in DbWalHandler() local
813 Tcl_Interp *interp = pDb->interp; in DbWalHandler()
814 assert(pDb->pWalHook); in DbWalHandler()
816 assert( db==pDb->db ); in DbWalHandler()
817 p = Tcl_DuplicateObj(pDb->pWalHook); in DbWalHandler()
848 SqliteDb *pDb = (SqliteDb *)apArg[i]; in DbUnlockNotify() local
849 setTestUnlockNotifyVars(pDb->interp, i, nArg); in DbUnlockNotify()
850 assert( pDb->pUnlockNotify); in DbUnlockNotify()
851 Tcl_EvalObjEx(pDb->interp, pDb->pUnlockNotify, flags); in DbUnlockNotify()
852 Tcl_DecrRefCount(pDb->pUnlockNotify); in DbUnlockNotify()
853 pDb->pUnlockNotify = 0; in DbUnlockNotify()
871 SqliteDb *pDb = (SqliteDb *)p; in DbPreUpdateHandler() local
878 assert( pDb->pPreUpdateHook ); in DbPreUpdateHandler()
879 assert( db==pDb->db ); in DbPreUpdateHandler()
882 pCmd = Tcl_DuplicateObj(pDb->pPreUpdateHook); in DbPreUpdateHandler()
889 Tcl_EvalObjEx(pDb->interp, pCmd, TCL_EVAL_DIRECT); in DbPreUpdateHandler()
901 SqliteDb *pDb = (SqliteDb *)p; in DbUpdateHandler() local
909 assert( pDb->pUpdateHook ); in DbUpdateHandler()
912 pCmd = Tcl_DuplicateObj(pDb->pUpdateHook); in DbUpdateHandler()
918 Tcl_EvalObjEx(pDb->interp, pCmd, TCL_EVAL_DIRECT); in DbUpdateHandler()
928 SqliteDb *pDb = (SqliteDb *)pCtx; in tclCollateNeeded() local
929 Tcl_Obj *pScript = Tcl_DuplicateObj(pDb->pCollateNeeded); in tclCollateNeeded()
932 Tcl_EvalObjEx(pDb->interp, pScript, 0); in tclCollateNeeded()
1022 pVal = Tcl_NewStringObj(p->pDb->zNull, -1); in tclSqlFunc()
1133 SqliteDb *pDb = (SqliteDb*)pArg; in auth_callback() local
1134 if( pDb->disableAuth ) return SQLITE_OK; in auth_callback()
1177 Tcl_DStringAppend(&str, pDb->zAuth, -1); in auth_callback()
1186 rc = Tcl_GlobalEval(pDb->interp, Tcl_DStringValue(&str)); in auth_callback()
1188 zReply = rc==TCL_OK ? Tcl_GetStringResult(pDb->interp) : "SQLITE_DENY"; in auth_callback()
1267 SqliteDb *pDb = (SqliteDb*)data[0]; in DbTransPostCmd() local
1271 pDb->nTransaction--; in DbTransPostCmd()
1272 zEnd = azEnd[(rc==TCL_ERROR)*2 + (pDb->nTransaction==0)]; in DbTransPostCmd()
1274 pDb->disableAuth++; in DbTransPostCmd()
1275 if( sqlite3_exec(pDb->db, zEnd, 0, 0, 0) ){ in DbTransPostCmd()
1287 Tcl_AppendResult(interp, sqlite3_errmsg(pDb->db), (char*)0); in DbTransPostCmd()
1290 sqlite3_exec(pDb->db, "ROLLBACK", 0, 0, 0); in DbTransPostCmd()
1292 pDb->disableAuth--; in DbTransPostCmd()
1294 delDatabaseRef(pDb); in DbTransPostCmd()
1306 SqliteDb *pDb, /* Database object */ in dbPrepare() argument
1313 if( pDb->bLegacyPrepare ){ in dbPrepare()
1314 return sqlite3_prepare(pDb->db, zSql, -1, ppStmt, pzOut); in dbPrepare()
1320 if( pDb->maxStmt>5 ) prepFlags = SQLITE_PREPARE_PERSISTENT; in dbPrepare()
1322 return sqlite3_prepare_v3(pDb->db, zSql, -1, prepFlags, ppStmt, pzOut); in dbPrepare()
1338 ** and an error message loaded into interpreter pDb->interp.
1341 SqliteDb *pDb, /* Database object */ in dbPrepareAndBind() argument
1356 Tcl_Interp *interp = pDb->interp; in dbPrepareAndBind()
1364 for(pPreStmt = pDb->stmtList; pPreStmt; pPreStmt=pPreStmt->pNext){ in dbPrepareAndBind()
1380 pDb->stmtList = pPreStmt->pNext; in dbPrepareAndBind()
1385 pDb->stmtLast = pPreStmt->pPrev; in dbPrepareAndBind()
1387 pDb->nStmt--; in dbPrepareAndBind()
1398 if( SQLITE_OK!=dbPrepare(pDb, zSql, &pStmt, pzOut) ){ in dbPrepareAndBind()
1399 Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3_errmsg(pDb->db), -1)); in dbPrepareAndBind()
1403 if( SQLITE_OK!=sqlite3_errcode(pDb->db) ){ in dbPrepareAndBind()
1405 Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3_errmsg(pDb->db), -1)); in dbPrepareAndBind()
1443 if( pVar==0 && pDb->zBindFallback!=0 ){ in dbPrepareAndBind()
1446 pCmd = Tcl_NewStringObj(pDb->zBindFallback, -1); in dbPrepareAndBind()
1497 if( needResultReset ) Tcl_ResetResult(pDb->interp); in dbPrepareAndBind()
1502 if( needResultReset && rc==TCL_OK ) Tcl_ResetResult(pDb->interp); in dbPrepareAndBind()
1517 SqliteDb *pDb, /* Database handle */ in dbReleaseStmt() argument
1529 if( pDb->maxStmt<=0 || discard ){ in dbReleaseStmt()
1534 pPreStmt->pNext = pDb->stmtList; in dbReleaseStmt()
1536 if( pDb->stmtList ){ in dbReleaseStmt()
1537 pDb->stmtList->pPrev = pPreStmt; in dbReleaseStmt()
1539 pDb->stmtList = pPreStmt; in dbReleaseStmt()
1540 if( pDb->stmtLast==0 ){ in dbReleaseStmt()
1541 assert( pDb->nStmt==0 ); in dbReleaseStmt()
1542 pDb->stmtLast = pPreStmt; in dbReleaseStmt()
1544 assert( pDb->nStmt>0 ); in dbReleaseStmt()
1546 pDb->nStmt++; in dbReleaseStmt()
1550 while( pDb->nStmt>pDb->maxStmt ){ in dbReleaseStmt()
1551 SqlPreparedStmt *pLast = pDb->stmtLast; in dbReleaseStmt()
1552 pDb->stmtLast = pLast->pPrev; in dbReleaseStmt()
1553 pDb->stmtLast->pNext = 0; in dbReleaseStmt()
1554 pDb->nStmt--; in dbReleaseStmt()
1571 SqliteDb *pDb; /* Database handle */ member
1613 SqliteDb *pDb, /* Database handle */ in dbEvalInit() argument
1619 p->pDb = pDb; in dbEvalInit()
1628 addDatabaseRef(p->pDb); in dbEvalInit()
1661 Tcl_Interp *interp = p->pDb->interp; in dbEvalRowInfo()
1700 rc = dbPrepareAndBind(p->pDb, p->zSql, &p->zSql, &p->pPreStmt); in dbEvalStep()
1704 SqliteDb *pDb = p->pDb; in dbEvalStep() local
1717 pDb->nStep = sqlite3_stmt_status(pStmt,SQLITE_STMTSTATUS_FULLSCAN_STEP,1); in dbEvalStep()
1718 pDb->nSort = sqlite3_stmt_status(pStmt,SQLITE_STMTSTATUS_SORT,1); in dbEvalStep()
1719 pDb->nIndex = sqlite3_stmt_status(pStmt,SQLITE_STMTSTATUS_AUTOINDEX,1); in dbEvalStep()
1720 pDb->nVMStep = sqlite3_stmt_status(pStmt,SQLITE_STMTSTATUS_VM_STEP,1); in dbEvalStep()
1727 dbReleaseStmt(pDb, pPreStmt, 1); in dbEvalStep()
1729 if( p->pDb->bLegacyPrepare && rcs==SQLITE_SCHEMA && zPrevSql ){ in dbEvalStep()
1739 Tcl_SetObjResult(pDb->interp, in dbEvalStep()
1740 Tcl_NewStringObj(sqlite3_errmsg(pDb->db), -1)); in dbEvalStep()
1743 dbReleaseStmt(pDb, pPreStmt, 0); in dbEvalStep()
1760 dbReleaseStmt(p->pDb, p->pPreStmt, 0); in dbEvalFinalize()
1769 delDatabaseRef(p->pDb); in dbEvalFinalize()
1798 return Tcl_NewStringObj(p->pDb->zNull, -1); in dbEvalColumnValue()
1913 SqliteDb *pDb, /* Database handle */ in DbHookCmd() argument
1917 sqlite3 *db = pDb->db; in DbHookCmd()
1935 sqlite3_preupdate_hook(db, (pDb->pPreUpdateHook?DbPreUpdateHandler:0), pDb); in DbHookCmd()
1937 sqlite3_update_hook(db, (pDb->pUpdateHook?DbUpdateHandler:0), pDb); in DbHookCmd()
1938 sqlite3_rollback_hook(db, (pDb->pRollbackHook?DbRollbackHandler:0), pDb); in DbHookCmd()
1939 sqlite3_wal_hook(db, (pDb->pWalHook?DbWalHandler:0), pDb); in DbHookCmd()
1961 SqliteDb *pDb = (SqliteDb*)cd; in DbObjCmd() local
2037 if( pDb->zAuth ){ in DbObjCmd()
2038 Tcl_AppendResult(interp, pDb->zAuth, (char*)0); in DbObjCmd()
2043 if( pDb->zAuth ){ in DbObjCmd()
2044 Tcl_Free(pDb->zAuth); in DbObjCmd()
2048 pDb->zAuth = Tcl_Alloc( len + 1 ); in DbObjCmd()
2049 memcpy(pDb->zAuth, zAuth, len+1); in DbObjCmd()
2051 pDb->zAuth = 0; in DbObjCmd()
2053 if( pDb->zAuth ){ in DbObjCmd()
2057 pDb->interp = interp; in DbObjCmd()
2058 sqlite3_set_authorizer(pDb->db,(sqlite3_auth_cb)auth_callback,pDb); in DbObjCmd()
2060 sqlite3_set_authorizer(pDb->db, 0, 0); in DbObjCmd()
2090 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE| pDb->openFlags, 0); in DbObjCmd()
2097 pBackup = sqlite3_backup_init(pDest, "main", pDb->db, zSrcDb); in DbObjCmd()
2140 if( pDb->zBindFallback ){ in DbObjCmd()
2141 Tcl_AppendResult(interp, pDb->zBindFallback, (char*)0); in DbObjCmd()
2146 if( pDb->zBindFallback ){ in DbObjCmd()
2147 Tcl_Free(pDb->zBindFallback); in DbObjCmd()
2151 pDb->zBindFallback = Tcl_Alloc( len + 1 ); in DbObjCmd()
2152 memcpy(pDb->zBindFallback, zCallback, len+1); in DbObjCmd()
2154 pDb->zBindFallback = 0; in DbObjCmd()
2170 if( pDb->zBusy ){ in DbObjCmd()
2171 Tcl_AppendResult(interp, pDb->zBusy, (char*)0); in DbObjCmd()
2176 if( pDb->zBusy ){ in DbObjCmd()
2177 Tcl_Free(pDb->zBusy); in DbObjCmd()
2181 pDb->zBusy = Tcl_Alloc( len + 1 ); in DbObjCmd()
2182 memcpy(pDb->zBusy, zBusy, len+1); in DbObjCmd()
2184 pDb->zBusy = 0; in DbObjCmd()
2186 if( pDb->zBusy ){ in DbObjCmd()
2187 pDb->interp = interp; in DbObjCmd()
2188 sqlite3_busy_handler(pDb->db, DbBusyHandler, pDb); in DbObjCmd()
2190 sqlite3_busy_handler(pDb->db, 0, 0); in DbObjCmd()
2216 flushStmtCache( pDb ); in DbObjCmd()
2229 flushStmtCache( pDb ); in DbObjCmd()
2234 pDb->maxStmt = n; in DbObjCmd()
2259 Tcl_SetWideIntObj(pResult, sqlite3_changes64(pDb->db)); in DbObjCmd()
2292 pCollate->pNext = pDb->pCollate; in DbObjCmd()
2294 pDb->pCollate = pCollate; in DbObjCmd()
2296 if( sqlite3_create_collation(pDb->db, zName, SQLITE_UTF8, in DbObjCmd()
2298 Tcl_SetResult(interp, (char *)sqlite3_errmsg(pDb->db), TCL_VOLATILE); in DbObjCmd()
2315 if( pDb->pCollateNeeded ){ in DbObjCmd()
2316 Tcl_DecrRefCount(pDb->pCollateNeeded); in DbObjCmd()
2318 pDb->pCollateNeeded = Tcl_DuplicateObj(objv[2]); in DbObjCmd()
2319 Tcl_IncrRefCount(pDb->pCollateNeeded); in DbObjCmd()
2320 sqlite3_collation_needed(pDb->db, pDb, tclCollateNeeded); in DbObjCmd()
2336 if( pDb->zCommit ){ in DbObjCmd()
2337 Tcl_AppendResult(interp, pDb->zCommit, (char*)0); in DbObjCmd()
2342 if( pDb->zCommit ){ in DbObjCmd()
2343 Tcl_Free(pDb->zCommit); in DbObjCmd()
2347 pDb->zCommit = Tcl_Alloc( len + 1 ); in DbObjCmd()
2348 memcpy(pDb->zCommit, zCommit, len+1); in DbObjCmd()
2350 pDb->zCommit = 0; in DbObjCmd()
2352 if( pDb->zCommit ){ in DbObjCmd()
2353 pDb->interp = interp; in DbObjCmd()
2354 sqlite3_commit_hook(pDb->db, DbCommitHandler, pDb); in DbObjCmd()
2356 sqlite3_commit_hook(pDb->db, 0, 0); in DbObjCmd()
2422 sqlite3_db_config(pDb->db, aDbConfig[ii].op, -1, &v); in DbObjCmd()
2446 sqlite3_db_config(pDb->db, aDbConfig[ii].op, onoff, &v); in DbObjCmd()
2532 rc = sqlite3_prepare(pDb->db, zSql, -1, &pStmt, 0); in DbObjCmd()
2535 Tcl_AppendResult(interp, "Error: ", sqlite3_errmsg(pDb->db), (char*)0); in DbObjCmd()
2558 rc = sqlite3_prepare(pDb->db, zSql, -1, &pStmt, 0); in DbObjCmd()
2561 Tcl_AppendResult(interp, "Error: ", sqlite3_errmsg(pDb->db), (char*)0); in DbObjCmd()
2577 (void)sqlite3_exec(pDb->db, "BEGIN", 0, 0, 0); in DbObjCmd()
2621 Tcl_AppendResult(interp,"Error: ", sqlite3_errmsg(pDb->db), (char*)0); in DbObjCmd()
2629 (void)sqlite3_exec(pDb->db, zCommit, 0, 0, 0); in DbObjCmd()
2708 xrc = sqlite3_deserialize(pDb->db, zSchema, pData, len, len, flags); in DbObjCmd()
2714 sqlite3_file_control(pDb->db, zSchema,SQLITE_FCNTL_SIZE_LIMIT,&mxSize); in DbObjCmd()
2738 sqlite3_enable_load_extension(pDb->db, onoff); in DbObjCmd()
2754 Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_errcode(pDb->db))); in DbObjCmd()
2765 Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_error_offset(pDb->db))); in DbObjCmd()
2785 dbEvalInit(&sEval, pDb, objv[2], 0, 0); in DbObjCmd()
2838 dbEvalInit(&sEval, pDb, objv[2], 0, 0); in DbObjCmd()
2866 dbEvalInit(p, pDb, objv[2], pArray, evalFlags); in DbObjCmd()
2949 pFunc = findSqlFunc(pDb, zName); in DbObjCmd()
2958 rc = sqlite3_create_function(pDb->db, zName, nArg, flags, in DbObjCmd()
2962 Tcl_SetResult(interp, (char *)sqlite3_errmsg(pDb->db), TCL_VOLATILE); in DbObjCmd()
3000 interp, pDb, zDb, zTable, zColumn, (sqlite3_int64)iRow, isReadonly in DbObjCmd()
3014 sqlite3_interrupt(pDb->db); in DbObjCmd()
3034 if( pDb->zNull ){ in DbObjCmd()
3035 Tcl_Free(pDb->zNull); in DbObjCmd()
3038 pDb->zNull = Tcl_Alloc( len + 1 ); in DbObjCmd()
3039 memcpy(pDb->zNull, zNull, len); in DbObjCmd()
3040 pDb->zNull[len] = '\0'; in DbObjCmd()
3042 pDb->zNull = 0; in DbObjCmd()
3045 Tcl_SetObjResult(interp, Tcl_NewStringObj(pDb->zNull, -1)); in DbObjCmd()
3061 rowid = sqlite3_last_insert_rowid(pDb->db); in DbObjCmd()
3078 if( pDb->zProgress ){ in DbObjCmd()
3079 Tcl_AppendResult(interp, pDb->zProgress, (char*)0); in DbObjCmd()
3082 sqlite3_progress_handler(pDb->db, 0, 0, 0); in DbObjCmd()
3091 if( pDb->zProgress ){ in DbObjCmd()
3092 Tcl_Free(pDb->zProgress); in DbObjCmd()
3096 pDb->zProgress = Tcl_Alloc( len + 1 ); in DbObjCmd()
3097 memcpy(pDb->zProgress, zProgress, len+1); in DbObjCmd()
3099 pDb->zProgress = 0; in DbObjCmd()
3102 if( pDb->zProgress ){ in DbObjCmd()
3103 pDb->interp = interp; in DbObjCmd()
3104 sqlite3_progress_handler(pDb->db, N, DbProgressHandler, pDb); in DbObjCmd()
3106 sqlite3_progress_handler(pDb->db, 0, 0, 0); in DbObjCmd()
3127 if( pDb->zProfile ){ in DbObjCmd()
3128 Tcl_AppendResult(interp, pDb->zProfile, (char*)0); in DbObjCmd()
3133 if( pDb->zProfile ){ in DbObjCmd()
3134 Tcl_Free(pDb->zProfile); in DbObjCmd()
3138 pDb->zProfile = Tcl_Alloc( len + 1 ); in DbObjCmd()
3139 memcpy(pDb->zProfile, zProfile, len+1); in DbObjCmd()
3141 pDb->zProfile = 0; in DbObjCmd()
3145 if( pDb->zProfile ){ in DbObjCmd()
3146 pDb->interp = interp; in DbObjCmd()
3147 sqlite3_profile(pDb->db, DbProfileHandler, pDb); in DbObjCmd()
3149 sqlite3_profile(pDb->db, 0, 0); in DbObjCmd()
3192 SQLITE_OPEN_READONLY | pDb->openFlags, 0); in DbObjCmd()
3199 pBackup = sqlite3_backup_init(pDb->db, zDestDb, pSrc, "main"); in DbObjCmd()
3202 sqlite3_errmsg(pDb->db), (char*)0); in DbObjCmd()
3222 sqlite3_errmsg(pDb->db), (char*)0); in DbObjCmd()
3248 pData = sqlite3_serialize(pDb->db, zSchema, &sz, SQLITE_SERIALIZE_NOCOPY); in DbObjCmd()
3252 pData = sqlite3_serialize(pDb->db, zSchema, &sz, 0); in DbObjCmd()
3277 v = pDb->nStep; in DbObjCmd()
3279 v = pDb->nSort; in DbObjCmd()
3281 v = pDb->nIndex; in DbObjCmd()
3283 v = pDb->nVMStep; in DbObjCmd()
3306 sqlite3_busy_timeout(pDb->db, ms); in DbObjCmd()
3323 Tcl_SetWideIntObj(pResult, sqlite3_total_changes64(pDb->db)); in DbObjCmd()
3338 if( pDb->zTrace ){ in DbObjCmd()
3339 Tcl_AppendResult(interp, pDb->zTrace, (char*)0); in DbObjCmd()
3344 if( pDb->zTrace ){ in DbObjCmd()
3345 Tcl_Free(pDb->zTrace); in DbObjCmd()
3349 pDb->zTrace = Tcl_Alloc( len + 1 ); in DbObjCmd()
3350 memcpy(pDb->zTrace, zTrace, len+1); in DbObjCmd()
3352 pDb->zTrace = 0; in DbObjCmd()
3356 if( pDb->zTrace ){ in DbObjCmd()
3357 pDb->interp = interp; in DbObjCmd()
3358 sqlite3_trace(pDb->db, DbTraceHandler, pDb); in DbObjCmd()
3360 sqlite3_trace(pDb->db, 0, 0); in DbObjCmd()
3378 if( pDb->zTraceV2 ){ in DbObjCmd()
3379 Tcl_AppendResult(interp, pDb->zTraceV2, (char*)0); in DbObjCmd()
3427 if( pDb->zTraceV2 ){ in DbObjCmd()
3428 Tcl_Free(pDb->zTraceV2); in DbObjCmd()
3432 pDb->zTraceV2 = Tcl_Alloc( len + 1 ); in DbObjCmd()
3433 memcpy(pDb->zTraceV2, zTraceV2, len+1); in DbObjCmd()
3435 pDb->zTraceV2 = 0; in DbObjCmd()
3438 if( pDb->zTraceV2 ){ in DbObjCmd()
3439 pDb->interp = interp; in DbObjCmd()
3440 sqlite3_trace_v2(pDb->db, (unsigned)wMask, DbTraceV2Handler, pDb); in DbObjCmd()
3442 sqlite3_trace_v2(pDb->db, 0, 0, 0); in DbObjCmd()
3468 if( pDb->nTransaction==0 && objc==4 ){ in DbObjCmd()
3489 pDb->disableAuth++; in DbObjCmd()
3490 rc = sqlite3_exec(pDb->db, zBegin, 0, 0, 0); in DbObjCmd()
3491 pDb->disableAuth--; in DbObjCmd()
3493 Tcl_AppendResult(interp, sqlite3_errmsg(pDb->db), (char*)0); in DbObjCmd()
3496 pDb->nTransaction++; in DbObjCmd()
3503 addDatabaseRef(pDb); /* DbTransPostCmd() calls delDatabaseRef() */ in DbObjCmd()
3529 if( pDb->pUnlockNotify ){ in DbObjCmd()
3530 Tcl_DecrRefCount(pDb->pUnlockNotify); in DbObjCmd()
3531 pDb->pUnlockNotify = 0; in DbObjCmd()
3536 pNotifyArg = (void *)pDb; in DbObjCmd()
3537 pDb->pUnlockNotify = objv[2]; in DbObjCmd()
3538 Tcl_IncrRefCount(pDb->pUnlockNotify); in DbObjCmd()
3541 if( sqlite3_unlock_notify(pDb->db, xNotify, pNotifyArg) ){ in DbObjCmd()
3542 Tcl_AppendResult(interp, sqlite3_errmsg(pDb->db), (char*)0); in DbObjCmd()
3577 int nCol = sqlite3_preupdate_count(pDb->db); in DbObjCmd()
3587 DbHookCmd(interp, pDb, (objc==4 ? objv[3] : 0), &pDb->pPreUpdateHook); in DbObjCmd()
3597 pRet = Tcl_NewIntObj(sqlite3_preupdate_depth(pDb->db)); in DbObjCmd()
3615 rc = sqlite3_preupdate_old(pDb->db, iIdx, &pValue); in DbObjCmd()
3618 rc = sqlite3_preupdate_new(pDb->db, iIdx, &pValue); in DbObjCmd()
3626 Tcl_AppendResult(interp, sqlite3_errmsg(pDb->db), (char*)0); in DbObjCmd()
3647 if( choice==DB_WAL_HOOK ) ppHook = &pDb->pWalHook; in DbObjCmd()
3648 if( choice==DB_UPDATE_HOOK ) ppHook = &pDb->pUpdateHook; in DbObjCmd()
3649 if( choice==DB_ROLLBACK_HOOK ) ppHook = &pDb->pRollbackHook; in DbObjCmd()
3655 DbHookCmd(interp, pDb, (objc==3 ? objv[2] : 0), ppHook); in DbObjCmd()
3675 if( Tcl_GetBooleanFromObj(interp, objv[i], &pDb->bLegacyPrepare) ){ in DbObjCmd()
3688 pDb->stmtList ? pDb->stmtList->pStmt: 0); in DbObjCmd()