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 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); }