public CommandContext getContext() { CommandContext context = super.getContext(); if (evaluatedParams) { context.setVariableContext(currentVarContext); } return context; }
public CommandContext getContext() { CommandContext context = super.getContext(); if (evaluatedParams) { context.setVariableContext(currentVarContext); } return context; }
public CommandContext getContext() { CommandContext context = super.getContext(); if (evaluatedParams) { context.setVariableContext(currentVarContext); } return context; }
@Override public void open() throws TeiidComponentException, TeiidProcessingException { super.open(); shareVariableContext(this, this.getProcessorPlan().getContext()); }
@Override public void open() throws TeiidComponentException, TeiidProcessingException { super.open(); shareVariableContext(this, this.getProcessorPlan().getContext()); }
public void setResults(TupleBuffer results, ProcessorPlan plan) { this.results = results; this.uuid = results.getId(); this.hasLobs = results.isLobs(); if (plan != null) { this.accessInfo.populate(plan.getContext(), true); } }
@Override public void open() throws TeiidComponentException, TeiidProcessingException { super.open(); shareVariableContext(this, this.getProcessorPlan().getContext()); }
public void setResults(TupleBuffer results, ProcessorPlan plan) { this.results = results; this.uuid = results.getId(); this.hasLobs = results.isLobs(); if (plan != null) { this.accessInfo.populate(plan.getContext(), true); } }
public void setResults(TupleBuffer results, ProcessorPlan plan) { this.results = results; this.uuid = results.getId(); this.hasLobs = results.isLobs(); if (plan != null) { this.accessInfo.populate(plan.getContext(), true); } }
public void reset() { super.reset(); if (evaluator != null) { evaluator.reset(); } evaluatedParams = false; if (parentContext != null) { super.getContext().setVariableContext(parentContext); } createVariableContext(); CommandContext cc = super.getContext(); if (cc != null) { //create fresh local state setContext(cc.clone()); } done = false; currentState = null; finalTupleSource = null; beginBatch = 1; batchRows = null; lastBatch = false; //reset program stack programs.clear(); LogManager.logTrace(org.teiid.logging.LogConstants.CTX_DQP, "ProcedurePlan reset"); //$NON-NLS-1$ }
/** * @see org.teiid.query.processor.relational.PlanExecutionNode#prepareNextCommand() */ protected boolean prepareNextCommand() throws BlockedException, TeiidComponentException, TeiidProcessingException { if (this.criteriaProcessor == null) { this.criteriaProcessor = new DependentProcedureCriteriaProcessor(this, (Criteria)inputCriteria.clone(), inputReferences, inputDefaults); } return criteriaProcessor.prepareNextCommand(this.getProcessorPlan().getContext().getVariableContext()); }
@Override protected boolean prepareNextCommand() throws BlockedException, TeiidComponentException, TeiidProcessingException { if (this.currentBatch == null) { this.currentBatch = this.getChildren()[0].nextBatch(); } if (!hasNextCommand()) { return false; } //assign the reference values. PreparedStatementRequest.resolveParameterValues(this.references, this.currentBatch.getTuple(this.batchRow), getProcessorPlan().getContext(), this.metadata); this.batchRow++; return true; }
@Override protected boolean prepareNextCommand() throws BlockedException, TeiidComponentException, TeiidProcessingException { if (this.currentBatch == null) { this.currentBatch = this.getChildren()[0].nextBatch(); } if (!hasNextCommand()) { return false; } //assign the reference values. PreparedStatementRequest.resolveParameterValues(this.references, this.currentBatch.getTuple(this.batchRow), getProcessorPlan().getContext(), this.metadata); this.batchRow++; return true; }
@Override protected boolean prepareNextCommand() throws BlockedException, TeiidComponentException, TeiidProcessingException { if (this.currentBatch == null) { this.currentBatch = this.getChildren()[0].nextBatch(); } if (!hasNextCommand()) { return false; } //assign the reference values. PreparedStatementRequest.resolveParameterValues(this.references, this.currentBatch.getTuple(this.batchRow), getProcessorPlan().getContext(), this.metadata); this.batchRow++; return true; }
/** * @see org.teiid.query.processor.relational.PlanExecutionNode#prepareNextCommand() */ protected boolean prepareNextCommand() throws BlockedException, TeiidComponentException, TeiidProcessingException { if (this.criteriaProcessor == null) { Criteria crit = (Criteria)inputCriteria.clone(); crit = QueryRewriter.evaluateAndRewrite(crit, getEvaluator(Collections.emptyMap()), this.getContext(), this.getContext().getMetadata()); this.criteriaProcessor = new DependentProcedureCriteriaProcessor(this, crit, inputReferences, inputDefaults); } return criteriaProcessor.prepareNextCommand(this.getProcessorPlan().getContext().getVariableContext()); }
/** * @see org.teiid.query.processor.relational.PlanExecutionNode#prepareNextCommand() */ protected boolean prepareNextCommand() throws BlockedException, TeiidComponentException, TeiidProcessingException { if (this.criteriaProcessor == null) { Criteria crit = (Criteria)inputCriteria.clone(); crit = QueryRewriter.evaluateAndRewrite(crit, getEvaluator(Collections.emptyMap()), this.getContext(), this.getContext().getMetadata()); this.criteriaProcessor = new DependentProcedureCriteriaProcessor(this, crit, inputReferences, inputDefaults); } return criteriaProcessor.prepareNextCommand(this.getProcessorPlan().getContext().getVariableContext()); }
private void openPlan() throws TeiidComponentException, TeiidProcessingException { //reset prior to updating the context updatePlans[planIndex].reset(); if (this.contexts != null && !this.contexts.isEmpty()) { CommandContext context = updatePlans[planIndex].getContext(); VariableContext vc = context.getVariableContext(); //ensure that we're dealing with the global context //this is just a safe guard against the plan not correctly resetting the context while (vc.getParentContext() != null) { vc = vc.getParentContext(); } vc.clear(); VariableContext currentValues = this.contexts.get(planIndex); vc.putAll(currentValues); } TransactionContext tc = this.getContext().getTransactionContext(); if (startTxn[planIndex] && tc != null && tc.getTransactionType() == Scope.NONE) { this.getContext().getTransactionServer().begin(tc); this.planContexts[planIndex] = tc; } updatePlans[planIndex].open(); planOpened[planIndex] = true; }
private void openPlan() throws TeiidComponentException, TeiidProcessingException { //reset prior to updating the context updatePlans[planIndex].reset(); if (this.contexts != null && !this.contexts.isEmpty()) { CommandContext context = updatePlans[planIndex].getContext(); VariableContext vc = context.getVariableContext(); //ensure that we're dealing with the global context //this is just a safe guard against the plan not correctly resetting the context while (vc.getParentContext() != null) { vc = vc.getParentContext(); } vc.clear(); VariableContext currentValues = this.contexts.get(planIndex); vc.putAll(currentValues); } TransactionContext tc = this.getContext().getTransactionContext(); if (startTxn[planIndex] && tc != null && tc.getTransactionType() == Scope.NONE) { this.getContext().getTransactionServer().begin(tc); this.planContexts[planIndex] = tc; } updatePlans[planIndex].open(); planOpened[planIndex] = true; }
@Test public void testExceptionHandling() throws Exception { String ddl = "create virtual procedure vproc (x integer) returns integer as begin " + "raise sqlexception 'hello world' sqlstate 'abc', 1;" + "exception e " + "raise sqlwarning sqlexception 'caught' chain e.exception; " + "\"return\" = 1;"+ "end;"; TransformationMetadata tm = TestProcedureResolving.createMetadata(ddl); String sql = "call vproc(1)"; //$NON-NLS-1$ ProcessorPlan plan = getProcedurePlan(sql, tm); HardcodedDataManager dataManager = new HardcodedDataManager(tm); helpTestProcess(plan, new List[] {Arrays.asList(1)}, dataManager, tm); TeiidSQLException tse = (TeiidSQLException)plan.getContext().getAndClearWarnings().get(0); assertEquals("caught", tse.getMessage()); assertEquals("hello world", tse.getCause().getMessage()); }
@Test public void testExceptionAndWarning() throws Exception { String ddl = "create virtual procedure vproc (x integer) returns integer as begin declare exception e = sqlexception 'hello'; raise sqlwarning e; raise sqlexception 'hello world' sqlstate 'abc', 1 chain e; end;"; TransformationMetadata tm = TestProcedureResolving.createMetadata(ddl); String sql = "call vproc(1)"; //$NON-NLS-1$ ProcessorPlan plan = getProcedurePlan(sql, tm); HardcodedDataManager dataManager = new HardcodedDataManager(tm); try { helpTestProcess(plan, null, dataManager, tm); fail(); } catch (TeiidProcessingException e) { TeiidSQLException tsw = (TeiidSQLException) plan.getContext().getAndClearWarnings().get(0); assertEquals("hello", tsw.getMessage()); assertEquals(e.getCause().getCause(), tsw); TeiidSQLException tse = (TeiidSQLException)e.getCause(); assertEquals("hello world", tse.getMessage()); assertEquals("abc", tse.getSQLState()); assertEquals(1, tse.getErrorCode()); } }