예제 #1
0
        // drop statement
        private void HandleStatement(DropStatement statement)
        {
            _catalogManager.CheckValidation(statement);
            SchemaRecord schema;

            switch (statement.TargetType)
            {
            case DropTarget.Table:
                schema = _catalogManager.GetTableSchemaRecord(statement.TableName);
                List <SchemaRecord> indices = _catalogManager.GetIndicesSchemaRecord(statement.TableName);
                // drop table
                _catalogManager.DropStatement(statement);
                _recordManager.DropTable(schema.RootPage);
                // drop index trees
                foreach (SchemaRecord index in indices)
                {
                    _recordManager.DropTable(index.RootPage);
                }
                break;

            case DropTarget.Index:
                schema = _catalogManager.GetIndexSchemaRecord(statement.IndexName);
                _catalogManager.DropStatement(statement);
                _recordManager.DropTable(schema.RootPage);
                break;
            }
        }
예제 #2
0
        //check whether we can successfully return the schema record of a table or an index
        static bool CheckGetSchemaRecord()
        {
            SchemaRecord target_table = icatalog.GetTableSchemaRecord("Student");

            Console.WriteLine("Schema of Table");
            Console.WriteLine(target_table.Name);
            Console.WriteLine(target_table.RootPage);
            Console.WriteLine(target_table.Type);
            Console.WriteLine(target_table.SQL.PrimaryKey);
            Console.WriteLine(target_table.SQL.TableName);
            Console.WriteLine(target_table.SQL.Type);

            SchemaRecord target_index = icatalog.GetIndexSchemaRecord("index_for_student_id");

            Console.WriteLine("Schema of Index");
            Console.WriteLine(target_index.Name);
            Console.WriteLine(target_index.RootPage);
            Console.WriteLine(target_index.Type);
            Console.WriteLine(target_index.SQL.IndexName);
            Console.WriteLine(target_index.SQL.IsUnique);
            Console.WriteLine(target_index.SQL.Type);

            List <SchemaRecord> target_indices = icatalog.GetIndicesSchemaRecord("Student");

            for (int i = 0; i < target_indices.Count; i++)
            {
                Console.WriteLine("Schema of Indices");
                Console.WriteLine(target_indices[i].Name);
                Console.WriteLine(target_indices[i].RootPage);
                Console.WriteLine(target_indices[i].Type);
                Console.WriteLine(target_indices[i].SQL.IndexName);
                Console.WriteLine(target_indices[i].SQL.IsUnique);
                Console.WriteLine(target_indices[i].SQL.Type);
            }
            return(true);
        }