Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions DBMS/DBMS/create.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
CREATE DATABASE orderDB;
USE orderDB;

CREATE TABLE publisher (
id int(10) NOT NULL,
name varchar(100) NOT NULL,
nation varchar(3),
PRIMARY KEY (id)
);

INSERT INTO publisher VALUES
(100008,'Oxbow Books Limited','USA');
INSERT INTO publisher VALUES
(100009,'Oxbow Books Limited','USA');
DELETE FROM publisher WHERE id = 100008;
UPDATE publisher SET nation = 'CNA' , name = 'wangqing' WHERE id = 100009;

5 changes: 5 additions & 0 deletions DBMS/DBMS/dbManage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ bool DBManager::deleteRecord(string tableName,BYTE **Value,string *colName,BYTE
SysObject* table = sysManager.findTable(tableName);
if (table == NULL)
return true;
vector<SysColumn*> sysColumns = sysManager.getTableAttr(tableName);
string* colNames = new string[sysColumns.size()];
for (int i = 0; i < sysColumns.size(); i++)
colNames[i] = sysColumns[i]->name;
TYPE_ID pageid = 0;
Node* dataPage = readPage(table->id, pageid);
TYPE_OFFSET recordLength = sysManager.getRecordLength(tableName);
Expand Down Expand Up @@ -226,6 +230,7 @@ bool DBManager::deleteRecord(string tableName,BYTE **Value,string *colName,BYTE
if (deleteFlag == true) {
cout << "delete onedata pageid: " << pageid << "offset: " << offset << endl;
deleteData(table, pageid, offset*recordLength, recordLength);
printRecord(tableName,sysColumns.size(),colNames, offset,pageid);
//cout << "continue" << endl;
}
}
Expand Down
Binary file removed DBMS/DBMS/orderDB/_sysFile
Binary file not shown.
Binary file removed DBMS/DBMS/orderDB/publisher
Binary file not shown.
3 changes: 3 additions & 0 deletions DBMS/DBMS/wq_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ bool parser::parserOneCommand(vector<string> commands) {
}
return true;
}
bool parser::parserSelect(vector<string> commands){
return true;
}
bool parser::parserUpdate(vector<string> commands) {
cout<< "********************start parser update*************************" << endl;
//without condition, update all
Expand Down
1 change: 1 addition & 0 deletions DBMS/DBMS/wq_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class parser{
bool parserDesc(vector<string> commands);
bool parserDelete(vector<string> commands);
bool parserUpdate(vector<string> commands);
bool parserSelect(vector<string> commands);
bool parserShowTable(vector<string> commands);
bool parserCreateColumn(vector<string> columnInfo, tableColumn* columnInfos);
bool parserUse(vector<string> commands);
Expand Down