1 /***************************************************************************
2 * Copyright (C) 2007 by Prabakaran Thirumalai *
3 * praba_tuty@yahoo.com *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
23 #include <AggTableImpl.h>
43 int paramNo
; // 0 ->not a param. It stores the param position
53 int paramNo
; // 0 ->not a param. It stores the param position
56 char fName
[IDENTIFIER_LENGTH
];
61 char fldName
[IDENTIFIER_LENGTH
];
62 AggType aType
; //used only in case of select projection
70 struct UpdateFieldValue
72 char fldName
[IDENTIFIER_LENGTH
];
84 char tblName
[IDENTIFIER_LENGTH
];
85 char idxName
[IDENTIFIER_LENGTH
];
87 StatementType stmtType
;
91 //holds pointer to field names. used in insert to store field name list
92 //and for projection list of select
93 //also used to store primary or unique key fields in create statement
96 List groupFieldNameList
;
98 //holds pointer to condition values.
99 List conditionValueList
;
101 //holds pointer to field values. used in insert to store field values
102 //used in update to store the current value returned by fetch().This gets replaced
103 //by value in updFldValList and then update() is called.
106 //used to store IN values of SELECT statement
107 //This should be a list of list. so that multiple IN shall be present
108 //in the select statement
111 //update field value list. used to store the values to be updated
112 //value in the SET clause of UPDATE statement is stored here.
115 //stores the where clause condition for SELECT, UPDATE and DELETE
118 //stores field information in CREATE TABLE
121 //stores list of fields for CREATE TABLE
122 FieldList creFldList
;
124 //stores index information
130 ParsedData() { paramCounter
= 0; stmtType
= UnknownStatement
;
131 isUnique
= false; isPrimary
= false; indexType
= hashIndex
;}
132 void setStmtType(StatementType type
) { stmtType
= type
; }
133 void setTableName(char *name
) { strcpy(tblName
, name
); }
134 void setIndexName(char *name
) { strcpy(idxName
, name
); }
136 char* getTableName() { return tblName
; }
137 char* getIndexName() { return idxName
; }
139 void insertValue(char *value
);
140 void insertInValue(char *value
);
141 void** insertCondValueAndGetPtr(char *fName
, char *value
);
142 void insertUpdateValue(char *fldName
, char *value
);
144 void insertField(char *fName
, AggType aggType
= AGG_UNKNOWN
);
145 void insertGroupField(char *fName
);
146 void clearFieldNameList();
149 Predicate
* insertPredicate(char *fldName
, ComparisionOp op
, void** value
);
150 Predicate
* insertPredicate(char *fldName
, ComparisionOp op
, char *fldName
);
151 Predicate
* insertPredicate(Predicate
*p1
, LogicalOp op
, Predicate
*p2
= NULL
);
152 void setCondition(Predicate
*pred
)
154 //No body is deleting memory allocated during condition::setTerm for PredicateImpl
155 //have list in this pared data and delete it during reset
156 predicate
.setPredicate(pred
);
158 Condition
* getCondition() { return &predicate
; }
160 void insertFieldValue(FieldValue
*newVal
) { fieldValueList
.append(newVal
); }
162 List
getFieldNameList() { return fieldNameList
; }
163 List
getGroupFieldNameList() { return groupFieldNameList
; }
164 List
getConditionValueList() { return conditionValueList
; }
165 List
getFieldValueList() { return fieldValueList
; }
166 List
getInValueList() { return inValueList
; }
167 List
getUpdateFieldValueList() { return updFldValList
; }
169 void setFldName(char *name
);
170 void setFldType(DataType type
);
171 void setFldLength(size_t length
);
172 void setDefaultValue(char * value
);
173 //void setFldDefaultValue -- will need two parametersers, check how u want to pass default value.
174 void setFldNotNull(bool notNull
);
176 void setUnique(bool unique
){ isUnique
= unique
; }
177 void setPrimary(bool primary
) { isPrimary
= primary
; }
178 void setIndexType (IndexType type
) { indexType
= type
; }
179 IndexType
getIndexType(){ return indexType
; }
180 bool getUnique() { return isUnique
; }
181 bool getPrimary() { return isPrimary
; }
183 void insertFldDef(); //check if fldDef needs to be a part of ParsedData
185 FieldList
getCreFldList() { return creFldList
; }
187 StatementType
getStmtType() { return stmtType
; }
196 //variable and function names suck, change if u want to
198 //finding out if fldDef needs to be part of parsedData, or can allocate memory and pass around