Package org.apache.derby.iapi.sql.compile

Examples of org.apache.derby.iapi.sql.compile.NodeFactory


     *    leftO < rightOList.elementAt(0) or leftO > rightOList.elementAt(1)
     * NOTE - We do the conversion here since ORs will eventually be
     * optimizable and there's no benefit for the optimizer to see NOT BETWEEN
     */

    NodeFactory nodeFactory = getNodeFactory();
    ContextManager cm = getContextManager();

    /* leftO < rightOList.elementAt(0) */
    leftBCO = (BinaryComparisonOperatorNode)
          nodeFactory.getNode(
                  C_NodeTypes.BINARY_LESS_THAN_OPERATOR_NODE,
                  leftOperand,
                   rightOperandList.elementAt(0),
                  cm);
    /* Set type info for the operator node */
    leftBCO.bindComparisonOperator();

        // DERBY-4388: If leftOperand is a ColumnReference, it may be remapped
        // during optimization, and that requires the less-than node and the
        // greater-than node to have separate objects.
        ValueNode leftClone = (leftOperand instanceof ColumnReference) ?
            leftOperand.getClone() : leftOperand;

    /* leftO > rightOList.elementAt(1) */
    rightBCO = (BinaryComparisonOperatorNode)
          nodeFactory.getNode(
                C_NodeTypes.BINARY_GREATER_THAN_OPERATOR_NODE,
                leftClone,
                rightOperandList.elementAt(1),
                cm);
    /* Set type info for the operator node */
    rightBCO.bindComparisonOperator();

    /* Create and return the OR */
    newOr = (OrNode) nodeFactory.getNode(
                        C_NodeTypes.OR_NODE,
                        leftBCO,
                        rightBCO,
                        cm);
    newOr.postBindFixup();
