1 Index: include/Parser.h
2 ===================================================================
3 RCS file: /cvsroot/csql/csql/include/Parser.h,v
4 retrieving revision 1.22
13 > UNKNOWN_QUERY_TYPE = 100
17 > class ParsedDataSub {
19 > List parsedDataList;
20 > void append(ParsedData *data);
24 > ParsedData *innerParsedData;
26 < shouldCreateTbl=false; userNode = NULL; isWorthyToCache=false; ftype = UNKNOWN_FUNCTION;
28 > shouldCreateTbl=false; userNode = NULL; isWorthyToCache=false; ftype = UNKNOWN_FUNCTION; qType=UNKNOWN_QUERY_TYPE; innerParsedData = NULL;
30 > void setSubQueryType(SubQueryType type) { qType = type; }
31 > void setInnerParsedData(ParsedData *data) { innerParsedData = data; }
34 Index: include/SqlStatement.h
35 ===================================================================
36 RCS file: /cvsroot/csql/csql/include/SqlStatement.h,v
37 retrieving revision 1.36
38 diff -r1.36 SqlStatement.h
40 < StatementType getStmtType() { return pData.getStmtType(); }
42 > StatementType getStmtType() { return pData->getStmtType(); }
47 Index: include/Statement.h
48 ===================================================================
49 RCS file: /cvsroot/csql/csql/include/Statement.h,v
50 retrieving revision 1.21
51 diff -r1.21 Statement.h
53 < void setParsedData(ParsedData *pData) { parsedData = pData; }
54 < void setDbMgr(DatabaseManager *dbmgr) { dbMgr = dbmgr; }
56 > virtual void setParsedData(ParsedData *pData) { parsedData = pData; }
57 > virtual void setDbMgr(DatabaseManager *dbmgr) { dbMgr = dbmgr; }
62 < void *fetch(DbRetVal &rv);
63 < void *fetchAndPrint(bool SQL);
66 > virtual void *fetch();
67 > virtual void *fetch(DbRetVal &rv);
68 > virtual void *fetchAndPrint(bool SQL);
69 > virtual void *next();
71 > class SetStatement : public SelStatement
75 > SelStatement *rightStmt;
77 > void setParsedData(ParsedData *pData);
78 > void setRightStmt(SelStatement *stmt){ rightStmt = stmt; }
79 > DbRetVal execute(int &rowsAffected);
81 > void *fetch(DbRetVal &rv);
82 > void *fetchAndPrint(bool SQL);
84 > void setDbMgr(DatabaseManager *dbmgr);
86 > DbRetVal setBindField(int pos, void* value);
87 > DbRetVal setShortParam(int paramNo, short value);
88 > DbRetVal setParam(int paramNo, void *value);
89 > DbRetVal setIntParam(int paramNo, int value);
90 > DbRetVal setLongParam(int paramNo, long value);
91 > DbRetVal setLongLongParam(int paramNo, long long value);
92 > DbRetVal setByteIntParam(int paramNo, ByteInt value);
93 > DbRetVal setFloatParam(int paramNo, float value);
94 > DbRetVal setDoubleParam(int paramNo, double value);
95 > DbRetVal setStringParam(int paramNo, char *value);
96 > DbRetVal setDateParam(int paramNo, Date value);
97 > DbRetVal setTimeParam(int paramNo, Time value);
98 > DbRetVal setTimeStampParam(int paramNo, TimeStamp value);
99 > DbRetVal setBinaryParam(int paramNo, void *value, int length);
100 > bool isFldNull(int pos);
101 > bool isFldNull(char *fldName);
102 > int getFldPos(char *name);
104 > DbRetVal getProjFldInfo (int projpos, FieldInfo *&fInfo);
105 > DbRetVal getParamFldInfo(int paramPos, FieldInfo *&info);
108 > DbRetVal resolve();
113 Index: src/Makefile.am
114 ===================================================================
115 RCS file: /cvsroot/csql/csql/src/Makefile.am,v
116 retrieving revision 1.15
117 diff -r1.15 Makefile.am
119 < SUBDIRS = storage adapter gateway sqllog sqlnetwork sql cache network jdbc odbc tools
121 > SUBDIRS = storage adapter gateway sqllog sqlnetwork sql cache network jdbc odbc tools
122 Index: src/sql/DelStatement.cxx
123 ===================================================================
124 RCS file: /cvsroot/csql/csql/src/sql/DelStatement.cxx,v
125 retrieving revision 1.22
126 diff -r1.22 DelStatement.cxx
128 < if(!(p>=48 && p<=57 || p==45))
130 > if(!(p>=48 && p<=57 || p==45)) {
133 Index: src/sql/InsStatement.cxx
134 ===================================================================
135 RCS file: /cvsroot/csql/csql/src/sql/InsStatement.cxx,v
136 retrieving revision 1.28
137 diff -r1.28 InsStatement.cxx
139 < if(!(p>=48 && p<=57 || p==45) )
141 > if(!(p>=48 && p<=57 || p==45) ) {
144 Index: src/sql/Makefile.am
145 ===================================================================
146 RCS file: /cvsroot/csql/csql/src/sql/Makefile.am,v
147 retrieving revision 1.13
148 diff -r1.13 Makefile.am
150 < AlterTblStatement.cxx
152 > AlterTblStatement.cxx SetStatement.cxx
153 Index: src/sql/ParsedData.cxx
154 ===================================================================
155 RCS file: /cvsroot/csql/csql/src/sql/ParsedData.cxx,v
156 retrieving revision 1.35
157 diff -r1.35 ParsedData.cxx
159 > void ParsedData::print()
161 > printf("PARSED DATA - START \n");
162 > if (getTableName() != NULL) printf ("Table Name : %s\n", getTableName());
163 > printf ("Statement Type : %d\n", getStmtType());
164 > printf ("Query Type : %d\n", qType);
165 > ListIterator iter = tableNameList.getIterator();
167 > while (iter.hasElement())
169 > tname = (TableName*)iter.nextElement();
170 > printf("TABLE NAME %s Alias %s\n", tname->tblName, tname->aliasName);
172 > printf ("INNER=START\n");
173 > if (innerParsedData) innerParsedData->print();
174 > printf ("INNER=END\n");
175 > printf("PARSED DATA - END \n");
177 Index: src/sql/SqlStatement.cxx
178 ===================================================================
179 RCS file: /cvsroot/csql/csql/src/sql/SqlStatement.cxx,v
180 retrieving revision 1.44
181 diff -r1.44 SqlStatement.cxx
183 > if (pData){ delete pData; }
185 < return pData.getTableNameList();
187 > return pData->getTableNameList();
189 > pData= new ParsedData();
191 < this->stmt->setParsedData(&this->pData);
193 > this->stmt->setParsedData(this->pData);
195 < parsedData = &pData;
197 > parsedData = pData;
199 < return pData.getTableName();
201 > return pData->getTableName();
203 < if ((pData.getStmtType() == SelectStatement) || (pData.getStmtType() == MetaStatement)) return true;
205 > if ((pData->getStmtType() == SelectStatement) ||
206 > (pData->getStmtType() == SetSelectStatement) ||
207 > (pData->getStmtType() == MetaStatement)) return true;
209 < if (rv == ErrAlready && pData.getStmtType() == SelectStatement )
211 > if (rv == ErrAlready && (
212 > ( pData->getStmtType() == SelectStatement ) ||
213 > ( pData->getStmtType() == SetSelectStatement )))
216 < if (pData.getStmtType() == SelectStatement ) {
218 > if (pData->getStmtType() == SelectStatement ||
219 > pData->getStmtType() == SetSelectStatement ) {
221 < else if(pData.getStmtType() == MetaStatement){
223 > else if(pData->getStmtType() == MetaStatement){
225 < if (pData.getStmtType() == SelectStatement ) {
227 > if (pData->getStmtType() == SelectStatement ||
228 > pData->getStmtType() == SetSelectStatement ) {
230 < else if(pData.getStmtType() == MetaStatement){
232 > else if(pData->getStmtType() == MetaStatement){
234 < if (pData.getStmtType() != SelectStatement) return NULL;
236 > if (pData->getStmtType() != SelectStatement &&
237 > pData->getStmtType() != SetSelectStatement ) return NULL;
239 < if (pData.getStmtType() == SelectStatement ) {
241 > if (pData->getStmtType() == SelectStatement ||
242 > pData->getStmtType() == SetSelectStatement ) {
244 < else if(pData.getStmtType() == MetaStatement){
246 > else if(pData->getStmtType() == MetaStatement){
248 < if (pData.getStmtType() == SelectStatement ) {
250 > if (pData->getStmtType() == SelectStatement ||
251 > pData->getStmtType() == SetSelectStatement) {
253 < else if(pData.getStmtType() == MetaStatement){
255 > else if(pData->getStmtType() == MetaStatement){
257 < if (pData.getStmtType() != SelectStatement) return 0;
259 > if (pData->getStmtType() != SelectStatement &&
260 > pData->getStmtType() != SetSelectStatement ) return 0;
262 < if (pData.getStmtType() != SelectStatement) return 0;
264 > if (pData->getStmtType() != SelectStatement &&
265 > pData->getStmtType() != SetSelectStatement ) return 0;
267 < if (pData.getStmtType() == SelectStatement ) {
269 > if (pData->getStmtType() == SelectStatement ||
270 > pData->getStmtType() == SetSelectStatement ) {
272 < else if(pData.getStmtType() == MetaStatement){
274 > else if(pData->getStmtType() == MetaStatement){
276 < //if (pData.getStmtType() != SelectStatement) return 0;
278 > //if (pData->getStmtType() != SelectStatement) return 0;
280 < if (pData.getStmtType() == SelectStatement ) {
282 > if (pData->getStmtType() == SelectStatement ||
283 > pData->getStmtType() == SetSelectStatement ) {
285 < else if(pData.getStmtType() == MetaStatement){
287 > else if(pData->getStmtType() == MetaStatement){
289 < if (pData.getStmtType() == SelectStatement ) {
291 > if (pData->getStmtType() == SelectStatement ||
292 > pData->getStmtType() == SetSelectStatement ) {
294 < else if(pData.getStmtType() == MetaStatement){
296 > else if(pData->getStmtType() == MetaStatement){
298 < if (pData.getStmtType() == SelectStatement ) {
300 > if (pData->getStmtType() == SelectStatement ||
301 > pData->getStmtType() == SetSelectStatement ) {
303 < else if(pData.getStmtType() == MetaStatement){
305 > else if(pData->getStmtType() == MetaStatement){
307 < if (pData.getStmtType() == SelectStatement ) {
309 > if (pData->getStmtType() == SelectStatement ||
310 > pData->getStmtType() == SetSelectStatement ) {
312 < else if(pData.getStmtType() == MetaStatement){
314 > else if(pData->getStmtType() == MetaStatement){
316 < if (pData.getStmtType() == SelectStatement ) {
318 > if (pData->getStmtType() == SelectStatement ||
319 > pData->getStmtType() == SetSelectStatement ) {
321 < else if(pData.getStmtType() == MetaStatement){
323 > else if(pData->getStmtType() == MetaStatement){
325 < if (pData.getStmtType() == SelectStatement ) {
327 > if (pData->getStmtType() == SelectStatement ||
328 > pData->getStmtType() == SetSelectStatement ) {
330 < else if(pData.getStmtType() == MetaStatement){
332 > else if(pData->getStmtType() == MetaStatement){
334 < if (pData.getStmtType() == SelectStatement ) {
336 > if (pData->getStmtType() == SelectStatement ||
337 > pData->getStmtType() == SetSelectStatement ) {
339 < else if(pData.getStmtType() == MetaStatement){
341 > else if(pData->getStmtType() == MetaStatement){
343 < if (pData.getStmtType() == SelectStatement ) {
345 > if (pData->getStmtType() == SelectStatement ||
346 > pData->getStmtType() == SetSelectStatement ) {
348 < else if(pData.getStmtType() == MetaStatement){
350 > else if(pData->getStmtType() == MetaStatement){
352 < if (pData.getStmtType() ==SelectStatement ||
353 < pData.getStmtType() ==InsertStatement ||
354 < pData.getStmtType() ==UpdateStatement ||
355 < pData.getStmtType() ==DeleteStatement)
357 > if (pData->getStmtType() ==SelectStatement ||
358 > pData->getStmtType() ==SetSelectStatement ||
359 > pData->getStmtType() ==InsertStatement ||
360 > pData->getStmtType() ==UpdateStatement ||
361 > pData->getStmtType() ==DeleteStatement)
371 < if (pData.getStmtType() == InsertStatement||
372 < pData.getStmtType() == UpdateStatement||
373 < pData.getStmtType() == DeleteStatement)
375 > if (pData->getStmtType() == InsertStatement||
376 > pData->getStmtType() == UpdateStatement||
377 > pData->getStmtType() == DeleteStatement)
378 Index: src/sql/StatementFactory.cxx
379 ===================================================================
380 RCS file: /cvsroot/csql/csql/src/sql/StatementFactory.cxx,v
381 retrieving revision 1.6
382 diff -r1.6 StatementFactory.cxx
384 > case SetSelectStatement: {
385 > ParsedData *iter = data;
386 > Statement *subStmt = new SetStatement();
387 > SelStatement *inStmt = NULL;
388 > //TODO:: the below works only for two table union
389 > while(iter->innerParsedData)
391 > if (iter->innerParsedData->innerParsedData) {
392 > inStmt = new SetStatement();
393 > inStmt->setParsedData(iter->innerParsedData);
394 > ((SetStatement*)subStmt)->setRightStmt(inStmt);
396 > inStmt = new SelStatement();
397 > inStmt->setParsedData(iter->innerParsedData);
398 > ((SetStatement*)subStmt)->setRightStmt(inStmt);
400 > iter = iter->innerParsedData;
405 Index: src/sql/dmllex.lxx
406 ===================================================================
407 RCS file: /cvsroot/csql/csql/src/sql/dmllex.lxx,v
408 retrieving revision 1.23
409 diff -r1.23 dmllex.lxx
411 > if(strcasecmp(yytext,"UNION") ==0) token = UNION;
412 > if(strcasecmp(yytext,"ALL") ==0) token = ALL;
413 Index: src/sql/dmlyacc.h
414 ===================================================================
415 RCS file: /cvsroot/csql/csql/src/sql/dmlyacc.h,v
416 retrieving revision 1.30
417 diff -r1.30 dmlyacc.h
420 < #define PASSWORD 356
439 < #define DISTINCT 375
444 > #define PASSWORD 358
463 > #define DISTINCT 377
467 Index: src/sql/dmlyacc.yxx
468 ===================================================================
469 RCS file: /cvsroot/csql/csql/src/sql/dmlyacc.yxx,v
470 retrieving revision 1.48
471 diff -r1.48 dmlyacc.yxx
476 < %token <stringval> DATE_DIFF DATE_ADD DATE_SUB HOUR MINUTE SECOND YEAR MONTH DAY INTERVAL TIME_DIFF TIME_ADD TIME_SUB TIMESTAMP_DIFF TIMESTAMP_ADD TIMESTAMP_SUB EXTRACT NOW
478 > %token <stringval> DATE_DIFF DATE_ADD DATE_SUB HOUR MINUTE SECOND YEAR MONTH DAY INTERVAL TIME_DIFF TIME_ADD TIME_SUB TIMESTAMP_DIFF TIMESTAMP_ADD TIMESTAMP_SUB EXTRACT NOW UNION ALL
480 > %type <pData> select_statement select_query_term select_query_expression subquery
482 > %type <intVal> set_op
484 < command: select_statement { YYACCEPT; }
486 > command: select_query_expression { YYACCEPT; }
488 < select_statement: opt_explain SELECT opt_distinct field_list FROM table_list where_clause_opt group_by_opt having_opt order_by_opt limit_opt semicolon_opt
490 > select_query_expression: select_query_term semicolon_opt
492 > printf("select_query_expression evaluated\n");
493 > *parsedData = *(ParsedData*)$1;
496 > |select_query_term set_op select_query_term semicolon_opt
497 > //|select_query_expression set_op select_query_term semicolon_opt
499 > printf("UNION evaluated %s\n", ((ParsedData*)$3)->getTableName());
500 > //parsedData->print();
501 > *parsedData = * ((ParsedData*)$1);
502 > parsedData->setInnerParsedData((ParsedData*)$3);
503 > parsedData->setSubQueryType((SubQueryType)$2);
504 > parsedData->setStmtType(SetSelectStatement);
518 > select_query_term: select_statement
520 > printf("select_query_term evaluated\n");
523 > | '(' select_statement ')'
525 > printf("select_query_term bracket evaluated\n");
529 > subquery: '(' select_statement ')'
531 > printf("subquery evaluated\n");
535 > select_statement: opt_explain SELECT opt_distinct field_list FROM table_list where_clause_opt group_by_opt having_opt order_by_opt limit_opt
537 > printf("select_statement evaluated\n");
539 > ParsedData *newP = new ParsedData();
540 > *newP = *parsedData;
541 > parsedData->init();
544 > | ident not_opt IN subquery
546 > printf("IN SUBQUERY TODO\n");
548 > | ident OPERATOR subquery
550 > printf("OPERATOR SUBQUERY TODO\n");