public static void DropTrigger(Parse parse, SrcList name, int noErr) { Context ctx = parse.Ctx; if (ctx.MallocFailed || parse.ReadSchema(parse) != RC.OK) { goto drop_trigger_cleanup; } Debug.Assert(name.Srcs == 1); string dbName = name.Ids[0].Database; string nameAsString = name.Ids[0].Name; int nameLength = nameAsString.Length; Debug.Assert(dbName != null || Btree.HoldsAllMutexes(ctx)); Trigger trigger = null; for (int i = E.OMIT_TEMPDB; i < ctx.DBs.length; i++) { int j = (i < 2 ? i ^ 1 : i); // Search TEMP before MAIN if (dbName != null && !string.Equals(ctx.DBs[j].Name, dbName, StringComparison.InvariantCultureIgnoreCase)) { continue; } Debug.Assert(Btree.SchemaMutexHeld(ctx, j, null)); trigger = ctx.DBs[j].Schema.TriggerHash.Find(nameAsString, nameLength, (Trigger)null); if (trigger != null) { break; } } if (trigger == null) { if (noErr == 0) { parse.ErrorMsg("no such trigger: %S", name, 0); } else { parse.CodeVerifyNamedSchema(dbName); } parse.CheckSchema = true; goto drop_trigger_cleanup; } DropTriggerPtr(parse, trigger); drop_trigger_cleanup: SrcListDelete(ctx, ref name); }
public static void Disconnect(Context ctx, Table table) { Debug.Assert(E.IsVirtual(table)); Debug.Assert(Btree.HoldsAllMutexes(ctx)); Debug.Assert(MutexEx.Held(ctx.Mutex)); for (VTable pvtable = table.VTables; pvtable != null; pvtable = pvtable.Next) { if (pvtable.Ctx == ctx) { VTable vtable = pvtable; vtable = vtable.Next; vtable.Unlock(); break; } } }
public static void UnlockList(Context ctx) { Debug.Assert(Btree.HoldsAllMutexes(ctx)); Debug.Assert(MutexEx.Held(ctx.Mutex)); VTable vtable = ctx.Disconnect; ctx.Disconnect = null; if (vtable != null) { Vdbe.ExpirePreparedStatements(ctx); do { VTable next = vtable.Next; vtable.Unlock(); vtable = next; } while (vtable != null); } }