src/sql/SqlStatement.cxx File Reference

#include "Statement.h"
#include <SqlStatement.h>
#include <dmllex.h>

Include dependency graph for SqlStatement.cxx:

Go to the source code of this file.

Functions

int yyparse ()

Variables

char * lexInput
ParsedDataparsedData


Function Documentation

int yyparse (  ) 

Definition at line 374 of file dmlyacc.cxx.

References CreateIndexStatement, CreateTableStatement, DeleteStatement, DropIndexStatement, DropTableStatement, AllDataType::getComparisionOperator(), ParsedData::getInValueList(), List::getIterator(), ListIterator::hasElement(), hashIndex, ParsedData::insertCondValueAndGetPtr(), ParsedData::insertField(), ParsedData::insertFldDef(), ParsedData::insertInValue(), ParsedData::insertPredicate(), InsertStatement, ParsedData::insertUpdateValue(), ParsedData::insertValue(), ListIterator::nextElement(), OpAnd, OpEquals, OpGreaterThanEquals, OpLessThanEquals, OpNot, OpOr, parsedData, FieldValue::parsedString, YYSTYPE::predicate, SelectStatement, ParsedData::setCondition(), ParsedData::setDefaultValue(), ParsedData::setFldLength(), ParsedData::setFldName(), ParsedData::setFldNotNull(), ParsedData::setFldType(), ParsedData::setIndexName(), ParsedData::setIndexType(), ParsedData::setPrimary(), ParsedData::setStmtType(), ParsedData::setTableName(), ParsedData::setUnique(), YYSTYPE::stringval, treeIndex, typeByteInt, typeDate, typeDouble, typeFloat, typeInt, typeLong, typeLongLong, typeShort, typeString, typeTime, typeTimeStamp, UpdateStatement, YYACCEPT, yychar, yycheck, YYDEBUG, yydebug, yydefred, yydgoto, YYERRCODE, yyerrflag, yyerror(), YYFINAL, yygindex, yylen, yylex(), yylhs, yylval, YYMAXTOKEN, yynerrs, YYPREFIX, yyrindex, yysindex, yyss, yyssp, yystacksize, yytable, YYTABLESIZE, yyval, yyvs, and yyvsp.

Referenced by SqlStatement::prepare().

