1 /***************************************************************************
3 * Copyright (C) Lakshya Solutions Ltd. All rights reserved. *
5 ***************************************************************************/
26 struct IndexInfoForDriver
28 char tableName
[IDENTIFIER_LENGTH
];
29 char fieldName
[IDENTIFIER_LENGTH
];
30 char indexName
[IDENTIFIER_LENGTH
];
41 char name
[IDENTIFIER_LENGTH
];
47 class ForeignKeyMetadata
50 char pkTableName
[IDENTIFIER_LENGTH
];
51 char pkColName
[IDENTIFIER_LENGTH
];
52 char fkTableName
[IDENTIFIER_LENGTH
];
53 char fkColName
[IDENTIFIER_LENGTH
];
76 * @class FieldNameList
78 * @brief Field name list used to specify composite key while creating index. <br/>
81 class DllExport FieldNameList
86 FieldNameList() { head
= iter
= NULL
; }
87 ~FieldNameList() { } //TODO::Remove all elements from the list
88 char *nextFieldName();
89 void resetIter(){ iter
= head
; }
92 /** appends field name to the list
93 * @param name field name
96 DbRetVal
append(const char *name
);
98 /** removes field name from the list
99 * @param name field name
102 DbRetVal
remove(const char *name
);
103 DbRetVal
removeAll();
113 * @brief Represents table definition used to create the table.
114 * Encapsulates the information or schema definition of a table.For Example say if <br/>
115 * we need to create table with two fields, call addField method with necessary parameters<br/>
116 * twice. Passed as argument to createTable method of DatabaseManager to create table.<br/>
119 class DllExport TableDef
125 TableDef() { fldCount
= 0; }
128 /** adds a field to the schema definition.
129 * @param name field name
130 * @param type data type of the field
131 * @param length size of the field. used in case of char and binary data types.
132 * @param defaultValue default value for the field. It is currently limited to 32 bytes.
133 * @param isPrimary whether the field is primary key( not null + unique)
134 * @param notNull whether the field can be null
135 * @param unique whether the field values are unique
138 int addField(const char *name
, DataType type
= typeUnknown
, size_t
139 length
= 0, const void *defaultValue
= 0,
140 bool notNull
= false, bool autoIn
= false);
142 /** removes a field from the schema definition
143 * @param name field name
146 int dropField(const char *name
);
148 /** returns the total number of fields in this table definition
149 * @return int no of fields
153 /** returns the total tuple size in bytes.
154 * @return size_t tuple size
156 size_t getTupleSize();
158 //Internal method used to iterate and get information stored
159 //in this table definition.
160 FieldIterator
getFieldIterator(){ return fldList
.getIterator(); }
161 bool isVarcharPresentInSchema(FieldIterator
&iter
);
164 class DllExport FieldInfo
167 char fldName
[IDENTIFIER_LENGTH
];
171 char defaultValueBuf
[DEFAULT_VALUE_BUF_LENGTH
];
177 bool isAutoIncrement
;
180 fldName
[0] = '\0'; type
= typeUnknown
; length
= 0; offset
= 0;
181 defaultValueBuf
[0]='\0'; aType
= AGG_UNKNOWN
; isNull
= false;
182 isPrimary
= isDefault
= isUnique
= isAutoIncrement
= false;
192 hashIndex
= 0, /**<hash index*/
193 treeIndex
, /**<tree index*/
194 trieIndex
, /**<trie index*/
195 unknownIndex
/**<no index*/
199 * @class IndexInitInfo
201 * @brief Represents index definition used to create index.
202 * Encapsulates the information or definition of an index.<br/>
208 char tableName
[IDENTIFIER_LENGTH
]; /**<tablename*/
209 FieldNameList list
; /**<field name list*/
210 IndexType indType
; /**<index type*/
211 bool isUnique
; /**<unique values*/
212 bool isPrimary
; /**<primary key*/
213 IndexInitInfo() { indType
= hashIndex
; isUnique
= false; isPrimary
= false;}
214 ~IndexInitInfo() {list
.removeAll();}
218 * @class HashIndexInitInfo
220 * @brief Represents hash index definition used to create index.
221 * Encapsulates the information or definition of hash index.<br/>
224 class HashIndexInitInfo
: public IndexInitInfo
227 int bucketSize
; /**<bucket size*/
228 HashIndexInitInfo() { bucketSize
= 1009; }
235 char pkTableName
[IDENTIFIER_LENGTH
];
236 char fkTableName
[IDENTIFIER_LENGTH
];
237 FieldNameList fkFldList
;
238 FieldNameList pkFldList
;