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

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


        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

      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 = 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

    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

     *    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

     *        >=    AND
     *           /   \
     *          <=    TRUE
     */

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

        QueryTreeNode trueNode = nodeFactory.getNode(
                      C_NodeTypes.BOOLEAN_CONSTANT_NODE,
                      Boolean.TRUE,
                      cm);

    /* Create the AND <= */
    BinaryComparisonOperatorNode lessEqual =
      (BinaryComparisonOperatorNode) nodeFactory.getNode(
            C_NodeTypes.BINARY_LESS_EQUALS_OPERATOR_NODE,
            leftClone1,
            rightOperandList.elementAt(1),
            cm);

    /* Set type info for the operator node */
    lessEqual.bindComparisonOperator();

    /* Create the AND */
    AndNode newAnd = (AndNode) nodeFactory.getNode(
                        C_NodeTypes.AND_NODE,
                        lessEqual,
                        trueNode,
                        cm);
    newAnd.postBindFixup();

    /* Create the AND >= */
    BinaryComparisonOperatorNode greaterEqual =
      (BinaryComparisonOperatorNode) nodeFactory.getNode(
          C_NodeTypes.BINARY_GREATER_EQUALS_OPERATOR_NODE,
          leftOperand,
          rightOperandList.elementAt(0),
          cm);

    /* Set type info for the operator node */
    greaterEqual.bindComparisonOperator();

    /* Create the AND */
    newAnd = (AndNode) nodeFactory.getNode(
                        C_NodeTypes.AND_NODE,
                        greaterEqual,
                        newAnd,
                        cm);
    newAnd.postBindFixup();
View Full Code Here

     *    leftO between rightOList.elementAt(0) and rightOList.elementAt(1)
     * to:
     *    leftO >= rightOList.elementAt(0) and leftO <= rightOList.elementAt(1)
     */

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

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

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

    /* Create and return the AND */
    newAnd = (AndNode) nodeFactory.getNode(
                        C_NodeTypes.AND_NODE,
                        leftBCO,
                        rightBCO,
                        cm);
    newAnd.postBindFixup();
View Full Code Here

    String    columnName
  )
    throws StandardException
  {
    ContextManager  cm = getContextManager();
    NodeFactory    nodeFactory = getNodeFactory();

    ResultColumn  rc = (ResultColumn) nodeFactory.getNode
      (
        C_NodeTypes.RESULT_COLUMN,
        columnName,
        nodeFactory.getNode
        (
          C_NodeTypes.COLUMN_REFERENCE,
          columnName,
          tableName,
          cm
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 (DeleteNode) nodeFactory.getNode(
                                                    C_NodeTypes.DELETE_NODE,
                                                    tableName,
                                                    resultSet,
                                                    getContextManager());

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.