Beispiel #1
0
        public void DropStatementForTable(DropStatement dropStatement)
        {
            bool if_find = false;

            if (this.If_in(dropStatement.TableName))
            {
                for (int i = 0; i < this.tables.Count;)
                {
                    if (this.tables[i].table_name == dropStatement.TableName)
                    {
                        tables.RemoveAt(i);
                        Save_table(tables);
                        if_find = true;
                    }
                    else
                    {
                        i++;
                    }
                }
            }
            //delete all the indices that are related to the deleted table
            Catalog_index b = new Catalog_index(_databaseName);

            if (if_find)
            {
                b.DeleteIndicesOfTable(dropStatement.TableName);
            }
            else
            {
                throw new TableOrIndexNotExistsException($"Table {dropStatement.TableName} Not Exists");
            }
        }
Beispiel #2
0
        //try to drop one table and save the result into the file
        //if succeed, return true
        //if can't find table, return false
        public bool TryDropStatementForTable(DropStatement dropStatement)
        {
            bool if_find = false;

            if (this.If_in(dropStatement.TableName))
            {
                for (int i = 0; i < this.tables.Count;)
                {
                    if (this.tables[i].table_name == dropStatement.TableName)
                    {
                        tables.RemoveAt(i);
                        Save_table(tables);
                        if_find = true;
                    }
                    else
                    {
                        i++;
                    }
                }
            }
            //delete all the indices that are related to the deleted table
            Catalog_index b = new Catalog_index(_databaseName);

            return(if_find && b.DeleteIndicesOfTable(dropStatement.TableName));
        }