MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / SQL_TQuery

Function SQL_TQuery

core/logic/smn_database.cpp:834–881  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

832}
833
834static cell_t SQL_TQuery(IPluginContext *pContext, const cell_t *params)
835{
836 IDatabase *db = NULL;
837 HandleError err;
838
839 if ((err = g_DBMan.ReadHandle(params[1], DBHandle_Database, (void **)&db))
840 != HandleError_None)
841 {
842 return pContext->ThrowNativeError("Invalid database Handle %x (error: %d)", params[1], err);
843 }
844
845 if (!db->GetDriver()->IsThreadSafe())
846 {
847 return pContext->ThrowNativeError("Driver \"%s\" is not thread safe!", db->GetDriver()->GetIdentifier());
848 }
849
850 IPluginFunction *pf = pContext->GetFunctionById(params[2]);
851 if (!pf)
852 {
853 return pContext->ThrowNativeError("Function id %x is invalid", params[2]);
854 }
855
856 char *query;
857 pContext->LocalToString(params[3], &query);
858
859 cell_t data = params[4];
860 PrioQueueLevel level = PrioQueue_Normal;
861 if (params[5] == (cell_t)PrioQueue_High)
862 {
863 level = PrioQueue_High;
864 } else if (params[5] == (cell_t)PrioQueue_Low) {
865 level = PrioQueue_Low;
866 }
867
868 IPlugin *pPlugin = scripts->FindPluginByContext(pContext);
869
870 TQueryOp *op = new TQueryOp(db, pf, query, data);
871 if (pPlugin->GetProperty("DisallowDBThreads", NULL)
872 || !g_DBMan.AddToThreadQueue(op, level))
873 {
874 /* Do everything right now */
875 op->RunThreadPart();
876 op->RunThinkPart();
877 op->Destroy();
878 }
879
880 return 1;
881}
882
883static cell_t SQL_LockDatabase(IPluginContext *pContext, const cell_t *params)
884{

Callers

nothing calls this directly

Calls 10

GetPropertyMethod · 0.80
AddToThreadQueueMethod · 0.80
ReadHandleMethod · 0.45
IsThreadSafeMethod · 0.45
GetDriverMethod · 0.45
GetIdentifierMethod · 0.45
FindPluginByContextMethod · 0.45
RunThreadPartMethod · 0.45
RunThinkPartMethod · 0.45
DestroyMethod · 0.45

Tested by

no test coverage detected