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
21 changes: 20 additions & 1 deletion DBMS/DBMS/dbManage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ void DBManager::dropTable(string tableName){
}

bool DBManager::insertRecord(RecordEntry *input, string colName[], string tableName){

//get full record
char record[PAGE_SIZE];
memset(record, MEMSET_NUM, PAGE_SIZE);
Expand All @@ -109,9 +110,14 @@ bool DBManager::insertRecord(RecordEntry *input, string colName[], string tableN
}

bool DBManager::updateRecord(string tableName,BYTE **Value,string *colName,BYTE *type,BYTE *len,BYTE *op, BYTE condCnt){
//int=123: string:'123';
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 @@ -154,9 +160,21 @@ bool DBManager::updateRecord(string tableName,BYTE **Value,string *colName,BYTE
if (op[i] != SET)
continue;
col = getTableColumn(tableName, colName[i]);
dataUtility::bytefillbyte(dataPage->page->data, (unsigned char*)Value[i], offset*recordLength+col->index, len[i]);
if (col->xtype == INT_TYPE) {
len[i] = 4;
char* temp = new char[4];
temp = dataUtility::data_to_char<int>(atoi((char*)Value[i]));
dataUtility::bytefillbyte(dataPage->page->data, (unsigned char*)temp, offset*recordLength+col->index, len[i]);
delete[] temp;
}else {
char* temp = new char[col->length-len[i]];
dataUtility::bytefillbyte(dataPage->page->data, (unsigned char*)Value[i], offset*recordLength+col->index, len[i]);
dataUtility::bytefillbyte(dataPage->page->data, (unsigned char*)temp, offset*recordLength+col->index+len[i], col->length-len[i]);
delete[] temp;
}
dataPage->dirty = true;
}
printRecord(tableName,sysColumns.size(),colNames, offset,pageid);
}
}
pageid++;
Expand All @@ -166,6 +184,7 @@ bool DBManager::updateRecord(string tableName,BYTE **Value,string *colName,BYTE
}

bool DBManager::deleteRecord(string tableName,BYTE **Value,string *colName,BYTE *type,BYTE *len,BYTE *op, BYTE condCnt){
//int=123: string:'123';
SysObject* table = sysManager.findTable(tableName);
if (table == NULL)
return true;
Expand Down
Binary file modified DBMS/DBMS/orderDB/publisher
Binary file not shown.
3 changes: 1 addition & 2 deletions DBMS/DBMS/wq_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ struct columnRequire {
BYTE len;
BYTE op;
columnRequire(string value_v, string colName_v, BYTE type_v, BYTE len_v, BYTE op_v) {
cout << "Requirement: " << value << " " << colName_v << " " << (int)type_v << " " << (int)len_v << " " << (int)op_v << endl;
value = value_v;
len = value.length();
colName = colName_v;
type = type_v;
op = op_v;
cout << "Value: " << value << endl;
cout << "Requirement: " << value << " " << colName_v << " " << (int)type_v << " " << (int)len_v << " " << (int)op_v << endl;
}
};
class parser{
Expand Down