00375 {
00376     register int yym, yyn, yystate;
00377 #if YYDEBUG
00378     register char *yys;
00379     extern char *getenv();
00380 
00381     if (yys = getenv("YYDEBUG"))
00382     {
00383         yyn = *yys;
00384         if (yyn >= '0' && yyn <= '9')
00385             yydebug = yyn - '0';
00386     }
00387 #endif
00388 
00389     yynerrs = 0;
00390     yyerrflag = 0;
00391     yychar = (-1);
00392 
00393     yyssp = yyss;
00394     yyvsp = yyvs;
00395     *yyssp = yystate = 0;
00396 
00397 yyloop:
00398     if (yyn = yydefred[yystate]) goto yyreduce;
00399     if (yychar < 0)
00400     {
00401         if ((yychar = yylex()) < 0) yychar = 0;
00402 #if YYDEBUG
00403         if (yydebug)
00404         {
00405             yys = 0;
00406             if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
00407             if (!yys) yys = "illegal-symbol";
00408             printf("%sdebug: state %d, reading %d (%s)\n",
00409                     YYPREFIX, yystate, yychar, yys);
00410         }
00411 #endif
00412     }
00413     if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
00414             yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
00415     {
00416 #if YYDEBUG
00417         if (yydebug)
00418             printf("%sdebug: state %d, shifting to state %d\n",
00419                     YYPREFIX, yystate, yytable[yyn]);
00420 #endif
00421         if (yyssp >= yyss + yystacksize - 1)
00422         {
00423             goto yyoverflow;
00424         }
00425         *++yyssp = yystate = yytable[yyn];
00426         *++yyvsp = yylval;
00427         yychar = (-1);
00428         if (yyerrflag > 0)  --yyerrflag;
00429         goto yyloop;
00430     }
00431     if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
00432             yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
00433     {
00434         yyn = yytable[yyn];
00435         goto yyreduce;
00436     }
00437     if (yyerrflag) goto yyinrecovery;
00438 #ifdef lint
00439     goto yynewerror;
00440 #endif
00441 yynewerror:
00442     yyerror("syntax error");
00443 #ifdef lint
00444     goto yyerrlab;
00445 #endif
00446 yyerrlab:
00447     ++yynerrs;
00448 yyinrecovery:
00449     if (yyerrflag < 3)
00450     {
00451         yyerrflag = 3;
00452         for (;;)
00453         {
00454             if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
00455                     yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
00456             {
00457 #if YYDEBUG
00458                 if (yydebug)
00459                     printf("%sdebug: state %d, error recovery shifting\
00460  to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
00461 #endif
00462                 if (yyssp >= yyss + yystacksize - 1)
00463                 {
00464                     goto yyoverflow;
00465                 }
00466                 *++yyssp = yystate = yytable[yyn];
00467                 *++yyvsp = yylval;
00468                 goto yyloop;
00469             }
00470             else
00471             {
00472 #if YYDEBUG
00473                 if (yydebug)
00474                     printf("%sdebug: error recovery discarding state %d\n",
00475                             YYPREFIX, *yyssp);
00476 #endif
00477                 if (yyssp <= yyss) goto yyabort;
00478                 --yyssp;
00479                 --yyvsp;
00480             }
00481         }
00482     }
00483     else
00484     {
00485         if (yychar == 0) goto yyabort;
00486 #if YYDEBUG
00487         if (yydebug)
00488         {
00489             yys = 0;
00490             if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
00491             if (!yys) yys = "illegal-symbol";
00492             printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
00493                     YYPREFIX, yystate, yychar, yys);
00494         }
00495 #endif
00496         yychar = (-1);
00497         goto yyloop;
00498     }
00499 yyreduce:
00500 #if YYDEBUG
00501     if (yydebug)
00502         printf("%sdebug: state %d, reducing by rule %d (%s)\n",
00503                 YYPREFIX, yystate, yyn, yyrule[yyn]);
00504 #endif
00505     yym = yylen[yyn];
00506     yyval = yyvsp[1-yym];
00507     switch (yyn)
00508     {
00509 case 1:
00510 #line 33 "dmlyacc.yxx"
00511 { YYACCEPT; }
00512 break;
00513 case 2:
00514 #line 34 "dmlyacc.yxx"
00515 { YYACCEPT; }
00516 break;
00517 case 3:
00518 #line 35 "dmlyacc.yxx"
00519 { YYACCEPT; }
00520 break;
00521 case 4:
00522 #line 36 "dmlyacc.yxx"
00523 { YYACCEPT; }
00524 break;
00525 case 5:
00526 #line 37 "dmlyacc.yxx"
00527 { YYACCEPT; }
00528 break;
00529 case 6:
00530 #line 41 "dmlyacc.yxx"
00531 {
00532             parsedData->setStmtType(SelectStatement);
00533             parsedData->setTableName(yyvsp[-2].stringval); 
00534             free(yyvsp[-2].stringval);
00535         }
00536 break;
00537 case 10:
00538 #line 55 "dmlyacc.yxx"
00539 {
00540             parsedData->setStmtType(InsertStatement);
00541             parsedData->setTableName(yyvsp[-6].stringval); 
00542             free(yyvsp[-6].stringval);
00543         }
00544 break;
00545 case 14:
00546 #line 68 "dmlyacc.yxx"
00547 {
00548             parsedData->insertValue((char*)yyvsp[0].stringval);
00549             free(yyvsp[0].stringval);
00550         }
00551 break;
00552 case 15:
00553 #line 74 "dmlyacc.yxx"
00554 {
00555             parsedData->insertValue((char*)yyvsp[0].stringval);
00556             free(yyvsp[0].stringval);
00557         }
00558 break;
00559 case 17:
00560 #line 82 "dmlyacc.yxx"
00561 {
00562             parsedData->insertInValue((char*)yyvsp[0].stringval);
00563             free(yyvsp[0].stringval);
00564         }
00565 break;
00566 case 18:
00567 #line 88 "dmlyacc.yxx"
00568 {
00569             parsedData->insertInValue((char*)yyvsp[0].stringval);
00570             free(yyvsp[0].stringval);
00571         }
00572 break;
00573 case 19:
00574 #line 95 "dmlyacc.yxx"
00575 {
00576             parsedData->setStmtType(DeleteStatement);
00577             parsedData->setTableName(yyvsp[-2].stringval); 
00578             free(yyvsp[-2].stringval);
00579         }
00580 break;
00581 case 20:
00582 #line 103 "dmlyacc.yxx"
00583 {
00584             parsedData->setStmtType(UpdateStatement);
00585             parsedData->setTableName(yyvsp[-4].stringval); 
00586             free( yyvsp[-4].stringval );
00587         }
00588 break;
00589 case 26:
00590 #line 121 "dmlyacc.yxx"
00591 { 
00592             parsedData->insertUpdateValue( (char*) yyvsp[-2].stringval, (char*) yyvsp[0].stringval);
00593             free( yyvsp[-2].stringval ); free(yyvsp[-1].stringval);free( yyvsp[0].stringval ); 
00594         }
00595 break;
00596 case 29:
00597 #line 132 "dmlyacc.yxx"
00598 {
00599             Predicate *pred;
00600             pred = parsedData->insertPredicate((Predicate*) yyvsp[-2].predicate, OpAnd, (Predicate*) yyvsp[0].predicate);
00601             parsedData->setCondition((Predicate*)pred);
00602             yyval.predicate= pred;
00603 
00604         }
00605 break;
00606 case 30:
00607 #line 140 "dmlyacc.yxx"
00608 {
00609             Predicate *pred;
00610             pred = parsedData->insertPredicate((Predicate*) yyvsp[-2].predicate, OpOr, (Predicate*) yyvsp[0].predicate);
00611             parsedData->setCondition((Predicate*)pred);
00612             yyval.predicate= pred;
00613         }
00614 break;
00615 case 31:
00616 #line 147 "dmlyacc.yxx"
00617 {
00618             Predicate *pred;
00619             pred = parsedData->insertPredicate((Predicate*) yyvsp[0].predicate, OpNot, NULL);
00620             parsedData->setCondition((Predicate*)pred);
00621             yyval.predicate= pred;
00622         }
00623 break;
00624 case 32:
00625 #line 153 "dmlyacc.yxx"
00626 { }
00627 break;
00628 case 33:
00629 #line 155 "dmlyacc.yxx"
00630 {
00631             parsedData->setCondition((Predicate*)yyvsp[0].predicate);
00632             /*((Predicate*)$1)->print();*/
00633             yyval.predicate=yyvsp[0].predicate;
00634         }
00635 break;
00636 case 34:
00637 #line 162 "dmlyacc.yxx"
00638 {
00639             ComparisionOp  op = AllDataType::getComparisionOperator((char*)yyvsp[-1].stringval);
00640             Predicate *pred;
00641             void **ptr = parsedData->insertCondValueAndGetPtr((char*)yyvsp[-2].stringval, (char*)yyvsp[0].stringval);
00642             pred = parsedData->insertPredicate((char*) yyvsp[-2].stringval, op, ptr);
00643             free( yyvsp[-2].stringval ); free(yyvsp[-1].stringval); free( yyvsp[0].stringval ); 
00644             yyval.predicate=pred;
00645         }
00646 break;
00647 case 35:
00648 #line 171 "dmlyacc.yxx"
00649 {
00650             ComparisionOp  op = AllDataType::getComparisionOperator((char*)yyvsp[-1].stringval);
00651             Predicate *pred;
00652             pred = parsedData->insertPredicate((char*) yyvsp[-2].stringval, op, (char*) yyvsp[0].stringval);
00653             free( yyvsp[-2].stringval ); free(yyvsp[-1].stringval); free( yyvsp[0].stringval );
00654             yyval.predicate=pred;
00655         }
00656 break;
00657 case 36:
00658 #line 180 "dmlyacc.yxx"
00659 {
00660             void **ptr1 = parsedData->insertCondValueAndGetPtr((char*)yyvsp[-5].stringval, (char*)yyvsp[-2].stringval);
00661             void **ptr2 = parsedData->insertCondValueAndGetPtr((char*)yyvsp[-5].stringval, (char*)yyvsp[0].stringval);
00662             Predicate *pred1, *pred2, *pred3, *finalPred;
00663             pred1 = parsedData->insertPredicate((char*) yyvsp[-5].stringval, OpGreaterThanEquals, ptr1);
00664             pred2 = parsedData->insertPredicate((char*) yyvsp[-5].stringval, OpLessThanEquals, ptr2);
00665             finalPred = parsedData->insertPredicate(pred1, OpAnd, pred2);
00666             if( yyvsp[-4].stringval == (char*) 1 )
00667                 finalPred = parsedData->insertPredicate(finalPred, OpNot, NULL);
00668             free( yyvsp[-5].stringval );  free( yyvsp[-2].stringval );  free( yyvsp[0].stringval );
00669             yyval.predicate= finalPred;
00670         }
00671 break;
00672 case 37:
00673 #line 193 "dmlyacc.yxx"
00674 {
00675             ListIterator valIter = parsedData->getInValueList().getIterator();
00676             FieldValue *value1, *value2;
00677             Predicate *pred1, *pred2, *finalPred;
00678             void **ptr1, **ptr2;
00679             if (valIter.hasElement()) {
00680                value1 = (FieldValue*) valIter.nextElement();
00681                ptr1 = parsedData->insertCondValueAndGetPtr((char*)yyvsp[-5].stringval, value1->parsedString);
00682                pred1 = parsedData->insertPredicate((char*) yyvsp[-5].stringval, OpEquals, ptr1);
00683                finalPred=pred1;
00684             }
00685             while (valIter.hasElement()) {
00686                value2 = (FieldValue*) valIter.nextElement();
00687                ptr2 = parsedData->insertCondValueAndGetPtr((char*)yyvsp[-5].stringval, value2->parsedString);
00688                pred2 = parsedData->insertPredicate((char*) yyvsp[-5].stringval, OpEquals, ptr2);
00689                finalPred = parsedData->insertPredicate(pred1, OpOr, pred2);
00690                pred1= finalPred;     
00691             }
00692             if( yyvsp[-4].stringval == (char*)1)
00693                 finalPred = parsedData->insertPredicate(finalPred, OpNot, NULL);
00694 
00695             free( yyvsp[-5].stringval );  
00696             yyval.predicate= finalPred;
00697         }
00698 break;
00699 case 38:
00700 #line 219 "dmlyacc.yxx"
00701 { yyval.stringval=(char*) 1;
00702         }
00703 break;
00704 case 39:
00705 #line 222 "dmlyacc.yxx"
00706 { yyval.stringval=(char*) 0; }
00707 break;
00708 case 40:
00709 #line 225 "dmlyacc.yxx"
00710 {
00711             parsedData->insertField((char*)yyvsp[0].stringval);
00712             free( yyvsp[0].stringval );
00713         }
00714 break;
00715 case 41:
00716 #line 230 "dmlyacc.yxx"
00717 { 
00718             parsedData->insertField((char*)yyvsp[0].stringval);
00719             free( yyvsp[0].stringval );
00720         }
00721 break;
00722 case 42:
00723 #line 235 "dmlyacc.yxx"
00724 { yyval.stringval = yyvsp[0].stringval; }
00725 break;
00726 case 43:
00727 #line 237 "dmlyacc.yxx"
00728 { yyval.stringval = yyvsp[0].stringval; }
00729 break;
00730 case 44:
00731 #line 238 "dmlyacc.yxx"
00732 { yyval.stringval = yyvsp[0].stringval; }
00733 break;
00734 case 45:
00735 #line 239 "dmlyacc.yxx"
00736 { yyval.stringval = yyvsp[0].stringval; }
00737 break;
00738 case 46:
00739 #line 240 "dmlyacc.yxx"
00740 { yyval.stringval = yyvsp[0].stringval; }
00741 break;
00742 case 47:
00743 #line 241 "dmlyacc.yxx"
00744 { yyval.stringval = yyvsp[0].stringval; }
00745 break;
00746 case 48:
00747 #line 242 "dmlyacc.yxx"
00748 { yyval.stringval = (char*) 0; }
00749 break;
00750 case 49:
00751 #line 246 "dmlyacc.yxx"
00752 {
00753             parsedData->setStmtType(CreateTableStatement);
00754             parsedData->setTableName(yyvsp[-4].stringval); 
00755             free(yyvsp[-4].stringval);
00756         }
00757 break;
00758 case 50:
00759 #line 252 "dmlyacc.yxx"
00760 {
00761             parsedData->setStmtType(CreateIndexStatement);
00762             parsedData->setIndexName(yyvsp[-8].stringval); 
00763             parsedData->setTableName(yyvsp[-6].stringval); 
00764             free(yyvsp[-8].stringval);
00765             free(yyvsp[-6].stringval);
00766         }
00767 break;
00768 case 51:
00769 #line 260 "dmlyacc.yxx"
00770 {
00771             parsedData->setStmtType(DropTableStatement);
00772             parsedData->setTableName(yyvsp[0].stringval); 
00773             free(yyvsp[0].stringval);
00774         }
00775 break;
00776 case 52:
00777 #line 266 "dmlyacc.yxx"
00778 {
00779             parsedData->setStmtType(DropIndexStatement);
00780             parsedData->setIndexName(yyvsp[0].stringval); 
00781             free(yyvsp[0].stringval);
00782         }
00783 break;
00784 case 54:
00785 #line 274 "dmlyacc.yxx"
00786 {
00787             parsedData->setIndexType(hashIndex);
00788         }
00789 break;
00790 case 55:
00791 #line 278 "dmlyacc.yxx"
00792 {
00793             parsedData->setIndexType(treeIndex);
00794         }
00795 break;
00796 case 56:
00797 #line 282 "dmlyacc.yxx"
00798 {
00799             parsedData->setIndexType(hashIndex);
00800         }
00801 break;
00802 case 58:
00803 #line 288 "dmlyacc.yxx"
00804 {
00805             parsedData->setUnique(true);
00806         }
00807 break;
00808 case 59:
00809 #line 292 "dmlyacc.yxx"
00810 {
00811             parsedData->setUnique(true);
00812             parsedData->setPrimary(true);
00813         }
00814 break;
00815 case 60:
00816 #line 297 "dmlyacc.yxx"
00817 {
00818             parsedData->setUnique(false);
00819             parsedData->setPrimary(false);
00820         }
00821 break;
00822 case 64:
00823 #line 310 "dmlyacc.yxx"
00824 {
00825             parsedData->insertFldDef();
00826         }
00827 break;
00828 case 67:
00829 #line 320 "dmlyacc.yxx"
00830 {
00831             parsedData->setFldName(yyvsp[0].stringval);
00832             free(yyvsp[0].stringval);
00833         }
00834 break;
00835 case 69:
00836 #line 326 "dmlyacc.yxx"
00837 {
00838             parsedData->setFldLength(atoi(yyvsp[-1].stringval)+1);
00839             free(yyvsp[-1].stringval);
00840         }
00841 break;
00842 case 71:
00843 #line 334 "dmlyacc.yxx"
00844 {
00845             parsedData->setDefaultValue(yyvsp[0].stringval);
00846             free(yyvsp[0].stringval);
00847         }
00848 break;
00849 case 73:
00850 #line 342 "dmlyacc.yxx"
00851 {
00852             parsedData->setFldNotNull(true);
00853         }
00854 break;
00855 case 75:
00856 #line 350 "dmlyacc.yxx"
00857 {
00858             parsedData->setPrimary(true);
00859         }
00860 break;
00861 case 76:
00862 #line 356 "dmlyacc.yxx"
00863 {
00864             parsedData->setFldType(typeInt);
00865         }
00866 break;
00867 case 77:
00868 #line 360 "dmlyacc.yxx"
00869 {
00870             parsedData->setFldType(typeLong);
00871         }
00872 break;
00873 case 78:
00874 #line 364 "dmlyacc.yxx"
00875 {
00876             parsedData->setFldType(typeShort);
00877         }
00878 break;
00879 case 79:
00880 #line 368 "dmlyacc.yxx"
00881 {
00882             parsedData->setFldType(typeLongLong);
00883         }
00884 break;
00885 case 80:
00886 #line 372 "dmlyacc.yxx"
00887 {
00888             parsedData->setFldType(typeByteInt);
00889         }
00890 break;
00891 case 81:
00892 #line 376 "dmlyacc.yxx"
00893 {
00894             parsedData->setFldType(typeFloat);
00895         }
00896 break;
00897 case 82:
00898 #line 380 "dmlyacc.yxx"
00899 {
00900             parsedData->setFldType(typeDouble);
00901         }
00902 break;
00903 case 83:
00904 #line 385 "dmlyacc.yxx"
00905 {
00906             parsedData->setFldType(typeDate);
00907         }
00908 break;
00909 case 84:
00910 #line 390 "dmlyacc.yxx"
00911 {
00912             parsedData->setFldType(typeTime);
00913         }
00914 break;
00915 case 85:
00916 #line 395 "dmlyacc.yxx"
00917 {
00918             parsedData->setFldType(typeTimeStamp);
00919         }
00920 break;
00921 case 86:
00922 #line 400 "dmlyacc.yxx"
00923 {
00924             parsedData->setFldType(typeString);
00925             parsedData->setFldLength(2);
00926         }
00927 break;
00928 #line 929 "dmlyacc.cxx"
00929     }
00930     yyssp -= yym;
00931     yystate = *yyssp;
00932     yyvsp -= yym;
00933     yym = yylhs[yyn];
00934     if (yystate == 0 && yym == 0)
00935     {
00936 #if YYDEBUG
00937         if (yydebug)
00938             printf("%sdebug: after reduction, shifting from state 0 to\
00939  state %d\n", YYPREFIX, YYFINAL);
00940 #endif
00941         yystate = YYFINAL;
00942         *++yyssp = YYFINAL;
00943         *++yyvsp = yyval;
00944         if (yychar < 0)
00945         {
00946             if ((yychar = yylex()) < 0) yychar = 0;
00947 #if YYDEBUG
00948             if (yydebug)
00949             {
00950                 yys = 0;
00951                 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
00952                 if (!yys) yys = "illegal-symbol";
00953                 printf("%sdebug: state %d, reading %d (%s)\n",
00954                         YYPREFIX, YYFINAL, yychar, yys);
00955             }
00956 #endif
00957         }
00958         if (yychar == 0) goto yyaccept;
00959         goto yyloop;
00960     }
00961     if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
00962             yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
00963         yystate = yytable[yyn];
00964     else
00965         yystate = yydgoto[yym];
00966 #if YYDEBUG
00967     if (yydebug)
00968         printf("%sdebug: after reduction, shifting from state %d \
00969 to state %d\n", YYPREFIX, *yyssp, yystate);
00970 #endif
00971     if (yyssp >= yyss + yystacksize - 1)
00972     {
00973         goto yyoverflow;
00974     }
00975     *++yyssp = yystate;
00976     *++yyvsp = yyval;
00977     goto yyloop;
00978 yyoverflow:
00979     yyerror("yacc stack overflow");
00980 yyabort:
00981     return (1);
00982 yyaccept:
00983     return (0);
00984 }

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

char* lexInput

Definition at line 24 of file SqlStatement.cxx.

Referenced by SqlStatement::prepare().

ParsedData* parsedData

Definition at line 16 of file dmlyacc.cxx.

Referenced by SqlStatement::prepare(), and yyparse().


Generated on Mon Jun 9 22:42:11 2008 for csql by  doxygen 1.4.7