Package org.apache.derby.iapi.sql.dictionary

Examples of org.apache.derby.iapi.sql.dictionary.ViewDescriptor


    /* Resolve the view, if this is a view */
    if (tableDescriptor.getTableType() == TableDescriptor.VIEW_TYPE)
    {
      FromSubquery                fsq;
      ResultSetNode        rsn;
      ViewDescriptor        vd;
      CreateViewNode        cvn;
      SchemaDescriptor      compSchema;

      /* Get the associated ViewDescriptor so that we can get
       * the view definition text.
       */
      vd = dataDictionary.getViewDescriptor(tableDescriptor);

      /*
      ** Set the default compilation schema to be whatever
      ** this schema this view was originally compiled against.
      ** That way we pick up the same tables no matter what
      ** schema we are running against.
      */
      compSchema = dataDictionary.getSchemaDescriptor(vd.getCompSchemaId(), null);

      compilerContext.pushCompilationSchema(compSchema);
 
      try
      {
   
        /* This represents a view - query is dependent on the ViewDescriptor */
        compilerContext.createDependency(vd);
 
        if (SanityManager.DEBUG)
        {
          SanityManager.ASSERT(vd != null,
            "vd not expected to be null for " + tableName);
        }

        cvn = (CreateViewNode)
                  parseStatement(vd.getViewText(), false);

        rsn = cvn.getParsedQueryExpression();

        /* If the view contains a '*' then we mark the views derived column list
         * so that the view will still work, and return the expected results,
View Full Code Here


   * @exception StandardException    Thrown on error
   */
  private ViewDescriptor getViewDescriptorScan(TableDescriptor tdi)
    throws StandardException
  {
    ViewDescriptor      vd;
    DataValueDescriptor    viewIdOrderable;
    TabInfoImpl          ti = getNonCoreTI(SYSVIEWS_CATALOG_NUM);
    UUID          viewID = tdi.getUUID();

    /* Use viewIdOrderable in both start
     * and stop position for scan.
     */
    viewIdOrderable = getIDValueAsCHAR(viewID);

    /* Set up the start/stop position for the scan */
    ExecIndexRow keyRow = exFactory.getIndexableRow(1);
    keyRow.setColumn(1, viewIdOrderable);

    vd = (ViewDescriptor)
          getDescriptorViaIndex(
            SYSVIEWSRowFactory.SYSVIEWS_INDEX1_ID,
            keyRow,
            (ScanQualifier [][]) null,
            ti,
            (TupleDescriptor) null,
            (List) null,
            false);

    if (vd != null)
    {
      vd.setViewName(tdi.getName());
    }
    return vd;
  }
View Full Code Here

    /* Resolve the view, if this is a view */
    if (tableDescriptor.getTableType() == TableDescriptor.VIEW_TYPE)
    {
      FromTable          fsq;
      ResultSetNode        rsn;
      ViewDescriptor        vd;
      CreateViewNode        cvn;
      SchemaDescriptor      compSchema;
      SchemaDescriptor      prevCompSchema;

      /* Get the associated ViewDescriptor so that we can get
       * the view definition text.
       */
      vd = dataDictionary.getViewDescriptor(tableDescriptor);

      /*
      ** Set the default compilation schema to be whatever
      ** this schema this view was originally compiled against.
      ** That way we pick up the same tables no matter what
      ** schema we are running against.
      */
      compSchema = dataDictionary.getSchemaDescriptor(vd.getCompSchemaId(), null);

      prevCompSchema = compilerContext.setCompilationSchema(compSchema);
 
      try
      {
   
        /* This represents a view - query is dependent on the ViewDescriptor */
        compilerContext.createDependency(vd);
 
        if (SanityManager.DEBUG)
        {
          SanityManager.ASSERT(vd != null,
            "vd not expected to be null for " + tableName);
        }
 
        /*
        ** Push a compiler context to parse the query text so that
        ** it won't clobber the current context.
        */
        LanguageConnectionContext lcc = getLanguageConnectionContext();
        CompilerContext newCC = lcc.pushCompilerContext();
        cvn = (CreateViewNode)
                    QueryTreeNode.parseQueryText(
                        newCC,
                        vd.getViewText(),
                        (DataValueDescriptor[])null,  // default params
                        lcc);

        lcc.popCompilerContext(newCC);

View Full Code Here

    int               checkIType;

    if (td != null)
    {
      UUID  tableUUID;
      ViewDescriptor vd = (ViewDescriptor)td;

      /*
      ** We only allocate a new UUID if the descriptor doesn't already have one.
      ** For descriptors replicated from a Source system, we already have an UUID.
      */
      tableUUID = vd.getUUID();
      if ( tableUUID == null )
        {
        tableUUID = getUUIDFactory().createUUID();
        vd.setUUID(tableUUID);
      }
      tableID = tableUUID.toString();
      viewText = vd.getViewText();

      /* RESOLVE - check constraints not supported yet */
      checkIType = vd.getCheckOptionType();

      if (SanityManager.DEBUG)
      {
        if (checkIType != ViewDescriptor.NO_CHECK_OPTION)
        {
          SanityManager.THROWASSERT("checkIType expected to be " +
            ViewDescriptor.NO_CHECK_OPTION +
            ", not " + checkIType);
        }
      }
      checkSType = "N";

      UUID tmpId = vd.getCompSchemaId();
      compSchemaId = (tmpId == null) ? null : tmpId.toString();
    }

    /* Insert info into sysviews */

 
View Full Code Here

    ExecRow          row,
    TupleDescriptor      parentTupleDescriptor,
    DataDictionary       dd )
          throws StandardException
  {
    ViewDescriptor vd = null;

    if (SanityManager.DEBUG)
    {
      SanityManager.ASSERT(
        row.nColumns() == SYSVIEWS_COLUMN_COUNT,
View Full Code Here

  {
    TableDescriptor       td;
    UUID             toid;
    SchemaDescriptor      schemaDescriptor;
    ColumnDescriptor      columnDescriptor;
    ViewDescriptor        vd;

    LanguageConnectionContext lcc = activation.getLanguageConnectionContext();
    DataDictionary dd = lcc.getDataDictionary();
    DependencyManager dm = dd.getDependencyManager();
    TransactionController tc = lcc.getTransactionExecute();
View Full Code Here

          FormatableBitSet providingCols = td.getReferencedColumnMap();
          if (providingCols == null)
          {
            if (dep instanceof ViewDescriptor)
            {
              ViewDescriptor vd = (ViewDescriptor) dep;
              DataDictionary dd = getDataDictionary();
              SchemaDescriptor compSchema;
              compSchema = dd.getSchemaDescriptor(vd.getCompSchemaId(), null);
              CompilerContext newCC = lcc.pushCompilerContext(compSchema);
              Parser  pa = newCC.getParser();
              LanguageConnectionFactory  lcf = lcc.getLanguageConnectionFactory();

              // 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 = (CreateViewNode) cvn.bind();
              ProviderInfo[] providerInfos = cvn.getProviderInfo();
View Full Code Here

   */
  public void  executeConstantAction( Activation activation )
            throws StandardException
  {
    TableDescriptor td;
    ViewDescriptor vd;

    LanguageConnectionContext lcc = activation.getLanguageConnectionContext();
    DataDictionary dd = lcc.getDataDictionary();
    DependencyManager dm = dd.getDependencyManager();
    TransactionController tc = lcc.getTransactionExecute();

    /*
    ** Inform the data dictionary that we are about to write to it.
    ** There are several calls to data dictionary "get" methods here
    ** that might be done in "read" mode in the data dictionary, but
    ** it seemed safer to do this whole operation in "write" mode.
    **
    ** We tell the data dictionary we're done writing at the end of
    ** the transaction.
    */
    dd.startWriting(lcc);

    /* Get the table descriptor.  We're responsible for raising
     * the error if it isn't found
     */
    td = dd.getTableDescriptor(tableName, sd);

    if (td == null)
    {
      throw StandardException.newException(SQLState.LANG_TABLE_NOT_FOUND_DURING_EXECUTION, fullTableName);
    }

    /* Verify that TableDescriptor represents a view */
    if (td.getTableType() != TableDescriptor.VIEW_TYPE)
    {
      throw StandardException.newException(SQLState.LANG_DROP_VIEW_ON_NON_VIEW, fullTableName);
    }

    vd = dd.getViewDescriptor(td);

    vd.dropViewWork(dd, dm, lcc, tc, sd, td, false);
  }
View Full Code Here

   * @exception StandardException    Thrown on error
   */
  private ViewDescriptor getViewDescriptorScan(TableDescriptor tdi)
    throws StandardException
  {
    ViewDescriptor      vd;
    DataValueDescriptor    viewIdOrderable;
    TabInfo          ti = getNonCoreTI(SYSVIEWS_CATALOG_NUM);
    UUID          viewID = tdi.getUUID();

    /* Use viewIdOrderable in both start
     * and stop position for scan.
     */
    viewIdOrderable = dvf.getCharDataValue(viewID.toString());

    /* Set up the start/stop position for the scan */
    ExecIndexRow keyRow = exFactory.getIndexableRow(1);
    keyRow.setColumn(1, viewIdOrderable);

    vd = (ViewDescriptor)
          getDescriptorViaIndex(
            SYSVIEWSRowFactory.SYSVIEWS_INDEX1_ID,
            keyRow,
            (ScanQualifier [][]) null,
            ti,
            (TupleDescriptor) null,
            (List) null,
            false);

    if (vd != null)
    {
      vd.setViewName(tdi.getName());
    }
    return vd;
  }
View Full Code Here

   */
  public void  executeConstantAction( Activation activation )
            throws StandardException
  {
    TableDescriptor td;
    ViewDescriptor vd;

    LanguageConnectionContext lcc = activation.getLanguageConnectionContext();
    DataDictionary dd = lcc.getDataDictionary();
    DependencyManager dm = dd.getDependencyManager();
    TransactionController tc = lcc.getTransactionExecute();

    /*
    ** Inform the data dictionary that we are about to write to it.
    ** There are several calls to data dictionary "get" methods here
    ** that might be done in "read" mode in the data dictionary, but
    ** it seemed safer to do this whole operation in "write" mode.
    **
    ** We tell the data dictionary we're done writing at the end of
    ** the transaction.
    */
    dd.startWriting(lcc);

    /* Get the table descriptor.  We're responsible for raising
     * the error if it isn't found
     */
    td = dd.getTableDescriptor(tableName, sd);

    if (td == null)
    {
      throw StandardException.newException(SQLState.LANG_TABLE_NOT_FOUND_DURING_EXECUTION, fullTableName);
    }

    /* Verify that TableDescriptor represents a view */
    if (td.getTableType() != TableDescriptor.VIEW_TYPE)
    {
      throw StandardException.newException(SQLState.LANG_DROP_VIEW_ON_NON_VIEW, fullTableName);
    }

    vd = dd.getViewDescriptor(td);

    vd.dropViewWork(dd, dm, lcc, tc, sd, td, false);
  }
View Full Code Here

TOP

Related Classes of org.apache.derby.iapi.sql.dictionary.ViewDescriptor

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.