⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 axionsqlparser.java

📁 开源的axion的数据库代码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    jj_consume_token(CONSTRAINT);    constraintname = SqlIdentifier();        {if (true) return new DropConstraintCommand(tablename,constraintname);}    throw new Error("Missing return statement in function");  }  final public AxionCommand SqlAddConstraint(String tablename) throws ParseException {    Constraint constraint = null;    jj_consume_token(ADD);    constraint = SqlTableConstraint();        if(null == constraint) {            {if (true) return null;}        } else {            {if (true) return new AddConstraintCommand(tablename,constraint);}        }    throw new Error("Missing return statement in function");  }// ----------------------------------------------------------------------------// COMMANDS: DROP// ----------------------------------------------------------------------------  final public AxionCommand SqlDrop() throws ParseException {    AxionCommand result = null;    jj_consume_token(DROP);     if(_log.isDebugEnabled()) { _log.debug("SqlDrop: consumed \"" + token + "\""); }    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {    case TABLE:      result = SqlDropTable();      break;    case SEQUENCE:      result = SqlDropSequence();      break;    default:      jj_consume_token(-1);      throw new ParseException();    }    {if (true) return result;}    throw new Error("Missing return statement in function");  }  final public AxionCommand SqlDropTable() throws ParseException {    DropTableCommand result = null;    String tableName = null;    boolean exists = false;    jj_consume_token(TABLE);       if(_log.isDebugEnabled()) {  _log.debug("SqlDropTable: consumed \"" + token + "\""); }    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {    case IF:      jj_consume_token(IF);      jj_consume_token(EXISTS);            exists = true;      break;    default:      ;    }    tableName = SqlIdentifier();       if(_log.isDebugEnabled()) { _log.debug("SqlDropTable: found table name  \"" + tableName + "\""); }       result = new DropTableCommand(tableName, exists);    {if (true) return result;}    throw new Error("Missing return statement in function");  }  final public AxionCommand SqlDropSequence() throws ParseException {    DropSequenceCommand result = null;    String sequenceName = null;    jj_consume_token(SEQUENCE);       if(_log.isDebugEnabled()) {  _log.debug("SqlDropSequence: consumed \"" + token + "\""); }    sequenceName = SqlIdentifier();       if(_log.isDebugEnabled()) { _log.debug("SqlDropSequence: found sequence name  \"" + sequenceName + "\""); }       result = new DropSequenceCommand(sequenceName);    {if (true) return result;}    throw new Error("Missing return statement in function");  }// ----------------------------------------------------------------------------// COMMANDS: INSERT// ----------------------------------------------------------------------------  final public AxionCommand SqlInsert() throws ParseException {    TableIdentifier table = null;    List columns = null;    List values = null;    jj_consume_token(INSERT);    jj_consume_token(INTO);    table = SqlTableRef();    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {    case OPENPAREN:      jj_consume_token(OPENPAREN);      columns = SqlSelectCols();      jj_consume_token(CLOSEPAREN);      break;    default:      ;    }    jj_consume_token(VALUES);    jj_consume_token(OPENPAREN);    values = SqlSelectList();    jj_consume_token(CLOSEPAREN);    {if (true) return new InsertCommand(table, columns, values);}    throw new Error("Missing return statement in function");  }// ----------------------------------------------------------------------------// COMMANDS: SELECT// ----------------------------------------------------------------------------  final public AxionCommand SqlSelect() throws ParseException {   SelectCommand result = new SelectCommand();   List temp = null;   Selectable where = null;   List order = null;   Literal limit = null;   Literal offset = null;   FromNode from = null;    jj_consume_token(SELECT);    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {    case ALL:    case DISTINCT:      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {      case ALL:        jj_consume_token(ALL);        result.setDistinct(false);        break;      case DISTINCT:        jj_consume_token(DISTINCT);        result.setDistinct(true);        break;      default:        jj_consume_token(-1);        throw new ParseException();      }      break;    default:      ;    }    // can gather all cols here and add to builder as list      // or one at a time farther down the parse tree      // problem is, farther down the parse tree, might not      // know we're getting column identifiers, might need to      // pass column identifiers back to production where      // context is obvious      temp = SqlSelectCols();    result.setSelect(temp);    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {    case FROM:      jj_consume_token(FROM);      from = SqlFrom();         result.setFrom(from);      break;    default:      ;    }    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {    case WHERE:      where = SqlWhere();      break;    default:      ;    }    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {    case ORDER:      order = SqlOrderBy();      break;    default:      ;    }    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {    case LIMIT:      limit = SqlSelectLimit();      break;    default:      ;    }    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {    case OFFSET:      offset = SqlSelectOffset();      break;    default:      ;    }    result.setWhere((WhereNode)where);    result.setOrderBy(order);    result.setLimit(limit);    result.setOffset(offset);    {if (true) return result;}    throw new Error("Missing return statement in function");  }  final public List SqlSelectCols() throws ParseException {  List list = new ArrayList();    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {    case CASE:    case FALSE:    case NOT:    case NULL:    case SYSDATE:    case TRUE:    case INTEGER_LITERAL:    case FLOATING_POINT_LITERAL:    case STRING_LITERAL:    case ID:    case OPENPAREN:    case ASTERISK:    case PLUS:    case MINUS:    case QUESTIONMARK:      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {      case ASTERISK:        jj_consume_token(ASTERISK);        list.add(new ColumnIdentifier("*"));        break;      case CASE:      case FALSE:      case NOT:      case NULL:      case SYSDATE:      case TRUE:      case INTEGER_LITERAL:      case FLOATING_POINT_LITERAL:      case STRING_LITERAL:      case ID:      case OPENPAREN:      case PLUS:      case MINUS:      case QUESTIONMARK:        list = SqlSelectList();        break;      default:        jj_consume_token(-1);        throw new ParseException();      }      break;    default:      ;    }    {if (true) return list;}    throw new Error("Missing return statement in function");  }  final public Literal SqlSelectLimit() throws ParseException {  Literal limit = null;    jj_consume_token(LIMIT);    limit = SqlNumericLiteralOrBindVar();    {if (true) return limit;}    throw new Error("Missing return statement in function");  }  final public Literal SqlSelectOffset() throws ParseException {  Literal offset = null;    jj_consume_token(OFFSET);    offset = SqlNumericLiteralOrBindVar();    {if (true) return offset;}    throw new Error("Missing return statement in function");  }  final public Literal SqlNumericLiteralOrBindVar() throws ParseException {  Literal value = null;    value = SqlLiteralOrBindVar();     try {        if(!(value instanceof BindVariable || value.evaluate(null) instanceof Number)) {           {if (true) throw new ParseException("Expected numeric literal or bind variable.");}        }     } catch(AxionException e) {        {if (true) throw new ParseException("AxionException " + e.toString() + " while parsing OFFSET. Shouldn't happen.");}     }    {if (true) return value;}    throw new Error("Missing return statement in function");  }  final public Literal SqlLiteralOrBindVar() throws ParseException {  Literal value = null;    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {    case FALSE:    case NULL:    case TRUE:    case INTEGER_LITERAL:    case FLOATING_POINT_LITERAL:    case STRING_LITERAL:    case ASTERISK:      value = SqlLiteral();      break;    case QUESTIONMARK:      value = SqlBindVar();      break;    default:      jj_consume_token(-1);      throw new ParseException();    }    {if (true) return value;}    throw new Error("Missing return statement in function");  }// ----------------------------------------------------------------------------// COMMANDS: UPDATE// ----------------------------------------------------------------------------  final public AxionCommand SqlUpdate() throws ParseException {    TableIdentifier table = null;    List colvalpairs = new ArrayList();    Selectable where = null;    Selectable[] curpair = null;    jj_consume_token(UPDATE);    table = SqlTableRef();    jj_consume_token(SET);    label_4:    while (true) {      curpair = SqlUpdateAssignment();      colvalpairs.add(curpair);      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {      case COMMA:        jj_consume_token(COMMA);        break;      default:        ;      }      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {      case ID:        ;        break;      default:        break label_4;      }    }    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {    case WHERE:      where = SqlWhere();      break;    default:      ;    }        UpdateCommand cmd = new UpdateCommand();        cmd.setTable(table);        Iterator iter = colvalpairs.iterator();        while(iter.hasNext()) {            Selectable[] pair = (Selectable[])(iter.next());            cmd.addColumn((ColumnIdentifier)pair[0]);            cmd.addValue(pair[1]);        }        cmd.setWhere((WhereNode)where);        {if (true) return cmd;}    throw new Error("Missing return statement in function");  }  final public Selectable[] SqlUpdateAssignment() throws ParseException {    Selectable[] pair = new Selectable[2];    pair[0] = SqlColumnRef();    jj_consume_token(EQUAL);    // akl: Be careful, we may run into "Halloween problem" here. Statements      // such as "update table t set a = a + 1" tend to go into a infinite      // recursive loop doing a = a + 1.      //pair[1] = SqlSelectableElements() // no expressions in update statement.      pair[1] = SqlSumExprSelectable();    {if (true) return pair;}    throw new Error("Missing return statement in function");  }// ----------------------------------------------------------------------------// CONSTRAINTS// ----------------------------------------------------------------------------  final public Constraint SqlTableConstraint() throws ParseException {    Constraint constraint = null;    String name = null;    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {    case CONSTRAINT:      jj_consume_token(CONSTRAINT);      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {      case ID:        name = SqlIdentifier();        break;      default:        ;      }      break;    default:      ;    }    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {    case NOT:    case NULL:    case PRIMARY:    case UNIQUE:      constraint = SqlSelectableBasedConstraintType(name);      SqlSelectableBasedConstraintArgs((SelectableBasedConstraint)constraint);      break;    case CHECK:      constraint = SqlCheckConstraintType(name);      break;    default:      jj_consume_token(-1);      throw new ParseException();    }    if (jj_2_1(2)) {      SqlDeferrable(constraint);    } else {      ;    }    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {    case INITIALLY:      SqlInitiallyDeferredOrImmediate(constraint);      break;    default:      ;    }        {if (true) return constraint;}    throw new Error("Missing return statement in function");  }  final public Constraint SqlColumnConstraint(String tablename, String columnname) throws ParseException {    Constraint constraint = null;    String name = null;    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {    case CONSTRAINT:      jj_consume_token(CONSTRAINT);      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {      case ID:        name = SqlIdentifier();        break;      default:        ;      }      break;    default:      ;    }    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {    case NOT:    case NULL:    case PRIMARY:    case UNIQUE:      constraint = SqlSelectableBasedConstraintType(name);                ((SelectableBasedConstraint)constraint).addSelectable(new ColumnIdentifier(new TableIdentifier(tablename),columnname));      break;    case CHECK:      constraint = SqlCheckConstraintType(name);      break;    default:      jj_consume_token(-1);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -