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

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


                        "), Begin compiling prepared statement: " +
                        getSource() +
                        " :End prepared statement");
        }

        Parser p = cc.getParser();

        cc.setCurrentDependent(preparedStmt);

        //Only top level statements go through here, nested statement
        //will invoke this method from other places
        StatementNode qt = p.parseStatement(statementText, paramDefaults);

        parseTime = getCurrentTimeMillis(lcc);

                // Call user-written tree-printer if it exists
                walkAST( lcc, qt, ASTVisitor.AFTER_PARSE);
View Full Code Here


    if (internalSQL)
        newCC.setReliability(CompilerContext.INTERNAL_SQL_LEGAL);

    try
    {
      Parser p = newCC.getParser();
      return p.parseStatement(sql);
    }

    finally
    {
      lcc.popCompilerContext(newCC);
View Full Code Here

     String        clauseText,
     TableDescriptor    td
    )
    throws StandardException
  {
    Parser            p;
    ValueNode          clauseTree;
    LanguageConnectionContext  lcc = getLanguageConnectionContext();
    CompilerContext       compilerContext = getCompilerContext();

    /* Get a Statement to pass to the parser */

    /* We're all set up to parse. We have to build a compilable SQL statement
     * before we can parse -  So, we goober up a VALUES defaultText.
     */
    String select = "SELECT " + clauseText + " FROM " + td.getQualifiedName();
   
    /*
    ** Get a new compiler context, so the parsing of the select statement
    ** doesn't mess up anything in the current context (it could clobber
    ** the ParameterValueSet, for example).
    */
    CompilerContext newCC = lcc.pushCompilerContext();

    p = newCC.getParser();
       
    /* Finally, we can call the parser */
    // Since this is always nested inside another SQL statement, so topLevel flag
    // should be false
    StatementNode qt = p.parseStatement(select);
    if (SanityManager.DEBUG)
    {
      if (! (qt instanceof CursorNode))
      {
        SanityManager.THROWASSERT(
View Full Code Here

    String        checkConstraintText,
    TableDescriptor    td
    )
    throws StandardException
  {
    Parser            p;
    ValueNode          checkTree;
    LanguageConnectionContext  lcc = getLanguageConnectionContext();
    CompilerContext       compilerContext = getCompilerContext();

    /* Get a Statement to pass to the parser */

    /* We're all set up to parse. We have to build a compile SQL statement
     * before we can parse - we just have a WHERE clause right now.
     * So, we goober up a SELECT * FROM table WHERE checkDefs.
     */
    String select = "SELECT * FROM " +
                  td.getQualifiedName() +
                  " WHERE " +
                  checkConstraintText;
   
    /*
    ** Get a new compiler context, so the parsing of the select statement
    ** doesn't mess up anything in the current context (it could clobber
    ** the ParameterValueSet, for example).
    */
    CompilerContext newCC = lcc.pushCompilerContext();

    p = newCC.getParser();
       
    /* Finally, we can call the parser */
    // Since this is always nested inside another SQL statement, so topLevel flag
    // should be false
    StatementNode qt = p.parseStatement(select);
    if (SanityManager.DEBUG)
    {
      if (! (qt instanceof CursorNode))
      {
        SanityManager.THROWASSERT(
View Full Code Here

      // Here we get the trigger action sql and use the parser to build
      // the parse tree for it.
      SchemaDescriptor compSchema;
      compSchema = dd.getSchemaDescriptor(trd.getSchemaDescriptor().getUUID(), null);
      CompilerContext newCC = lcc.pushCompilerContext(compSchema);
      Parser  pa = newCC.getParser();
      StatementNode stmtnode = (StatementNode)pa.parseStatement(trd.getTriggerDefinition());
      lcc.popCompilerContext(newCC);
      // Do not delete following. We use this in finally clause to
      // determine if the CompilerContext needs to be popped.
      newCC = null;
     
      try {
        // We are interested in ColumnReference classes in the parse tree
        CollectNodesVisitor visitor = new CollectNodesVisitor(ColumnReference.class);
        stmtnode.accept(visitor);
        Vector refs = visitor.getList();
       
        // Regenerate the internal representation for the trigger action
        // sql using the ColumnReference classes in the parse tree. It
        // will catch dropped column getting used in trigger action sql
        // through the REFERENCING clause(this can happen only for the
        // the triggers created prior to 10.7. Trigger created with
        // 10.7 and higher keep track of trigger action column used
        // through the REFERENCING clause in system table and hence
        // use of dropped column will be detected earlier in this
        // method for such triggers).
        //
        // We might catch errors like following during this step.
        // Say that following pre-10.7 trigger exists in the system and
        // user is dropping column c11. During the regeneration of the
        // internal trigger action sql format, we will catch that
        // column oldt.c11 does not exist anymore
        // CREATE TRIGGER DERBY4998_SOFT_UPGRADE_RESTRICT_tr1
        //    AFTER UPDATE OF c12
        //    ON DERBY4998_SOFT_UPGRADE_RESTRICT REFERENCING OLD AS oldt
        //    FOR EACH ROW
        //    SELECT oldt.c11 from DERBY4998_SOFT_UPGRADE_RESTRICT

        SPSDescriptor triggerActionSPSD = trd.getActionSPS(lcc);
        int[] referencedColsInTriggerAction = new int[td.getNumberOfColumns()];
        java.util.Arrays.fill(referencedColsInTriggerAction, -1);
        triggerActionSPSD.setText(dd.getTriggerActionString(stmtnode,
          trd.getOldReferencingName(),
          trd.getNewReferencingName(),
          trd.getTriggerDefinition(),
          trd.getReferencedCols(),
          referencedColsInTriggerAction,
          0,
          trd.getTableDescriptor(),
          trd.getTriggerEventMask(),
          true
          ));
       
        // Now that we have the internal format of the trigger action sql,
        // bind that sql to make sure that we are not using colunm being
        // dropped in the trigger action sql directly (ie not through
        // REFERENCING clause.
        // eg
        // create table atdc_12 (a integer, b integer);
        // create trigger atdc_12_trigger_1 after update of a
        //     on atdc_12 for each row select a,b from atdc_12
        // Drop one of the columns used in the trigger action
        //   alter table atdc_12 drop column b
        // Following rebinding of the trigger action sql will catch the use
        // of column b in trigger atdc_12_trigger_1
        compSchema = dd.getSchemaDescriptor(trd.getSchemaDescriptor().getUUID(), null);
        newCC = lcc.pushCompilerContext(compSchema);
          newCC.setReliability(CompilerContext.INTERNAL_SQL_LEGAL);
        pa = newCC.getParser();
        stmtnode = (StatementNode)pa.parseStatement(triggerActionSPSD.getText());
        // need a current dependent for bind
        newCC.setCurrentDependent(triggerActionSPSD.getPreparedStatement());
        stmtnode.bindStatement();
        //Register the dependency between trigger table and trigger
        // action SPS
View Full Code Here

            {
              ViewDescriptor vd = (ViewDescriptor) dep;
              SchemaDescriptor compSchema;
              compSchema = dd.getSchemaDescriptor(vd.getCompSchemaId(), null);
              CompilerContext newCC = lcc.pushCompilerContext(compSchema);
              Parser  pa = newCC.getParser();

              // Since this is always nested inside another SQL
              // statement, so topLevel flag should be false
              CreateViewNode cvn = (CreateViewNode)pa.parseStatement(
                        vd.getViewText());

              // need a current dependent for bind
              newCC.setCurrentDependent(dep);
              cvn.bindStatement();
View Full Code Here

  (
    String        defaultText
    )
    throws StandardException
  {
    Parser            p;
    ValueNode          defaultTree;
    LanguageConnectionContext  lcc = getLanguageConnectionContext();
    CompilerContext       compilerContext = getCompilerContext();

    /* Get a Statement to pass to the parser */

    /* We're all set up to parse. We have to build a compilable SQL statement
     * before we can parse -  So, we goober up a VALUES defaultText.
     */
    String values = "VALUES " + defaultText;
   
    /*
    ** Get a new compiler context, so the parsing of the select statement
    ** doesn't mess up anything in the current context (it could clobber
    ** the ParameterValueSet, for example).
    */
    CompilerContext newCC = lcc.pushCompilerContext();

    p = newCC.getParser();
       
    /* Finally, we can call the parser */
    // Since this is always nested inside another SQL statement, so topLevel flag
    // should be false
    StatementNode qt = p.parseStatement(values);
    if (SanityManager.DEBUG)
    {
      if (! (qt instanceof CursorNode))
      {
        SanityManager.THROWASSERT(
View Full Code Here

                        "), Begin compiling prepared statement: " +
                        getSource() +
                        " :End prepared statement");
        }

        Parser p = cc.getParser();

        cc.setCurrentDependent(preparedStmt);

        //Only top level statements go through here, nested statement
        //will invoke this method from other places
        StatementNode qt = p.parseStatement(statementText, paramDefaults);

        parseTime = getCurrentTimeMillis(lcc);

        if (SanityManager.DEBUG)
        {
View Full Code Here

         isRow && (referencingOld || referencingNew))
    {
      SchemaDescriptor compSchema;
      compSchema = getDataDictionary().getSchemaDescriptor(triggerSchemaId, null);
      CompilerContext newCC = lcc.pushCompilerContext(compSchema);
      Parser  pa = newCC.getParser();
      StatementNode stmtnode = (StatementNode)pa.parseStatement(triggerDefinition);
      lcc.popCompilerContext(newCC);
         
      actionSPS.setText(getDataDictionary().getTriggerActionString(stmtnode,
          oldReferencingName,
          newReferencingName,
View Full Code Here

     String        clauseText,
     TableDescriptor    td
    )
    throws StandardException
  {
    Parser            p;
    ValueNode          clauseTree;
    LanguageConnectionContext  lcc = getLanguageConnectionContext();
    CompilerContext       compilerContext = getCompilerContext();

    /* Get a Statement to pass to the parser */

    /* We're all set up to parse. We have to build a compilable SQL statement
     * before we can parse -  So, we goober up a VALUES defaultText.
     */
    String select = "SELECT " + clauseText + " FROM " + td.getQualifiedName();
   
    /*
    ** Get a new compiler context, so the parsing of the select statement
    ** doesn't mess up anything in the current context (it could clobber
    ** the ParameterValueSet, for example).
    */
    CompilerContext newCC = lcc.pushCompilerContext();

    p = newCC.getParser();
       
    /* Finally, we can call the parser */
    // Since this is always nested inside another SQL statement, so topLevel flag
    // should be false
    StatementNode qt = p.parseStatement(select);
    if (SanityManager.DEBUG)
    {
      if (! (qt instanceof CursorNode))
      {
        SanityManager.THROWASSERT(
View Full Code Here

TOP

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

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.