예제 #1
0
파일: VTable.cs 프로젝트: BclEx/GpuStructs
        public static void BeginParse(Parse parse, Token name1, Token name2, Token moduleName, bool ifNotExists)
        {
            parse.StartTable(name1, name2, false, false, true, false);
            Table table = parse.NewTable; // The new virtual table

            if (table == null)
            {
                return;
            }
            Debug.Assert(table.Index == null);

            Context ctx = parse.Ctx;                                // Database connection
            int     db  = Prepare.SchemaToIndex(ctx, table.Schema); // The database the table is being created in

            Debug.Assert(db >= 0);

            table.TabFlags         |= TF.Virtual;
            table.ModuleArgs.length = 0;
            AddModuleArgument(ctx, table, Parse.NameFromToken(ctx, moduleName));
            AddModuleArgument(ctx, table, null);
            AddModuleArgument(ctx, table, table.Name);
            parse.NameToken.length = (uint)parse.NameToken.data.Length; //: (int)(&moduleName[moduleName->length] - name1);

#if !OMIT_AUTHORIZATION
            // Creating a virtual table invokes the authorization callback twice. The first invocation, to obtain permission to INSERT a row into the
            // sqlite_master table, has already been made by sqlite3StartTable(). The second call, to obtain permission to create the table, is made now.
            if (table.ModuleArgs.data != null)
            {
                Auth.Check(parse, AUTH.CREATE_VTABLE, table.Name, table.ModuleArgs[0], ctx.DBs[db].Name);
            }
#endif
        }