コード例 #1
0
        static void ReloadTableSchema(Parse parse, Table table, string name)
        {
            Context ctx = parse.Ctx;
            string  where_;

#if !SQLITE_OMIT_TRIGGER
            Trigger trig;
#endif

            Vdbe v = parse.GetVdbe();
            if (C._NEVER(v == null))
            {
                return;
            }
            Debug.Assert(Btree.HoldsAllMutexes(ctx));
            int db = Prepare.SchemaToIndex(ctx, table.Schema); // Index of database containing pTab
            Debug.Assert(db >= 0);

#if !OMIT_TRIGGER
            // Drop any table triggers from the internal schema.
            for (trig = Trigger.List(parse, table); trig != null; trig = trig.Next)
            {
                int trigDb = Prepare.SchemaToIndex(ctx, trig.Schema);
                Debug.Assert(trigDb == db || trigDb == 1);
                v.AddOp4(OP.DropTrigger, trigDb, 0, 0, trig.Name, 0);
            }
#endif

            // Drop the table and index from the internal schema.
            v.AddOp4(OP.DropTable, db, 0, 0, table.Name, 0);

            // Reload the table, index and permanent trigger schemas.
            where_ = C._mtagprintf(ctx, "tbl_name=%Q", name);
            if (where_ == null)
            {
                return;
            }
            v.AddParseSchemaOp(db, where_);

#if !OMIT_TRIGGER
            // Now, if the table is not stored in the temp database, reload any temp triggers. Don't use IN(...) in case SQLITE_OMIT_SUBQUERY is defined.
            if ((where_ = WhereTempTriggers(parse, table)) != "")
            {
                v.AddParseSchemaOp(1, where_);
            }
#endif
        }