View Full Code Here


  public ValueNode putAndsOnTop()
          throws StandardException
  {
    BinaryComparisonOperatorNode    equalsNode;
    BooleanConstantNode  trueNode;
    NodeFactory    nodeFactory = getNodeFactory();
    ValueNode    andNode;

        trueNode = (BooleanConstantNode) nodeFactory.getNode(
                    C_NodeTypes.BOOLEAN_CONSTANT_NODE,
                    Boolean.TRUE,
                    getContextManager());
    equalsNode = (BinaryComparisonOperatorNode)
            nodeFactory.getNode(
                    C_NodeTypes.BINARY_EQUALS_OPERATOR_NODE,
                    this,
                    trueNode,
                    getContextManager());
    /* Set type info for the operator node */
    equalsNode.bindComparisonOperator();
    andNode = (ValueNode) nodeFactory.getNode(
                  C_NodeTypes.AND_NODE,
                  equalsNode,
                  trueNode,
                  getContextManager());
    ((AndNode) andNode).postBindFixup();
View Full Code Here

    private void pushOrderingDown( ResultSetNode rsn)
        throws StandardException
    {
        ContextManager cm = getContextManager();
        NodeFactory nf = getNodeFactory();
        OrderByList orderByList = (OrderByList) nf.getNode( C_NodeTypes.ORDER_BY_LIST, cm);
        for( int i = 0; i < intermediateOrderByColumns.length; i++)
        {
            OrderByColumn orderByColumn = (OrderByColumn)
              nf.getNode( C_NodeTypes.ORDER_BY_COLUMN,
        nf.getNode(C_NodeTypes.INT_CONSTANT_NODE,
             ReuseFactory.getInteger( intermediateOrderByColumns[i] + 1),
             cm),
                          cm);
            if( intermediateOrderByDirection[i] < 0)
                orderByColumn.setDescending();
View Full Code Here

      throws StandardException
  {
    BinaryRelationalOperatorNode equalsNode;
    BooleanConstantNode     falseNode;
    boolean         nullableResult;
    NodeFactory        nodeFactory = getNodeFactory();

    falseNode = (BooleanConstantNode) nodeFactory.getNode(
                  C_NodeTypes.BOOLEAN_CONSTANT_NODE,
                  Boolean.FALSE,
                  getContextManager());
    equalsNode = (BinaryRelationalOperatorNode)
              nodeFactory.getNode(
                C_NodeTypes.BINARY_EQUALS_OPERATOR_NODE,
                this,
                falseNode,
                getContextManager());
    nullableResult = getTypeServices().isNullable();
View Full Code Here

   * @exception StandardException    Thrown on error
   */
  public ValueNode putAndsOnTop()
          throws StandardException
  {
    NodeFactory    nodeFactory = getNodeFactory();

        QueryTreeNode trueNode = (QueryTreeNode) nodeFactory.getNode(
                    C_NodeTypes.BOOLEAN_CONSTANT_NODE,
                    Boolean.TRUE,
                    getContextManager());
    AndNode andNode = (AndNode) nodeFactory.getNode(
                    C_NodeTypes.AND_NODE,
                    this,
                    trueNode,
                    getContextManager());
    andNode.postBindFixup();
View Full Code Here

        ValueNode whereClause = null;

        TableName tableName = new TableName();
        tableName.init(schemaName , targetTableName);

        NodeFactory nodeFactory = getNodeFactory();
        FromList   fromList = (FromList) nodeFactory.getNode(C_NodeTypes.FROM_LIST, getContextManager());
        FromTable fromTable = (FromTable) nodeFactory.getNode(
                                                    C_NodeTypes.FROM_BASE_TABLE,
                                                    tableName,
                                                    null,
                                                    ReuseFactory.getInteger(FromBaseTable.DELETE),
                                                    null,
                                                    getContextManager());

    //we would like to use references index & table scan instead of
    //what optimizer says for the dependent table scan.
    Properties targetProperties = new FormatableProperties();
    targetProperties.put("index", "null");
    ((FromBaseTable) fromTable).setTableProperties(targetProperties);

        fromList.addFromTable(fromTable);
        SelectNode resultSet = (SelectNode) nodeFactory.getNode(
                                                     C_NodeTypes.SELECT_NODE,
                                                     null,
                                                     null,   /* AGGREGATE list */
                                                     fromList, /* FROM list */
                                                     whereClause, /* WHERE clause */
                                                     null, /* GROUP BY list */
                                                     null, /* having clause */
                           null, /* windows */
                           getContextManager());

        return (StatementNode) nodeFactory.getNode(
                                                    C_NodeTypes.DELETE_NODE,
                                                    tableName,
                                                    resultSet,
                                                    getContextManager());

View Full Code Here

        ValueNode whereClause = null;

        TableName tableName = new TableName();
        tableName.init(schemaName , targetTableName);

        NodeFactory nodeFactory = getNodeFactory();
        FromList   fromList = (FromList) nodeFactory.getNode(C_NodeTypes.FROM_LIST, getContextManager());
        FromTable fromTable = (FromTable) nodeFactory.getNode(
                                                    C_NodeTypes.FROM_BASE_TABLE,
                                                    tableName,
                                                    null,
                                                    ReuseFactory.getInteger(FromBaseTable.DELETE),
                                                    null,
                                                    getContextManager());


    //we would like to use references index & table scan instead of
    //what optimizer says for the dependent table scan.
    Properties targetProperties = new FormatableProperties();
    targetProperties.put("index", "null");
    ((FromBaseTable) fromTable).setTableProperties(targetProperties);

        fromList.addFromTable(fromTable);

        SelectNode resultSet = (SelectNode) nodeFactory.getNode(
                                                     C_NodeTypes.SELECT_NODE,
                                                     getSetClause(tableName, cdl),
                                                     null,   /* AGGREGATE list */
                                                     fromList, /* FROM list */
                                                     whereClause, /* WHERE clause */
                                                     null, /* GROUP BY list */
                           null, /* having clause */
                           null, /* windows */
                                                     getContextManager());

        return (StatementNode) nodeFactory.getNode(
                                                    C_NodeTypes.UPDATE_NODE,
                                                    tableName,
                                                    resultSet,
                                                    getContextManager());

View Full Code Here

    throws StandardException
  {
    ResultColumn resultColumn;
    ValueNode   valueNode;

    NodeFactory nodeFactory = getNodeFactory();
    ResultColumnList  columnList = (ResultColumnList) nodeFactory.getNode(
                        C_NodeTypes.RESULT_COLUMN_LIST,
                        getContextManager());

    valueNode =  (ValueNode) nodeFactory.getNode(C_NodeTypes.UNTYPED_NULL_CONSTANT_NODE,
                               getContextManager());
    for(int index =0 ; index < cdl.size() ; index++)
    {
      ColumnDescriptor cd = (ColumnDescriptor) cdl.elementAt(index);
      //only columns that are nullable need to be set to 'null' for ON
      //DELETE SET NULL
      if((cd.getType()).isNullable())
      {
        resultColumn = (ResultColumn) nodeFactory.getNode(
                         C_NodeTypes.RESULT_COLUMN,
                    cd,
                    valueNode,
                    getContextManager());
View Full Code Here

  public  ConstantNode getNullNode(TypeId typeId,
      ContextManager cm)
    throws StandardException
  {
    QueryTreeNode constantNode = null;
    NodeFactory nf = getNodeFactory();

    switch (typeId.getJDBCTypeId())
    {
      case Types.VARCHAR:
      constantNode =  nf.getNode(
                    C_NodeTypes.VARCHAR_CONSTANT_NODE,
                    typeId,
                    cm);
      break;

      case Types.CHAR:
      constantNode = nf.getNode(
                    C_NodeTypes.CHAR_CONSTANT_NODE,
                    typeId,
                    cm);
      break;

      case Types.TINYINT:
      constantNode = nf.getNode(
                    C_NodeTypes.TINYINT_CONSTANT_NODE,
                    typeId,
                    cm);
      break;

      case Types.SMALLINT:
      constantNode = nf.getNode(
                    C_NodeTypes.SMALLINT_CONSTANT_NODE,
                    typeId,
                    cm);
      break;

      case Types.INTEGER:
      constantNode = nf.getNode(
                    C_NodeTypes.INT_CONSTANT_NODE,
                    typeId,
                    cm);
      break;

      case Types.BIGINT:
      constantNode = nf.getNode(
                    C_NodeTypes.LONGINT_CONSTANT_NODE,
                    typeId,
                    cm);
      break;

      case Types.REAL:
      constantNode = nf.getNode(
                    C_NodeTypes.FLOAT_CONSTANT_NODE,
                    typeId,
                    cm);
      break;

      case Types.DOUBLE:
      constantNode = nf.getNode(
                    C_NodeTypes.DOUBLE_CONSTANT_NODE,
                    typeId,
                    cm);
      break;

      case Types.NUMERIC:
      case Types.DECIMAL:
      constantNode = nf.getNode(
                    C_NodeTypes.DECIMAL_CONSTANT_NODE,
                    typeId,
                    cm);
      break;

      case Types.DATE:
      case Types.TIME:
      case Types.TIMESTAMP:
      constantNode = nf.getNode(
                    C_NodeTypes.USERTYPE_CONSTANT_NODE,
                    typeId,
                    cm);
      break;

      case Types.BINARY:
      constantNode = nf.getNode(
                    C_NodeTypes.BIT_CONSTANT_NODE,
                    typeId,
                    cm);
      break;

      case Types.VARBINARY:
      constantNode = nf.getNode(
                    C_NodeTypes.VARBIT_CONSTANT_NODE,
                    typeId,
                    cm);
      break;

      case Types.LONGVARCHAR:
      constantNode = nf.getNode(
                    C_NodeTypes.LONGVARCHAR_CONSTANT_NODE,
                    typeId,
                    cm);
      break;

      case Types.CLOB:
      constantNode = nf.getNode(
                    C_NodeTypes.CLOB_CONSTANT_NODE,
                    typeId,
                    cm);
      break;

      case Types.LONGVARBINARY:
      constantNode = nf.getNode(
                    C_NodeTypes.LONGVARBIT_CONSTANT_NODE,
                    typeId,
                    cm);
      break;

      case Types.BLOB:
      constantNode = nf.getNode(
                    C_NodeTypes.BLOB_CONSTANT_NODE,
                    typeId,
                    cm);
      break;

      case StoredFormatIds.XML_TYPE_ID:
      constantNode = nf.getNode(
                    C_NodeTypes.XML_CONSTANT_NODE,
                    typeId,
                    cm);
      break;

      default:
      if (typeId.getSQLTypeName().equals("BOOLEAN"))
      {
        constantNode = nf.getNode(
                    C_NodeTypes.BOOLEAN_CONSTANT_NODE,
                    typeId,
                    cm);
      }
      else if ( ! typeId.builtIn())
      {
        constantNode = nf.getNode(
                    C_NodeTypes.USERTYPE_CONSTANT_NODE,
                    typeId,
                    cm);
      }
      else
View Full Code Here

  public  ConstantNode getNullNode(TypeId typeId,
      ContextManager cm)
    throws StandardException
  {
    QueryTreeNode constantNode = null;
    NodeFactory nf = getNodeFactory();

    switch (typeId.getJDBCTypeId())
    {
      case Types.VARCHAR:
      constantNode =  nf.getNode(
                    C_NodeTypes.VARCHAR_CONSTANT_NODE,
                    typeId,
                    cm);
      break;

      case Types.CHAR:
      constantNode = nf.getNode(
                    C_NodeTypes.CHAR_CONSTANT_NODE,
                    typeId,
                    cm);
      break;

      case Types.TINYINT:
      constantNode = nf.getNode(
                    C_NodeTypes.TINYINT_CONSTANT_NODE,
                    typeId,
                    cm);
      break;

      case Types.SMALLINT:
      constantNode = nf.getNode(
                    C_NodeTypes.SMALLINT_CONSTANT_NODE,
                    typeId,
                    cm);
      break;

      case Types.INTEGER:
      constantNode = nf.getNode(
                    C_NodeTypes.INT_CONSTANT_NODE,
                    typeId,
                    cm);
      break;

      case Types.BIGINT:
      constantNode = nf.getNode(
                    C_NodeTypes.LONGINT_CONSTANT_NODE,
                    typeId,
                    cm);
      break;

      case Types.REAL:
      constantNode = nf.getNode(
                    C_NodeTypes.FLOAT_CONSTANT_NODE,
                    typeId,
                    cm);
      break;

      case Types.DOUBLE:
      constantNode = nf.getNode(
                    C_NodeTypes.DOUBLE_CONSTANT_NODE,
                    typeId,
                    cm);
      break;

      case Types.NUMERIC:
      case Types.DECIMAL:
      constantNode = nf.getNode(
                    C_NodeTypes.DECIMAL_CONSTANT_NODE,
                    typeId,
                    cm);
      break;

      case Types.DATE:
      case Types.TIME:
      case Types.TIMESTAMP:
      constantNode = nf.getNode(
                    C_NodeTypes.USERTYPE_CONSTANT_NODE,
                    typeId,
                    cm);
      break;

      case Types.BINARY:
      constantNode = nf.getNode(
                    C_NodeTypes.BIT_CONSTANT_NODE,
                    typeId,
                    cm);
      break;

      case Types.VARBINARY:
      constantNode = nf.getNode(
                    C_NodeTypes.VARBIT_CONSTANT_NODE,
                    typeId,
                    cm);
      break;

      case Types.LONGVARCHAR:
      constantNode = nf.getNode(
                    C_NodeTypes.LONGVARCHAR_CONSTANT_NODE,
                    typeId,
                    cm);
      break;

      case Types.CLOB:
      constantNode = nf.getNode(
                    C_NodeTypes.CLOB_CONSTANT_NODE,
                    typeId,
                    cm);
      break;

      case Types.LONGVARBINARY:
      constantNode = nf.getNode(
                    C_NodeTypes.LONGVARBIT_CONSTANT_NODE,
                    typeId,
                    cm);
      break;

      case Types.BLOB:
      constantNode = nf.getNode(
                    C_NodeTypes.BLOB_CONSTANT_NODE,
                    typeId,
                    cm);
      break;

      case StoredFormatIds.XML_TYPE_ID:
      constantNode = nf.getNode(
                    C_NodeTypes.XML_CONSTANT_NODE,
                    typeId,
                    cm);
      break;

      default:
      if (typeId.getSQLTypeName().equals("BOOLEAN"))
      {
        constantNode = nf.getNode(
                    C_NodeTypes.BOOLEAN_CONSTANT_NODE,
                    typeId,
                    cm);
      }
      else if ( ! typeId.builtIn())
      {
        constantNode = nf.getNode(
                    C_NodeTypes.USERTYPE_CONSTANT_NODE,
                    typeId,
                    cm);
      }
      else
View Full Code Here

TOP

Related Classes of org.apache.derby.iapi.sql.compile.NodeFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.