Skip to content

Commit c4d7bbf

Browse files
committed
re-organize code
1 parent a1b2180 commit c4d7bbf

File tree

20 files changed

+913
-817
lines changed

20 files changed

+913
-817
lines changed

src/MiniSQL.Api/Api.cs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ private void HandleStatement(CreateStatement statement)
8888
}
8989
}
9090

91-
// TODO: review
9291
// drop statement
9392
private void HandleStatement(DropStatement statement)
9493
{
@@ -127,16 +126,8 @@ private void HandleStatement(DeleteStatement statement)
127126
SchemaRecord tableSchema = _catalogManager.GetTableSchemaRecord(statement.TableName);
128127
List<SchemaRecord> indexSchemas = _catalogManager.GetIndicesSchemaRecord(statement.TableName);
129128

130-
// // delete index records from index trees
131-
// foreach (SchemaRecord indexSchema in indexSchemas)
132-
// {
133-
// // build condition for each index tree
134-
// Expression condition = new Expression();
135-
136-
137-
// }
138-
139129
// TODO
130+
// delete index records from index trees
140131
// __problem__:
141132
// attribute names := (priKey, a, b, c)
142133
// condition := b < 3 and c > 5
@@ -169,9 +160,9 @@ private SelectResult HandleSelectStatement(SelectStatement statement)
169160
{
170161
isIndexTreeAvailable = true;
171162
// find out the primary key
172-
// List<AtomValue> indexPrimaryKeyPair = _recordManager.SelectRecord(statement.Condition.Ands[indexSchema.Name].RightOperant.ConcreteValue, indexSchema.RootPage);
163+
// List<AtomValue> indexPrimaryKeyPair = _recordManager.SelectRecord(statement.Condition.Ands[indexSchema.Name].RightOperand.ConcreteValue, indexSchema.RootPage);
173164
// primaryKey = indexPrimaryKeyPair[1];
174-
List<AtomValue> wrappedPrimaryKey = _recordManager.SelectRecord(statement.Condition.Ands[indexSchema.SQL.AttributeName].RightOperant.ConcreteValue, indexSchema.RootPage);
165+
List<AtomValue> wrappedPrimaryKey = _recordManager.SelectRecord(statement.Condition.Ands[indexSchema.SQL.AttributeName].RightOperand.ConcreteValue, indexSchema.RootPage);
175166
primaryKey = wrappedPrimaryKey?[0];
176167
break;
177168
}

src/MiniSQL.Api/Program.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ namespace MiniSQL.Api
1818
{
1919
class Program
2020
{
21-
// TODO: view of the whole solution
2221
static void Main(string[] args)
2322
{
2423
// init

src/MiniSQL.Api/tests/compilation.sql

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
-- insert-delete
2+
3+
-- create table test
4+
-- (
5+
-- id INT,
6+
-- name Char(8)
7+
-- );
8+
create table test
9+
(
10+
id INT,
11+
name Char(8),
12+
primary key (id)
13+
);
14+
15+
insert into test values (1, "Tom");
16+
insert into test values (2, "Tim");
17+
insert into test values (3, "Tai");
18+
19+
select * from test;
20+
21+
delete from test where name = "Tai";
22+
23+
select * from test;
24+
25+
delete from test where id < 3;
26+
27+
select * from test;
28+
29+
-- type
30+
31+
create table typetest
32+
(
33+
id INT,
34+
name Char(8),
35+
height FLOAT,
36+
primary key (id)
37+
);
38+
39+
insert into typetest values (3, "test1", 12.3);
40+
insert into typetest values (3, "test2", 332.1);
41+
42+
select * from typetest;
43+
44+
-- table collision
45+
46+
create table test
47+
(
48+
id INT,
49+
name Char(8),
50+
height FLOAT,
51+
primary key (id)
52+
);
53+
create table test
54+
(
55+
id INT,
56+
name Char(8),
57+
height FLOAT,
58+
primary key (id)
59+
);
60+
61+
-- inconsistent number of values
62+
63+
create table test
64+
(
65+
id INT,
66+
name Char(8),
67+
height FLOAT,
68+
primary key (id)
69+
);
70+
71+
insert into test values (1, "Tom");
72+
73+
-- inconsistent types of values
74+
75+
create table test
76+
(
77+
id INT,
78+
name Char(8),
79+
height FLOAT,
80+
primary key (id)
81+
);
82+
83+
insert into test values (1, 1123.4, "Tom");

src/MiniSQL.BufferManager/Program.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ private static Expression GetAndsExpression()
5353
// <=
5454
Expression node4 = new Expression();
5555
node4.Operator = Operator.LessThanOrEqualTo;
56-
node4.LeftOperant = node8;
57-
node4.RightOperant = node9;
56+
node4.LeftOperand = node8;
57+
node4.RightOperand = node9;
5858
// <=
5959
Expression node5 = new Expression();
6060
node5.Operator = Operator.LessThanOrEqualTo;
61-
node5.LeftOperant = node10;
62-
node5.RightOperant = node11;
61+
node5.LeftOperand = node10;
62+
node5.RightOperand = node11;
6363
// 6.6
6464
Expression node6 = new Expression();
6565
node6.Operator = Operator.AtomConcreteValue;
@@ -73,18 +73,18 @@ private static Expression GetAndsExpression()
7373
// and
7474
Expression node2 = new Expression();
7575
node2.Operator = Operator.And;
76-
node2.LeftOperant = node4;
77-
node2.RightOperant = node5;
76+
node2.LeftOperand = node4;
77+
node2.RightOperand = node5;
7878
// >
7979
Expression node3 = new Expression();
8080
node3.Operator = Operator.MoreThan;
81-
node3.LeftOperant = node6;
82-
node3.RightOperant = node7;
81+
node3.LeftOperand = node6;
82+
node3.RightOperand = node7;
8383
// and
8484
Expression node1 = new Expression();
8585
node1.Operator = Operator.And;
86-
node1.LeftOperant = node2;
87-
node1.RightOperant = node3;
86+
node1.LeftOperand = node2;
87+
node1.RightOperand = node3;
8888

8989
return node1;
9090
}

0 commit comments

Comments
 (0)