Beispiel #1
0
  public boolean visit(SQLVariantRefExpr x) {
    print(x.getName());

    String collate = (String) x.getAttribute("COLLATE");
    if (collate != null) {
      print(" COLLATE ");
      print(collate);
    }

    return false;
  }
Beispiel #2
0
  public static boolean visit(SQLEvalVisitor visitor, SQLVariantRefExpr x) {
    if (!"?".equals(x.getName())) {
      return false;
    }

    Map<String, Object> attributes = x.getAttributes();

    int varIndex = x.getIndex();

    if (varIndex != -1 && visitor.getParameters().size() > varIndex) {
      boolean containsValue = attributes.containsKey(EVAL_VALUE);
      if (!containsValue) {
        Object value = visitor.getParameters().get(varIndex);
        attributes.put(EVAL_VALUE, value);
      }
    }

    return false;
  }
Beispiel #3
0
  public SQLExpr primary() {
    final Token tok = lexer.token();

    if (identifierEquals("outfile")) {
      lexer.nextToken();
      SQLExpr file = primary();
      SQLExpr expr = new MySqlOutFileExpr(file);

      return primaryRest(expr);
    }

    switch (tok) {
      case TRUE:
        lexer.nextToken();
        return primaryRest(new MySqlBooleanExpr(true));
      case FALSE:
        lexer.nextToken();
        return primaryRest(new MySqlBooleanExpr(false));
      case LITERAL_ALIAS:
        String aliasValue = lexer.stringVal();
        lexer.nextToken();
        return primaryRest(new SQLCharExpr(aliasValue));
      case VARIANT:
        SQLVariantRefExpr varRefExpr = new SQLVariantRefExpr(lexer.stringVal());
        lexer.nextToken();
        if (varRefExpr.getName().equalsIgnoreCase("@@global")) {
          accept(Token.DOT);
          varRefExpr = new SQLVariantRefExpr(lexer.stringVal(), true);
          lexer.nextToken();
        } else if (varRefExpr.getName().equals("@") && lexer.token() == Token.LITERAL_CHARS) {
          varRefExpr.setName("@'" + lexer.stringVal() + "'");
          lexer.nextToken();
        } else if (varRefExpr.getName().equals("@@") && lexer.token() == Token.LITERAL_CHARS) {
          varRefExpr.setName("@@'" + lexer.stringVal() + "'");
          lexer.nextToken();
        }
        return primaryRest(varRefExpr);
      case VALUES:
        lexer.nextToken();
        if (lexer.token() != Token.LPAREN) {
          throw new ParserException("syntax error, illegal values clause");
        }
        return this.methodRest(new SQLIdentifierExpr("VALUES"), true);
      case BINARY:
        lexer.nextToken();
        if (lexer.token() == Token.COMMA
            || lexer.token() == Token.SEMI
            || lexer.token() == Token.EOF) {
          return new SQLIdentifierExpr("BINARY");
        } else {
          SQLUnaryExpr binaryExpr = new SQLUnaryExpr(SQLUnaryOperator.BINARY, expr());
          return primaryRest(binaryExpr);
        }
      case GROUP:
        lexer.nextToken();
        return primaryRest(new SQLIdentifierExpr(lexer.stringVal()));
      default:
        return super.primary();
    }
  }