Examples of CreateUpdateProcedureCommand


Examples of org.teiid.query.sql.proc.CreateUpdateProcedureCommand

            + "BEGIN " //$NON-NLS-1$
            + "declare string x = '1'; " //$NON-NLS-1$
            +"select * from xmltest.doc1 where node1 = x; " //$NON-NLS-1$
            +"end "; //$NON-NLS-1$

        CreateUpdateProcedureCommand command = (CreateUpdateProcedureCommand) helpResolve(sql);
       
        CommandStatement cmdStmt = (CommandStatement)command.getBlock().getStatements().get(1);
       
        CompareCriteria criteria = (CompareCriteria)((Query)cmdStmt.getCommand()).getCriteria();
       
        assertEquals(ProcedureReservedWords.VARIABLES, ((ElementSymbol)criteria.getRightExpression()).getGroupSymbol().getCanonicalName());
    }
View Full Code Here

Examples of org.teiid.query.sql.proc.CreateUpdateProcedureCommand

       
        Block block = new Block();       
        block.addStatement(declStmt);
        block.addStatement(stmt);
               
        CreateUpdateProcedureCommand cmd = new CreateUpdateProcedureCommand();
        cmd.setBlock(block);
      
        TestParser.helpTest("CREATE PROCEDURE BEGIN DECLARE short var1;"+ //$NON-NLS-1$
           " IF(HAS IN CRITERIA ON (a)) BEGIN var1 = (SELECT a1 FROM g WHERE a2 = 5); END"+ //$NON-NLS-1$
           " ELSE BEGIN DECLARE short var2; var2 = SELECT b1 FROM g, /*+ optional */ h WHERE a2 = 5; END" + //$NON-NLS-1$
           " END", "CREATE PROCEDURE"+"\n"+"BEGIN"+"\n"+"DECLARE short var1;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
View Full Code Here

Examples of org.teiid.query.sql.proc.CreateUpdateProcedureCommand

  private String getRewritenProcedure(String userUpdateStr,
      QueryMetadataInterface metadata) throws TeiidComponentException,
      QueryMetadataException, TeiidProcessingException {
    ProcedureContainer userCommand = (ProcedureContainer)QueryParser.getQueryParser().parseCommand(userUpdateStr);
        QueryResolver.resolveCommand(userCommand, metadata);
        CreateUpdateProcedureCommand proc = (CreateUpdateProcedureCommand)QueryResolver.expandCommand(userCommand, metadata, null);
    QueryRewriter.rewrite(userCommand, metadata, null);
    Command result = QueryRewriter.rewrite(proc, metadata, null);
    return result.toString();
  }
View Full Code Here

Examples of org.teiid.query.sql.proc.CreateUpdateProcedureCommand

   
    /**
     *  Constants will now auto resolve if they are consistently representable in the target type
     */
    @Test public void testDefect23257() throws Exception{
      CreateUpdateProcedureCommand command = helpResolve("EXEC pm5.vsp59()", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
       
        CommandStatement cs = (CommandStatement)command.getBlock().getStatements().get(1);
       
        Insert insert = (Insert)cs.getCommand();
       
        assertEquals(DataTypeManager.DefaultDataClasses.SHORT, ((Expression)insert.getValues().get(1)).getType());
    }
View Full Code Here

Examples of org.teiid.query.sql.proc.CreateUpdateProcedureCommand

        .append("\n  END") //$NON-NLS-1$
        .append("\nEND"); //$NON-NLS-1$
       
        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
       
        CreateUpdateProcedureCommand command = helpResolveUpdateProcedure(proc.toString(), userUpdateStr,
                                     FakeMetadataObject.Props.UPDATE_PROCEDURE);
       
        Block block = command.getBlock();
       
        AssignmentStatement assStmt = (AssignmentStatement)block.getStatements().get(1);
        assertEquals(ProcedureReservedWords.VARIABLES, assStmt.getVariable().getGroupSymbol().getCanonicalName());
        assertEquals(ProcedureReservedWords.VARIABLES, ((ElementSymbol)assStmt.getValue()).getGroupSymbol().getCanonicalName());
       
View Full Code Here

Examples of org.teiid.query.sql.proc.CreateUpdateProcedureCommand

    ForEachRowPlan result = new ForEachRowPlan();
    result.setParams(params);
    ProcessorPlan queryPlan = QueryOptimizer.optimizePlan(query, metadata, idGenerator, capFinder, analysisRecord, context);
    result.setQueryPlan(queryPlan);
    result.setLookupMap(RelationalNode.createLookupMap(query.getProjectedSymbols()));
    ProcedurePlan rowProcedure = (ProcedurePlan)QueryOptimizer.optimizePlan(new CreateUpdateProcedureCommand(ta.getBlock()), metadata, idGenerator, capFinder, analysisRecord, context);
    result.setRowProcedure(rowProcedure);
    return result;
  }
View Full Code Here

Examples of org.teiid.query.sql.proc.CreateUpdateProcedureCommand

        }
        if (type == Command.TYPE_UPDATE || type == Command.TYPE_DELETE) {
          ProcedureContainerResolver.addScalarGroup(SQLConstants.Reserved.OLD, tma.getMetadataStore(), externalGroups, viewElements, false);
        }
    } else if (currentCommand instanceof CreateUpdateProcedureCommand) {
      CreateUpdateProcedureCommand cupc = (CreateUpdateProcedureCommand)currentCommand;
      cupc.setVirtualGroup(container);

      if (type == Command.TYPE_STORED_PROCEDURE) {
        StoredProcedureInfo info = metadata.getStoredProcedureInfoForProcedure(container.getCanonicalName());
            // Create temporary metadata that defines a group based on either the stored proc
            // name or the stored query name - this will be used later during planning
View Full Code Here

Examples of org.teiid.query.sql.proc.CreateUpdateProcedureCommand

        if(debug) {
            analysisRecord.println("\n####################################################"); //$NON-NLS-1$
            analysisRecord.println("PROCEDURE COMMAND: " + procCommand); //$NON-NLS-1$
        }

        CreateUpdateProcedureCommand cupc = Assertion.isInstanceOf(procCommand, CreateUpdateProcedureCommand.class, "Wrong command type"); //$NON-NLS-1$

        if(debug) {
            analysisRecord.println("OPTIMIZING SUB-COMMANDS: "); //$NON-NLS-1$
        }
       
        for (Command command : CommandCollectorVisitor.getCommands(procCommand)) {
          if (!(command instanceof DynamicCommand)) {
            command.setProcessorPlan(QueryOptimizer.optimizePlan(command, metadata, idGenerator, capFinder, analysisRecord, context));
          }
        }

        Block block = cupc.getBlock();

    Program programBlock = planBlock(cupc, block, metadata, debug, idGenerator, capFinder, analysisRecord, context);

        if(debug) {
            analysisRecord.println("\n####################################################"); //$NON-NLS-1$
        }
               
        // create plan from program and initialized environment
        ProcedurePlan plan = new ProcedurePlan(programBlock);
       
        plan.setUpdateProcedure(cupc.isUpdateProcedure());
        plan.setOutputElements(cupc.getProjectedSymbols());
       
        if(debug) {
            analysisRecord.println("####################################################"); //$NON-NLS-1$
            analysisRecord.println("PROCEDURE PLAN :"+plan); //$NON-NLS-1$
            analysisRecord.println("####################################################"); //$NON-NLS-1$
View Full Code Here

Examples of org.teiid.query.sql.proc.CreateUpdateProcedureCommand

      Command command = cr.expandCommand(proc, metadata, analysisRecord);
      if (command == null) {
        return null;
      }
    if (command instanceof CreateUpdateProcedureCommand) {
        CreateUpdateProcedureCommand cupCommand = (CreateUpdateProcedureCommand)command;
        cupCommand.setUserCommand(proc);
        //if the subcommand is virtual stored procedure, it must have the same
            //projected symbol as its parent.
            if(!cupCommand.isUpdateProcedure()){
                cupCommand.setProjectedSymbols(proc.getProjectedSymbols());
            }
      }
      resolveCommand(command, proc.getGroup(), proc.getType(), metadata.getDesignTimeMetadata());
      return command;
    }
View Full Code Here

Examples of org.teiid.query.sql.proc.CreateUpdateProcedureCommand

                                  
    ProcessorPlan result = null;

    switch (command.getType()) {
    case Command.TYPE_UPDATE_PROCEDURE:
      CreateUpdateProcedureCommand cupc = (CreateUpdateProcedureCommand)command;
      if (cupc.isUpdateProcedure()) {
        result = planProcedure(command, metadata, idGenerator, capFinder, analysisRecord, context);
      } else {
        StoredProcedure c = (StoredProcedure)cupc.getUserCommand();
        Object pid = cupc.getVirtualGroup().getMetadataID();
        if (c != null) {
          pid = c.getProcedureID();
        }
        String fullName = metadata.getFullName(pid);
        fullName = "procedure cache:" + fullName; //$NON-NLS-1$
        PreparedPlan pp = context.getPlan(fullName);
        if (pp == null) {
          Determinism determinismLevel = context.resetDeterminismLevel();
          CommandContext clone = context.clone();
          ProcessorPlan plan = planProcedure(command, metadata, idGenerator, capFinder, analysisRecord, clone);
          //note that this is not a full prepared plan.  It is not usable by user queries.
          if (pid instanceof Procedure) {
            clone.accessedPlanningObject(pid);
          }
          pp = new PreparedPlan();
          pp.setPlan(plan, clone);
          context.putPlan(fullName, pp, context.getDeterminismLevel());
          context.setDeterminismLevel(determinismLevel);
        }
        result = pp.getPlan().clone();
        for (Object id : pp.getAccessInfo().getObjectsAccessed()) {
          context.accessedPlanningObject(id);
        }
      }
          // propagate procedure parameters to the plan to allow runtime type checking
          ProcedureContainer container = (ProcedureContainer)cupc.getUserCommand();
          ProcedurePlan plan = (ProcedurePlan)result;
          if (container != null) {
            LinkedHashMap<ElementSymbol, Expression> params = container.getProcedureParameters();
            if (container instanceof StoredProcedure) {
              plan.setRequiresTransaction(container.getUpdateCount() > 0);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.