-
Notifications
You must be signed in to change notification settings - Fork 0
/
minisql.h
123 lines (107 loc) · 2.09 KB
/
minisql.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#ifndef minisql_h
#define minisql_h
#include "string"
#include "iostream"
#include <iomanip>
#include "block.h"
using namespace std;
#define INT32 unsigned int
#define BLOCKSIZE 4096
#define INDEX_BLOCK_INFO 12
#define PRIMARY 0
#define UNIQUE 1
#define NULLVALUE 2
#define CHAR 0
#define INT 1
#define FLOAT 2
class IndexInfo{
public:
string indexname;
int attr_size;
int maxKeyNum;
};
class TupleIndex
{
public:
int type;
string key;
INT32 position;
};
class TupleIndex_number:public TupleIndex
{
public:
int intkey;
float floatkey;
};
class Tuple_Addr
{
private:
INT32 Index_Block_Addr;
INT32 Index_Offset;
INT32 Table_Addr;
bool Key_Exist;
public:
Tuple_Addr()
{
Index_Block_Addr = 0;
Index_Offset = 0;
Table_Addr = 0;
Key_Exist = 0;
}
Tuple_Addr(INT32 IBA, INT32 IO, INT32 TA, bool KE)
:Index_Block_Addr(IBA), Index_Offset(IO), Table_Addr(TA), Key_Exist(KE){}
bool Get_Key_Exist(){ return Key_Exist; }
INT32 getIBA(){ return Index_Block_Addr; }
INT32 getIO(){ return Index_Offset; }
INT32 getTable_Addr(){ return Table_Addr; }
~Tuple_Addr(){}
};
#define EQUAL "="
#define NOT_EQUAL "<>"
#define LARGER_THAN ">"
#define LARGER_THAN_AND_EQUAL ">="
#define LESS_THAN "<"
#define LESS_THAN_AND_EQUAL "<="
#define INFI 2147483647
//文件打开相关的异常类
class File_openfail{
public:
string filename;
File_openfail(const char* fn){
filename = fn;
}
};
//表/索引冲突异常类
class Table_Index_Error{
public:
string errorType;
string name;
Table_Index_Error(const char* errorType, string name){
this->errorType = errorType;
this->name = name;
}
};
//语法错误异常类
class Grammer_error{
public:
string errorPos;
Grammer_error(string err) : errorPos(err){}
};
class Conflict_Error
{
public:
string tablename;
Conflict_Error(string tblname)
{
tablename = tblname;
}
};
class Multip_Error
{
public:
string name;
Multip_Error(string name){
this->name = name;
}
};
#endif