MiniSQL.cpp
资源名称:minisqlc.rar [点击查看]
上传用户:lkd6667
上传日期:2015-05-13
资源大小:1448k
文件大小:2k
源码类别:
其他数据库
开发平台:
C/C++
- #include "MiniSQL.h"
- extern _M_Buffer Buffer;
- extern unsigned int BTreeNodeSize;
- extern char* ErrorMessage[];
- extern char CurLocation[256];
- extern char CurRelationName[33];
- extern unsigned int SizeOfPageHead;
- void Init_MiniSQL();
- void Run_MiniSQL();
- void Exit_MiniSQL();
- int main()
- {
- Init_MiniSQL(); //初始化配置
- Run_MiniSQL(); //程序的主体
- Exit_MiniSQL(); //退出
- return 1;
- }
- void Init_MiniSQL()
- {
- std::cout<<" *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*n";
- std::cout<<" | WELCOME TO USE MINISQL! |n";
- std::cout<<" | |n";
- std::cout<<" | 2007-6 |n";
- std::cout<<" *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*n";
- Buffer.Start(); // initialize the buffer
- }
- void Exit_MiniSQL()
- {
- Buffer.End(); // close the buffer
- return;
- }
- void Run_MiniSQL()
- {
- MSG msg = DEFAULT; // make msg != QUIT
- while(msg!= QUIT) // quit the program
- {
- try
- {
- TB_Create_Info* pCreateInfo;
- TB_Select_Info* pSelectInfo;
- TB_Insert_Info* pInsertInfo;
- TB_Update_Info* pUpdateInfo;
- TB_Delete_Info* pDeleteInfo;
- // get commmand from API and execute according operation
- msg = GetCommand(&pCreateInfo,&pSelectInfo,
- &pInsertInfo,&pUpdateInfo,&pDeleteInfo);
- switch(msg)
- {
- case CREATE : Create( *pCreateInfo ); break;
- case SELECT : Select( *pSelectInfo ); break;
- case INSERT : Insert( *pInsertInfo ); break;
- case UPDATE : Update( *pUpdateInfo ); break;
- case DELETE : Delete( *pDeleteInfo ); break;
- case DROP : Ctrl_DropTB(); break;
- case DROPDB : Ctrl_DropDB(); break;
- case QUIT : break;
- default : break;
- }
- }
- catch (int ERROR_CODE)
- {
- //print the error message
- DispatchError(ERROR_CODE);
- }
- }
- return;
- }