Author: shawkins
Date: 2011-11-22 07:55:13 -0500 (Tue, 22 Nov 2011)
New Revision: 3683
Added:
trunk/engine/src/main/java/org/teiid/query/sql/proc/CreateProcedureCommand.java
Removed:
trunk/engine/src/main/java/org/teiid/query/sql/proc/CreateUpdateProcedureCommand.java
Modified:
trunk/build/kits/jboss-container/teiid-releasenotes.html
trunk/engine/src/main/java/org/teiid/query/optimizer/ProcedurePlanner.java
trunk/engine/src/main/java/org/teiid/query/optimizer/QueryOptimizer.java
trunk/engine/src/main/java/org/teiid/query/optimizer/TriggerActionPlanner.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java
trunk/engine/src/main/java/org/teiid/query/processor/proc/ExecDynamicSqlInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java
trunk/engine/src/main/java/org/teiid/query/resolver/ProcedureContainerResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/QueryResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/command/UpdateProcedureResolver.java
trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
trunk/engine/src/main/java/org/teiid/query/sql/LanguageVisitor.java
trunk/engine/src/main/java/org/teiid/query/sql/ProcedureReservedWords.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/AlterProcedure.java
trunk/engine/src/main/java/org/teiid/query/sql/navigator/PreOrPostOrderNavigator.java
trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java
trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj
trunk/engine/src/test/java/org/teiid/query/optimizer/proc/TestProcedurePlanner.java
trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java
trunk/engine/src/test/java/org/teiid/query/processor/TestInherintlyUpdatableViews.java
trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java
trunk/engine/src/test/java/org/teiid/query/resolver/TestProcedureResolving.java
trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java
trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java
trunk/engine/src/test/java/org/teiid/query/sql/proc/TestCreateUpdateProcedureCommand.java
trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java
trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java
Log:
TEIID-1842 completely removing the concept of an update procedure
Modified: trunk/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-container/teiid-releasenotes.html 2011-11-22 12:49:12 UTC (rev
3682)
+++ trunk/build/kits/jboss-container/teiid-releasenotes.html 2011-11-22 12:55:13 UTC (rev
3683)
@@ -37,7 +37,7 @@
<h4>from 7.6</h4>
<ul>
- <li>TRANSLATE/HAS CRITERIA has been removed. INSTEAD OF trigger actions should
be used instead. INPUTS and INPUT are no longer procedure reserved words.
+ <li>TRANSLATE/HAS CRITERIA has been removed. INSTEAD OF trigger actions should
be used instead. ROWS_UPDATED, INPUTS, and INPUT are no longer procedure reserved words.
</ul>
<h4>from 7.5</h4>
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/ProcedurePlanner.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/ProcedurePlanner.java 2011-11-22
12:49:12 UTC (rev 3682)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/ProcedurePlanner.java 2011-11-22
12:55:13 UTC (rev 3683)
@@ -35,31 +35,12 @@
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
import org.teiid.query.processor.ProcessorPlan;
-import org.teiid.query.processor.proc.AssignmentInstruction;
-import org.teiid.query.processor.proc.BranchingInstruction;
-import org.teiid.query.processor.proc.CreateCursorResultSetInstruction;
-import org.teiid.query.processor.proc.ErrorInstruction;
-import org.teiid.query.processor.proc.ExecDynamicSqlInstruction;
-import org.teiid.query.processor.proc.IfInstruction;
-import org.teiid.query.processor.proc.LoopInstruction;
-import org.teiid.query.processor.proc.ProcedurePlan;
-import org.teiid.query.processor.proc.Program;
-import org.teiid.query.processor.proc.ProgramInstruction;
-import org.teiid.query.processor.proc.WhileInstruction;
+import org.teiid.query.processor.proc.*;
import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.DynamicCommand;
import org.teiid.query.sql.lang.SPParameter;
import org.teiid.query.sql.lang.StoredProcedure;
-import org.teiid.query.sql.proc.AssignmentStatement;
-import org.teiid.query.sql.proc.Block;
-import org.teiid.query.sql.proc.BranchingStatement;
-import org.teiid.query.sql.proc.CommandStatement;
-import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
-import org.teiid.query.sql.proc.IfStatement;
-import org.teiid.query.sql.proc.LoopStatement;
-import org.teiid.query.sql.proc.RaiseErrorStatement;
-import org.teiid.query.sql.proc.Statement;
-import org.teiid.query.sql.proc.WhileStatement;
+import org.teiid.query.sql.proc.*;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.Reference;
@@ -69,7 +50,7 @@
/**
* <p> This prepares an {@link org.teiid.query.processor.proc.ProcedurePlan
ProcedurePlan} from
- * a CreateUpdateProcedureCommand {@link
org.teiid.query.sql.proc.CreateUpdateProcedureCommand CreateUpdateProcedureCommand}.
+ * a CreateUpdateProcedureCommand {@link org.teiid.query.sql.proc.CreateProcedureCommand
CreateUpdateProcedureCommand}.
* </p>
*/
public final class ProcedurePlanner implements CommandPlanner {
@@ -94,7 +75,7 @@
analysisRecord.println("PROCEDURE COMMAND: " + procCommand);
//$NON-NLS-1$
}
- CreateUpdateProcedureCommand cupc = Assertion.isInstanceOf(procCommand,
CreateUpdateProcedureCommand.class, "Wrong command type"); //$NON-NLS-1$
+ CreateProcedureCommand cupc = Assertion.isInstanceOf(procCommand,
CreateProcedureCommand.class, "Wrong command type"); //$NON-NLS-1$
if(debug) {
analysisRecord.println("OPTIMIZING SUB-COMMANDS: "); //$NON-NLS-1$
@@ -117,7 +98,6 @@
// create plan from program and initialized environment
ProcedurePlan plan = new ProcedurePlan(programBlock);
- plan.setUpdateProcedure(cupc.isUpdateProcedure());
plan.setOutputElements(cupc.getProjectedSymbols());
if(debug) {
@@ -142,7 +122,7 @@
* @throws QueryMetadataException if there is an error accessing metadata
* @throws TeiidComponentException if unexpected error occurs
*/
- private Program planBlock(CreateUpdateProcedureCommand parentProcCommand, Block
block, QueryMetadataInterface metadata, boolean debug, IDGenerator idGenerator,
CapabilitiesFinder capFinder, AnalysisRecord analysisRecord, CommandContext context)
+ private Program planBlock(CreateProcedureCommand parentProcCommand, Block block,
QueryMetadataInterface metadata, boolean debug, IDGenerator idGenerator,
CapabilitiesFinder capFinder, AnalysisRecord analysisRecord, CommandContext context)
throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
// Generate program and add instructions
@@ -184,7 +164,7 @@
* @throws QueryMetadataException if there is an error accessing metadata
* @throws TeiidComponentException if unexpected error occurs
*/
- private Object planStatement(CreateUpdateProcedureCommand parentProcCommand,
Statement statement, QueryMetadataInterface metadata, boolean debug, IDGenerator
idGenerator, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord, CommandContext
context)
+ private Object planStatement(CreateProcedureCommand parentProcCommand, Statement
statement, QueryMetadataInterface metadata, boolean debug, IDGenerator idGenerator,
CapabilitiesFinder capFinder, AnalysisRecord analysisRecord, CommandContext context)
throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
int stmtType = statement.getType();
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/QueryOptimizer.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/QueryOptimizer.java 2011-11-22
12:49:12 UTC (rev 3682)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/QueryOptimizer.java 2011-11-22
12:55:13 UTC (rev 3683)
@@ -53,7 +53,7 @@
import org.teiid.query.sql.lang.Query;
import org.teiid.query.sql.lang.SPParameter;
import org.teiid.query.sql.lang.StoredProcedure;
-import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
+import org.teiid.query.sql.proc.CreateProcedureCommand;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.util.CommandContext;
@@ -106,8 +106,9 @@
switch (command.getType()) {
case Command.TYPE_UPDATE_PROCEDURE:
- CreateUpdateProcedureCommand cupc = (CreateUpdateProcedureCommand)command;
- if (cupc.isUpdateProcedure()) {
+ CreateProcedureCommand cupc = (CreateProcedureCommand)command;
+ if (cupc.getUserCommand() == null) {
+ //row update procedure
result = planProcedure(command, metadata, idGenerator, capFinder, analysisRecord,
context);
} else {
StoredProcedure c = (StoredProcedure)cupc.getUserCommand();
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/TriggerActionPlanner.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/optimizer/TriggerActionPlanner.java 2011-11-22
12:49:12 UTC (rev 3682)
+++
trunk/engine/src/main/java/org/teiid/query/optimizer/TriggerActionPlanner.java 2011-11-22
12:55:13 UTC (rev 3683)
@@ -47,7 +47,7 @@
import org.teiid.query.rewriter.QueryRewriter;
import org.teiid.query.sql.LanguageObject;
import org.teiid.query.sql.lang.*;
-import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
+import org.teiid.query.sql.proc.CreateProcedureCommand;
import org.teiid.query.sql.proc.TriggerAction;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
@@ -99,7 +99,7 @@
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);
+ ProcedurePlan rowProcedure = (ProcedurePlan)QueryOptimizer.optimizePlan(new
CreateProcedureCommand(ta.getBlock()), metadata, idGenerator, capFinder, analysisRecord,
context);
result.setRowProcedure(rowProcedure);
return result;
}
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java 2011-11-22
12:49:12 UTC (rev 3682)
+++
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java 2011-11-22
12:55:13 UTC (rev 3683)
@@ -73,7 +73,7 @@
import org.teiid.query.sql.LanguageObject.Util;
import org.teiid.query.sql.lang.*;
import org.teiid.query.sql.navigator.PreOrPostOrderNavigator;
-import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
+import org.teiid.query.sql.proc.CreateProcedureCommand;
import org.teiid.query.sql.proc.TriggerAction;
import org.teiid.query.sql.symbol.*;
import org.teiid.query.sql.util.SymbolMap;
@@ -548,8 +548,8 @@
}
} else {
c = (Command)c.clone();
- if (c instanceof CreateUpdateProcedureCommand) {
- ((CreateUpdateProcedureCommand)c).setUserCommand(container);
+ if (c instanceof CreateProcedureCommand) {
+ ((CreateProcedureCommand)c).setUserCommand(container);
}
}
if (c != null) {
Modified:
trunk/engine/src/main/java/org/teiid/query/processor/proc/ExecDynamicSqlInstruction.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/processor/proc/ExecDynamicSqlInstruction.java 2011-11-22
12:49:12 UTC (rev 3682)
+++
trunk/engine/src/main/java/org/teiid/query/processor/proc/ExecDynamicSqlInstruction.java 2011-11-22
12:55:13 UTC (rev 3683)
@@ -60,7 +60,7 @@
import org.teiid.query.sql.lang.Insert;
import org.teiid.query.sql.lang.Query;
import org.teiid.query.sql.lang.SetClause;
-import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
+import org.teiid.query.sql.proc.CreateProcedureCommand;
import org.teiid.query.sql.symbol.Constant;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
@@ -94,12 +94,12 @@
private QueryMetadataInterface metadata;
// The parent command
- CreateUpdateProcedureCommand parentProcCommand;
+ CreateProcedureCommand parentProcCommand;
private Program dynamicProgram;
public ExecDynamicSqlInstruction(
- CreateUpdateProcedureCommand parentProcCommand,
+ CreateProcedureCommand parentProcCommand,
DynamicCommand command, QueryMetadataInterface metadata,
IDGenerator idGenerator, CapabilitiesFinder capFinder) {
this.parentProcCommand = parentProcCommand;
Modified: trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java 2011-11-22
12:49:12 UTC (rev 3682)
+++
trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java 2011-11-22
12:55:13 UTC (rev 3683)
@@ -110,19 +110,14 @@
private Map<String, CursorState> cursorStates = new HashMap<String,
CursorState>();
- private static ElementSymbol ROWS_UPDATED =
- new
ElementSymbol(ProcedureReservedWords.VARIABLES+"."+ProcedureReservedWords.ROWS_UPDATED);
//$NON-NLS-1$
-
static ElementSymbol ROWCOUNT =
new
ElementSymbol(ProcedureReservedWords.VARIABLES+"."+ProcedureReservedWords.ROWCOUNT);
//$NON-NLS-1$
static {
- ROWS_UPDATED.setType(DataTypeManager.DefaultDataClasses.INTEGER);
ROWCOUNT.setType(DataTypeManager.DefaultDataClasses.INTEGER);
}
private VariableContext currentVarContext;
- private boolean isUpdateProcedure = true;
private TupleSource lastTupleSource;
@@ -377,10 +372,6 @@
program.incrementProgramCounter();
}
- if(this.isUpdateProcedure){
- return this.getUpdateCountAsToupleSource();
- }
-
if(lastTupleSource == null){
return CollectionTupleSource.createNullTupleSource();
}
@@ -416,7 +407,6 @@
public ProcessorPlan clone(){
ProcedurePlan plan = new ProcedurePlan((Program)originalProgram.clone());
- plan.setUpdateProcedure(this.isUpdateProcedure());
plan.setOutputElements(this.getOutputElements());
plan.setParams(params);
plan.setOutParams(outParams);
@@ -486,18 +476,9 @@
private void createVariableContext() {
this.currentVarContext = new VariableContext(true);
- this.currentVarContext.setValue(ROWS_UPDATED, 0);
this.currentVarContext.setValue(ROWCOUNT, 0);
}
- private TupleSource getUpdateCountAsToupleSource() {
- Object rowCount = currentVarContext.getValue(ROWS_UPDATED);
- if(rowCount == null) {
- rowCount = 0;
- }
- return CollectionTupleSource.createUpdateCountTupleSource((Integer)rowCount);
- }
-
/**
* <p> Get the current <code>VariavleContext</code> on this
environment.
* The VariableContext is updated with variables and their values by
@@ -714,20 +695,6 @@
return context;
}
- /**
- * @return
- */
- public boolean isUpdateProcedure() {
- return isUpdateProcedure;
- }
-
- /**
- * @param b
- */
- public void setUpdateProcedure(boolean b) {
- isUpdateProcedure = b;
- }
-
public List getOutputElements() {
return outputElements;
}
Modified:
trunk/engine/src/main/java/org/teiid/query/resolver/ProcedureContainerResolver.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/resolver/ProcedureContainerResolver.java 2011-11-22
12:49:12 UTC (rev 3682)
+++
trunk/engine/src/main/java/org/teiid/query/resolver/ProcedureContainerResolver.java 2011-11-22
12:55:13 UTC (rev 3683)
@@ -49,7 +49,7 @@
import org.teiid.query.sql.lang.GroupContext;
import org.teiid.query.sql.lang.ProcedureContainer;
import org.teiid.query.sql.lang.SPParameter;
-import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
+import org.teiid.query.sql.proc.CreateProcedureCommand;
import org.teiid.query.sql.proc.TriggerAction;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.GroupSymbol;
@@ -255,8 +255,8 @@
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;
+ } else if (currentCommand instanceof CreateProcedureCommand) {
+ CreateProcedureCommand cupc = (CreateProcedureCommand)currentCommand;
cupc.setVirtualGroup(container);
if (type == Command.TYPE_STORED_PROCEDURE) {
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/QueryResolver.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/QueryResolver.java 2011-11-22
12:49:12 UTC (rev 3682)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/QueryResolver.java 2011-11-22
12:55:13 UTC (rev 3683)
@@ -61,7 +61,7 @@
import org.teiid.query.sql.lang.SubqueryContainer;
import org.teiid.query.sql.lang.UnaryFromClause;
import org.teiid.query.sql.navigator.DeepPostOrderNavigator;
-import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
+import org.teiid.query.sql.proc.CreateProcedureCommand;
import org.teiid.query.sql.symbol.AliasSymbol;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
@@ -105,14 +105,12 @@
if (command == null) {
return null;
}
- if (command instanceof CreateUpdateProcedureCommand) {
- CreateUpdateProcedureCommand cupCommand = (CreateUpdateProcedureCommand)command;
+ if (command instanceof CreateProcedureCommand) {
+ CreateProcedureCommand cupCommand = (CreateProcedureCommand)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());
- }
+ cupCommand.setProjectedSymbols(proc.getProjectedSymbols());
}
resolveCommand(command, proc.getGroup(), proc.getType(),
metadata.getDesignTimeMetadata());
return command;
Modified:
trunk/engine/src/main/java/org/teiid/query/resolver/command/UpdateProcedureResolver.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/resolver/command/UpdateProcedureResolver.java 2011-11-22
12:49:12 UTC (rev 3682)
+++
trunk/engine/src/main/java/org/teiid/query/resolver/command/UpdateProcedureResolver.java 2011-11-22
12:55:13 UTC (rev 3683)
@@ -73,26 +73,17 @@
if (command instanceof TriggerAction) {
TriggerAction ta = (TriggerAction)command;
- resolveBlock(new CreateUpdateProcedureCommand(), ta.getBlock(),
ta.getExternalGroupContexts(), metadata);
+ resolveBlock(new CreateProcedureCommand(), ta.getBlock(),
ta.getExternalGroupContexts(), metadata);
return;
}
- CreateUpdateProcedureCommand procCommand = (CreateUpdateProcedureCommand)
command;
+ CreateProcedureCommand procCommand = (CreateProcedureCommand) command;
//by creating a new group context here it means that variables will resolve with
a higher precedence than input/changing
GroupContext externalGroups = command.getExternalGroupContexts();
List<ElementSymbol> symbols = new LinkedList<ElementSymbol>();
- // virtual group elements in HAS and TRANSLATE criteria have to be resolved
- if(procCommand.isUpdateProcedure()){
- //add the default variables
- String countVar = ProcedureReservedWords.VARIABLES + ElementSymbol.SEPARATOR
+ ProcedureReservedWords.ROWS_UPDATED;
- ElementSymbol updateCount = new ElementSymbol(countVar);
- updateCount.setType(DataTypeManager.DefaultDataClasses.INTEGER);
- symbols.add(updateCount);
- }
-
String countVar = ProcedureReservedWords.VARIABLES + ElementSymbol.SEPARATOR +
ProcedureReservedWords.ROWCOUNT;
ElementSymbol updateCount = new ElementSymbol(countVar);
updateCount.setType(DataTypeManager.DefaultDataClasses.INTEGER);
@@ -102,7 +93,7 @@
resolveBlock(procCommand, procCommand.getBlock(), externalGroups, metadata);
}
- public void resolveBlock(CreateUpdateProcedureCommand command, Block block, GroupContext
externalGroups,
+ public void resolveBlock(CreateProcedureCommand command, Block block, GroupContext
externalGroups,
TempMetadataAdapter metadata)
throws QueryResolverException, QueryMetadataException, TeiidComponentException {
LogManager.logTrace(org.teiid.logging.LogConstants.CTX_QUERY_RESOLVER, new
Object[]{"Resolving block", block}); //$NON-NLS-1$
@@ -120,7 +111,7 @@
}
}
- private void resolveStatement(CreateUpdateProcedureCommand command, Statement statement,
GroupContext externalGroups, GroupSymbol variables, TempMetadataAdapter metadata)
+ private void resolveStatement(CreateProcedureCommand command, Statement statement,
GroupContext externalGroups, GroupSymbol variables, TempMetadataAdapter metadata)
throws QueryResolverException, QueryMetadataException, TeiidComponentException {
LogManager.logTrace(org.teiid.logging.LogConstants.CTX_QUERY_RESOLVER, new
Object[]{"Resolving statement", statement}); //$NON-NLS-1$
@@ -172,27 +163,25 @@
if (subCommand instanceof DynamicCommand) {
DynamicCommand dynCommand = (DynamicCommand)subCommand;
- if(dynCommand.getIntoGroup() == null &&
!command.isUpdateProcedure()
+ if(dynCommand.getIntoGroup() == null
&& !dynCommand.isAsClauseSet() &&
!command.getProjectedSymbols().isEmpty()) {
dynCommand.setAsColumns(command.getProjectedSymbols());
}
}
- if(!command.isUpdateProcedure()){
- //don't bother using the metadata when it doesn't matter
- if (command.getResultsCommand() != null &&
command.getResultsCommand().getType() == Command.TYPE_DYNAMIC) {
- DynamicCommand dynamicCommand =
(DynamicCommand)command.getResultsCommand();
- if (!dynamicCommand.isAsClauseSet()) {
- dynamicCommand.setAsColumns(Collections.EMPTY_LIST);
- }
+ //don't bother using the metadata when it doesn't matter
+ if (command.getResultsCommand() != null &&
command.getResultsCommand().getType() == Command.TYPE_DYNAMIC) {
+ DynamicCommand dynamicCommand =
(DynamicCommand)command.getResultsCommand();
+ if (!dynamicCommand.isAsClauseSet()) {
+ dynamicCommand.setAsColumns(Collections.EMPTY_LIST);
}
-
- if (subCommand.returnsResultSet()) {
- //this could be the last select statement, set the projected symbol
- //on the virtual procedure command
- command.setResultsCommand(subCommand);
- }
}
+
+ if (subCommand.returnsResultSet()) {
+ //this could be the last select statement, set the projected symbol
+ //on the virtual procedure command
+ command.setResultsCommand(subCommand);
+ }
break;
case Statement.TYPE_ERROR:
Modified: trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2011-11-22
12:49:12 UTC (rev 3682)
+++ trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2011-11-22
12:55:13 UTC (rev 3683)
@@ -197,7 +197,7 @@
command = rewriteDelete((Delete) command);
break;
case Command.TYPE_UPDATE_PROCEDURE:
- command = rewriteUpdateProcedure((CreateUpdateProcedureCommand)
command);
+ command = rewriteUpdateProcedure((CreateProcedureCommand) command);
break;
case Command.TYPE_BATCHED_UPDATE:
List subCommands = ((BatchedUpdateCommand)command).getUpdateCommands();
@@ -218,7 +218,7 @@
return command;
}
- private Command rewriteUpdateProcedure(CreateUpdateProcedureCommand command)
+ private Command rewriteUpdateProcedure(CreateProcedureCommand command)
throws TeiidComponentException, TeiidProcessingException{
Block block = rewriteBlock(command.getBlock());
command.setBlock(block);
@@ -1872,7 +1872,7 @@
return criteria;
}
- public static Expression rewriteExpression(Expression expression,
CreateUpdateProcedureCommand procCommand, CommandContext context, QueryMetadataInterface
metadata) throws TeiidComponentException, TeiidProcessingException{
+ public static Expression rewriteExpression(Expression expression, CreateProcedureCommand
procCommand, CommandContext context, QueryMetadataInterface metadata) throws
TeiidComponentException, TeiidProcessingException{
return new QueryRewriter(metadata, context).rewriteExpressionDirect(expression);
}
@@ -2651,15 +2651,23 @@
TeiidComponentException, TeiidProcessingException {
Block b = new Block();
b.addStatement(new CommandStatement(newUpdate));
- CreateUpdateProcedureCommand cupc = new CreateUpdateProcedureCommand();
+ CreateProcedureCommand cupc = new CreateProcedureCommand();
+ cupc.setUpdateProcedure(false);
Block parent = new Block();
+ parent.setAtomic(true);
+ ElementSymbol rowsUpdated = new
ElementSymbol(ProcedureReservedWords.VARIABLES+ElementSymbol.SEPARATOR+"ROWS_UPDATED");
//$NON-NLS-1$
+ DeclareStatement ds = new DeclareStatement(rowsUpdated,
DataTypeManager.DefaultDataTypes.INTEGER, new Constant(0));
+ parent.addStatement(ds);
LoopStatement ls = new LoopStatement(b, query, "X"); //$NON-NLS-1$
parent.addStatement(ls);
AssignmentStatement as = new AssignmentStatement();
- ElementSymbol rowsUpdate = new
ElementSymbol(ProcedureReservedWords.VARIABLES+ElementSymbol.SEPARATOR+ProcedureReservedWords.ROWS_UPDATED);
- as.setVariable(rowsUpdate);
- as.setExpression(new Function("+", new Expression[] {rowsUpdate, new
Constant(1)})); //$NON-NLS-1$
+ rowsUpdated.setType(DataTypeManager.DefaultDataClasses.INTEGER);
+ as.setVariable(rowsUpdated);
+ as.setExpression(new Function("+", new Expression[] {rowsUpdated, new
Constant(1)})); //$NON-NLS-1$
b.addStatement(as);
+ Query returnQuery = new Query();
+ returnQuery.setSelect(new Select(Arrays.asList(rowsUpdated.clone())));
+ parent.addStatement(new CommandStatement(returnQuery));
cupc.setBlock(parent);
cupc.setVirtualGroup(group);
QueryResolver.resolveCommand(cupc, metadata);
Modified: trunk/engine/src/main/java/org/teiid/query/sql/LanguageVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/LanguageVisitor.java 2011-11-22
12:49:12 UTC (rev 3682)
+++ trunk/engine/src/main/java/org/teiid/query/sql/LanguageVisitor.java 2011-11-22
12:55:13 UTC (rev 3683)
@@ -70,7 +70,7 @@
import org.teiid.query.sql.proc.Block;
import org.teiid.query.sql.proc.BranchingStatement;
import org.teiid.query.sql.proc.CommandStatement;
-import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
+import org.teiid.query.sql.proc.CreateProcedureCommand;
import org.teiid.query.sql.proc.DeclareStatement;
import org.teiid.query.sql.proc.IfStatement;
import org.teiid.query.sql.proc.LoopStatement;
@@ -181,7 +181,7 @@
public void visit(AssignmentStatement obj) {}
public void visit(Block obj) {}
public void visit(CommandStatement obj) {}
- public void visit(CreateUpdateProcedureCommand obj) {}
+ public void visit(CreateProcedureCommand obj) {}
public void visit(DeclareStatement obj) {
visit((AssignmentStatement)obj);
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/ProcedureReservedWords.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/ProcedureReservedWords.java 2011-11-22
12:49:12 UTC (rev 3682)
+++ trunk/engine/src/main/java/org/teiid/query/sql/ProcedureReservedWords.java 2011-11-22
12:55:13 UTC (rev 3683)
@@ -33,8 +33,6 @@
*/
public class ProcedureReservedWords {
- public static final String ROWS_UPDATED = "ROWS_UPDATED"; //$NON-NLS-1$
-
public static final String ROWCOUNT = "ROWCOUNT"; //$NON-NLS-1$
public static final String CHANGING = "CHANGING"; //$NON-NLS-1$
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/AlterProcedure.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/AlterProcedure.java 2011-11-22
12:49:12 UTC (rev 3682)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/AlterProcedure.java 2011-11-22
12:55:13 UTC (rev 3683)
@@ -22,9 +22,9 @@
package org.teiid.query.sql.lang;
import org.teiid.query.sql.LanguageVisitor;
-import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
+import org.teiid.query.sql.proc.CreateProcedureCommand;
-public class AlterProcedure extends Alter<CreateUpdateProcedureCommand> {
+public class AlterProcedure extends Alter<CreateProcedureCommand> {
@Override
public void acceptVisitor(LanguageVisitor visitor) {
Modified:
trunk/engine/src/main/java/org/teiid/query/sql/navigator/PreOrPostOrderNavigator.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/sql/navigator/PreOrPostOrderNavigator.java 2011-11-22
12:49:12 UTC (rev 3682)
+++
trunk/engine/src/main/java/org/teiid/query/sql/navigator/PreOrPostOrderNavigator.java 2011-11-22
12:55:13 UTC (rev 3683)
@@ -74,7 +74,7 @@
import org.teiid.query.sql.proc.Block;
import org.teiid.query.sql.proc.BranchingStatement;
import org.teiid.query.sql.proc.CommandStatement;
-import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
+import org.teiid.query.sql.proc.CreateProcedureCommand;
import org.teiid.query.sql.proc.DeclareStatement;
import org.teiid.query.sql.proc.IfStatement;
import org.teiid.query.sql.proc.LoopStatement;
@@ -213,7 +213,7 @@
preVisitVisitor(obj);
postVisitVisitor(obj);
}
- public void visit(CreateUpdateProcedureCommand obj) {
+ public void visit(CreateProcedureCommand obj) {
preVisitVisitor(obj);
visitNode(obj.getBlock());
postVisitVisitor(obj);
Copied: trunk/engine/src/main/java/org/teiid/query/sql/proc/CreateProcedureCommand.java
(from rev 3670,
trunk/engine/src/main/java/org/teiid/query/sql/proc/CreateUpdateProcedureCommand.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/proc/CreateProcedureCommand.java
(rev 0)
+++
trunk/engine/src/main/java/org/teiid/query/sql/proc/CreateProcedureCommand.java 2011-11-22
12:55:13 UTC (rev 3683)
@@ -0,0 +1,267 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.query.sql.proc;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.StoredProcedure;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
+
+/**
+ * <p> This class represents a update procedure in the storedprocedure language.
+ * It extends the <code>Command</code> and represents the command for Insert
, Update
+ * and Delete procedures.</p>
+ */
+public class CreateProcedureCommand extends Command {
+
+ // top level block for the procedure
+ private Block block;
+
+ // the command the user submitted against the virtual group being updated
+ private Command userCommand;
+
+ //whether it is update procedure or virtual stored procedure, default to update
procedure
+ private boolean isUpdateProcedure = true;
+
+ private List projectedSymbols;
+
+ private GroupSymbol virtualGroup;
+
+ //command that returns resultset. For virtual procedure only.
+ private Command resultsCommand;
+ /**
+ * Constructor for CreateUpdateProcedureCommand.
+ */
+ public CreateProcedureCommand() {
+ super();
+ }
+
+ /**
+ * Constructor for CreateUpdateProcedureCommand.
+ * @param block The block on this command
+ * @param type The procedure type
+ */
+ public CreateProcedureCommand(Block block) {
+ this.block = block;
+ }
+
+ /**
+ * Return type of command to make it easier to build switch statements by command type.
+ * @return The type of this command
+ */
+ public int getType() {
+ return Command.TYPE_UPDATE_PROCEDURE;
+ }
+
+ /**
+ * Get the block on this command.
+ * @return The <code>Block</code> on this command
+ */
+ public Block getBlock() {
+ return block;
+ }
+
+ /**
+ * Set the block on this command.
+ * @param block The <code>Block</code> on this command
+ */
+ public void setBlock(Block block) {
+ this.block = block;
+ }
+
+ /**
+ * Set the user's command to which this obj which is the subcommand
+ * @param command The user's command
+ */
+ public void setUserCommand(Command command) {
+ this.userCommand = command;
+ }
+
+ /**
+ * Get the user's command to which this obj which is the subcommand
+ * @return The user's command
+ */
+ public Command getUserCommand() {
+ return this.userCommand;
+ }
+
+ // =========================================================================
+ // P R O C E S S I N G M E T H O D S
+ // =========================================================================
+
+ public void acceptVisitor(LanguageVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ /**
+ * Deep clone statement to produce a new identical statement.
+ * @return Deep clone
+ */
+ public Object clone() {
+ CreateProcedureCommand copy = new CreateProcedureCommand();
+
+ //Clone this class state
+ if (this.block != null) {
+ copy.setBlock(this.block.clone());
+ }
+ if (this.projectedSymbols != null) {
+ copy.setProjectedSymbols(new ArrayList(this.projectedSymbols));
+ }
+ if (this.virtualGroup != null) {
+ copy.virtualGroup = this.virtualGroup.clone();
+ }
+ this.copyMetadataState(copy);
+ return copy;
+ }
+
+ /**
+ * Compare two CreateUpdateProcedureCommand for equality. They will only evaluate to
equal if
+ * they are IDENTICAL: the commandTypes are same and the block objects are equal.
+ * @param obj Other object
+ * @return True if equal
+ */
+ public boolean equals(Object obj) {
+ // Quick same object test
+ if(this == obj) {
+ return true;
+ }
+
+ // Quick fail tests
+ if(! (obj instanceof CreateProcedureCommand)) {
+ return false;
+ }
+
+ CreateProcedureCommand other = (CreateProcedureCommand)obj;
+
+ // Compare the block
+ return sameOptionAndHint(other) && EquivalenceUtil.areEqual(getBlock(),
other.getBlock());
+ }
+
+ /**
+ * Get hashcode for CreateUpdateProcedureCommand. WARNING: This hash code relies
+ * on the hash codes of the block and the procedure type of this command. Hash code
+ * is only valid after the command has been completely constructed.
+ * @return Hash code
+ */
+ public int hashCode() {
+ // This hash code relies on the block and the procedure type for this command
+ int myHash = 0;
+ myHash = HashCodeUtil.hashCode(myHash, this.getBlock());
+ return myHash;
+ }
+
+ /**
+ * Returns a string representation of an instance of this class.
+ * @return String representation of object
+ */
+ public String toString() {
+ return SQLStringVisitor.getSQLString(this);
+ }
+
+ // ========================================
+ // Methods inherited from Command
+ // ========================================
+
+ /**
+ * Get the ordered list of all elements returned by this query. These elements
+ * may be ElementSymbols or ExpressionSymbols but in all cases each represents a
+ * single column.
+ * @return Ordered list of SingleElementSymbol
+ */
+ public List getProjectedSymbols(){
+ if(this.projectedSymbols != null){
+ return this.projectedSymbols;
+ }
+ if(!isUpdateProcedure){
+ if(this.resultsCommand == null){
+ //user may have not entered any query yet
+ return Collections.EMPTY_LIST;
+ }
+ List<? extends SingleElementSymbol> symbols =
this.resultsCommand.getProjectedSymbols();
+ if (this.resultsCommand instanceof StoredProcedure) {
+ StoredProcedure sp = (StoredProcedure)this.resultsCommand;
+ if (sp.isCallableStatement()) {
+ symbols = sp.getResultSetColumns();
+ }
+ }
+ setProjectedSymbols(symbols);
+ return this.projectedSymbols;
+ }
+ this.projectedSymbols = Command.getUpdateCommandSymbol();
+ return this.projectedSymbols;
+ }
+
+ /**
+ * @param isUpdateProcedure
+ */
+ public void setUpdateProcedure(boolean isUpdateProcedure) {
+ this.isUpdateProcedure = isUpdateProcedure;
+ }
+
+ /**
+ * @param projSymbols
+ */
+ public void setProjectedSymbols(List projSymbols) {
+ projectedSymbols = projSymbols;
+ }
+
+ /**
+ * @return Command
+ */
+ public Command getResultsCommand() {
+ return resultsCommand;
+ }
+
+ /**
+ * @param command
+ */
+ public void setResultsCommand(Command command) {
+ resultsCommand = command;
+ }
+
+ /**
+ * @see org.teiid.query.sql.lang.Command#areResultsCachable()
+ */
+ public boolean areResultsCachable() {
+ return Query.areResultsCachable(getProjectedSymbols());
+ }
+
+ public GroupSymbol getVirtualGroup() {
+ return this.virtualGroup;
+ }
+
+ public void setVirtualGroup(GroupSymbol virtualGroup) {
+ this.virtualGroup = virtualGroup;
+ }
+
+} // END CLASS
Deleted:
trunk/engine/src/main/java/org/teiid/query/sql/proc/CreateUpdateProcedureCommand.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/sql/proc/CreateUpdateProcedureCommand.java 2011-11-22
12:49:12 UTC (rev 3682)
+++
trunk/engine/src/main/java/org/teiid/query/sql/proc/CreateUpdateProcedureCommand.java 2011-11-22
12:55:13 UTC (rev 3683)
@@ -1,305 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.query.sql.proc;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.teiid.core.util.EquivalenceUtil;
-import org.teiid.core.util.HashCodeUtil;
-import org.teiid.query.sql.LanguageVisitor;
-import org.teiid.query.sql.lang.Command;
-import org.teiid.query.sql.lang.Query;
-import org.teiid.query.sql.lang.StoredProcedure;
-import org.teiid.query.sql.symbol.GroupSymbol;
-import org.teiid.query.sql.symbol.SingleElementSymbol;
-import org.teiid.query.sql.visitor.SQLStringVisitor;
-
-
-/**
- * <p> This class represents a update procedure in the storedprocedure language.
- * It extends the <code>Command</code> and represents the command for Insert
, Update
- * and Delete procedures.</p>
- */
-public class CreateUpdateProcedureCommand extends Command {
-
- // top level block for the procedure
- private Block block;
-
- // map between elements on the virtual groups and the elements in the
- // transformation query that define it.
- private Map symbolMap;
-
- // the command the user submitted against the virtual group being updated
- private Command userCommand;
-
- //whether it is update procedure or virtual stored procedure, default to update
procedure
- private boolean isUpdateProcedure = true;
-
- private List projectedSymbols;
-
- private GroupSymbol virtualGroup;
-
- //command that returns resultset. For virtual procedure only.
- private Command resultsCommand;
- /**
- * Constructor for CreateUpdateProcedureCommand.
- */
- public CreateUpdateProcedureCommand() {
- super();
- }
-
- /**
- * Constructor for CreateUpdateProcedureCommand.
- * @param block The block on this command
- * @param type The procedure type
- */
- public CreateUpdateProcedureCommand(Block block) {
- this.block = block;
- }
-
- /**
- * Return type of command to make it easier to build switch statements by command type.
- * @return The type of this command
- */
- public int getType() {
- return Command.TYPE_UPDATE_PROCEDURE;
- }
-
- /**
- * Get the block on this command.
- * @return The <code>Block</code> on this command
- */
- public Block getBlock() {
- return block;
- }
-
- /**
- * Set the block on this command.
- * @param block The <code>Block</code> on this command
- */
- public void setBlock(Block block) {
- this.block = block;
- }
-
- /**
- * Set the user's command to which this obj which is the subcommand
- * @param command The user's command
- */
- public void setUserCommand(Command command) {
- this.userCommand = command;
- }
-
- /**
- * Get the user's command to which this obj which is the subcommand
- * @return The user's command
- */
- public Command getUserCommand() {
- return this.userCommand;
- }
-
- /**
- * Set the symbol map between elements on the virtual group being updated and the
- * elements on the transformation query.
- * @param symbolMap Map of virtual group elements -> elements that define those
- */
- public void setSymbolMap(Map symbolMap) {
- this.symbolMap = symbolMap;
- }
-
- /**
- * Get the symbol map between elements on the virtual group being updated and the
- * elements on the transformation query.
- * @return Map of virtual group elements -> elements that define those
- */
- public Map getSymbolMap() {
- return this.symbolMap;
- }
-
- // =========================================================================
- // P R O C E S S I N G M E T H O D S
- // =========================================================================
-
- public void acceptVisitor(LanguageVisitor visitor) {
- visitor.visit(this);
- }
-
- /**
- * Deep clone statement to produce a new identical statement.
- * @return Deep clone
- */
- public Object clone() {
- CreateUpdateProcedureCommand copy = new CreateUpdateProcedureCommand();
-
- //Clone this class state
- if (this.block != null) {
- copy.setBlock(this.block.clone());
- }
- if (this.getSymbolMap() != null) {
- copy.setSymbolMap(new HashMap(this.getSymbolMap()));
- }
- copy.setUpdateProcedure(isUpdateProcedure());
- if (this.projectedSymbols != null) {
- copy.setProjectedSymbols(new ArrayList(this.projectedSymbols));
- }
- if (this.virtualGroup != null) {
- copy.virtualGroup = this.virtualGroup.clone();
- }
- this.copyMetadataState(copy);
- return copy;
- }
-
- /**
- * Compare two CreateUpdateProcedureCommand for equality. They will only evaluate to
equal if
- * they are IDENTICAL: the commandTypes are same and the block objects are equal.
- * @param obj Other object
- * @return True if equal
- */
- public boolean equals(Object obj) {
- // Quick same object test
- if(this == obj) {
- return true;
- }
-
- // Quick fail tests
- if(! (obj instanceof CreateUpdateProcedureCommand)) {
- return false;
- }
-
- CreateUpdateProcedureCommand other = (CreateUpdateProcedureCommand)obj;
-
- // Compare the block
- return sameOptionAndHint(other) && EquivalenceUtil.areEqual(getBlock(),
other.getBlock());
- }
-
- /**
- * Get hashcode for CreateUpdateProcedureCommand. WARNING: This hash code relies
- * on the hash codes of the block and the procedure type of this command. Hash code
- * is only valid after the command has been completely constructed.
- * @return Hash code
- */
- public int hashCode() {
- // This hash code relies on the block and the procedure type for this command
- int myHash = 0;
- myHash = HashCodeUtil.hashCode(myHash, this.getBlock());
- return myHash;
- }
-
- /**
- * Returns a string representation of an instance of this class.
- * @return String representation of object
- */
- public String toString() {
- return SQLStringVisitor.getSQLString(this);
- }
-
- // ========================================
- // Methods inherited from Command
- // ========================================
-
- /**
- * Get the ordered list of all elements returned by this query. These elements
- * may be ElementSymbols or ExpressionSymbols but in all cases each represents a
- * single column.
- * @return Ordered list of SingleElementSymbol
- */
- public List getProjectedSymbols(){
- if(this.projectedSymbols != null){
- return this.projectedSymbols;
- }
- if(!isUpdateProcedure){
- if(this.resultsCommand == null){
- //user may have not entered any query yet
- return Collections.EMPTY_LIST;
- }
- List<? extends SingleElementSymbol> symbols =
this.resultsCommand.getProjectedSymbols();
- if (this.resultsCommand instanceof StoredProcedure) {
- StoredProcedure sp = (StoredProcedure)this.resultsCommand;
- if (sp.isCallableStatement()) {
- symbols = sp.getResultSetColumns();
- }
- }
- setProjectedSymbols(symbols);
- return this.projectedSymbols;
- }
- this.projectedSymbols = Command.getUpdateCommandSymbol();
- return this.projectedSymbols;
- }
-
- /**
- * @return
- */
- public boolean isUpdateProcedure() {
- return isUpdateProcedure;
- }
-
- /**
- * @param isUpdateProcedure
- */
- public void setUpdateProcedure(boolean isUpdateProcedure) {
- this.isUpdateProcedure = isUpdateProcedure;
- }
-
- /**
- * @param projSymbols
- */
- public void setProjectedSymbols(List projSymbols) {
- projectedSymbols = projSymbols;
- }
-
- /**
- * @return Command
- */
- public Command getResultsCommand() {
- return resultsCommand;
- }
-
- /**
- * @param command
- */
- public void setResultsCommand(Command command) {
- resultsCommand = command;
- }
-
- /**
- * @see org.teiid.query.sql.lang.Command#areResultsCachable()
- */
- public boolean areResultsCachable() {
- if(isUpdateProcedure()){
- return false;
- }
- return Query.areResultsCachable(getProjectedSymbols());
- }
-
- public GroupSymbol getVirtualGroup() {
- return this.virtualGroup;
- }
-
- public void setVirtualGroup(GroupSymbol virtualGroup) {
- this.virtualGroup = virtualGroup;
- }
-
-} // END CLASS
Modified: trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java 2011-11-22
12:49:12 UTC (rev 3682)
+++
trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java 2011-11-22
12:55:13 UTC (rev 3683)
@@ -39,100 +39,14 @@
import org.teiid.metadata.BaseColumn.NullType;
import org.teiid.query.sql.LanguageObject;
import org.teiid.query.sql.LanguageVisitor;
-import org.teiid.query.sql.lang.AlterProcedure;
-import org.teiid.query.sql.lang.AlterTrigger;
-import org.teiid.query.sql.lang.AlterView;
-import org.teiid.query.sql.lang.ArrayTable;
-import org.teiid.query.sql.lang.AtomicCriteria;
-import org.teiid.query.sql.lang.BetweenCriteria;
-import org.teiid.query.sql.lang.CacheHint;
-import org.teiid.query.sql.lang.CompareCriteria;
-import org.teiid.query.sql.lang.CompoundCriteria;
-import org.teiid.query.sql.lang.Create;
-import org.teiid.query.sql.lang.Criteria;
-import org.teiid.query.sql.lang.Delete;
-import org.teiid.query.sql.lang.DependentSetCriteria;
-import org.teiid.query.sql.lang.Drop;
-import org.teiid.query.sql.lang.DynamicCommand;
-import org.teiid.query.sql.lang.ExistsCriteria;
-import org.teiid.query.sql.lang.ExpressionCriteria;
-import org.teiid.query.sql.lang.From;
-import org.teiid.query.sql.lang.FromClause;
-import org.teiid.query.sql.lang.GroupBy;
-import org.teiid.query.sql.lang.Insert;
-import org.teiid.query.sql.lang.Into;
-import org.teiid.query.sql.lang.IsNullCriteria;
-import org.teiid.query.sql.lang.JoinPredicate;
-import org.teiid.query.sql.lang.JoinType;
-import org.teiid.query.sql.lang.Limit;
-import org.teiid.query.sql.lang.MatchCriteria;
-import org.teiid.query.sql.lang.NotCriteria;
-import org.teiid.query.sql.lang.Option;
-import org.teiid.query.sql.lang.OrderBy;
-import org.teiid.query.sql.lang.OrderByItem;
-import org.teiid.query.sql.lang.PredicateCriteria;
-import org.teiid.query.sql.lang.Query;
-import org.teiid.query.sql.lang.QueryCommand;
-import org.teiid.query.sql.lang.SPParameter;
-import org.teiid.query.sql.lang.Select;
-import org.teiid.query.sql.lang.SetClause;
-import org.teiid.query.sql.lang.SetClauseList;
-import org.teiid.query.sql.lang.SetCriteria;
-import org.teiid.query.sql.lang.SetQuery;
-import org.teiid.query.sql.lang.SourceHint;
-import org.teiid.query.sql.lang.StoredProcedure;
-import org.teiid.query.sql.lang.SubqueryCompareCriteria;
-import org.teiid.query.sql.lang.SubqueryFromClause;
-import org.teiid.query.sql.lang.SubquerySetCriteria;
-import org.teiid.query.sql.lang.TextTable;
-import org.teiid.query.sql.lang.UnaryFromClause;
-import org.teiid.query.sql.lang.Update;
-import org.teiid.query.sql.lang.WithQueryCommand;
-import org.teiid.query.sql.lang.XMLTable;
+import org.teiid.query.sql.lang.*;
import org.teiid.query.sql.lang.ExistsCriteria.SubqueryHint;
import org.teiid.query.sql.lang.TableFunctionReference.ProjectedColumn;
import org.teiid.query.sql.lang.TextTable.TextColumn;
import org.teiid.query.sql.lang.XMLTable.XMLColumn;
-import org.teiid.query.sql.proc.AssignmentStatement;
-import org.teiid.query.sql.proc.Block;
-import org.teiid.query.sql.proc.BranchingStatement;
-import org.teiid.query.sql.proc.CommandStatement;
-import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
-import org.teiid.query.sql.proc.DeclareStatement;
-import org.teiid.query.sql.proc.IfStatement;
-import org.teiid.query.sql.proc.LoopStatement;
-import org.teiid.query.sql.proc.RaiseErrorStatement;
-import org.teiid.query.sql.proc.Statement;
-import org.teiid.query.sql.proc.TriggerAction;
-import org.teiid.query.sql.proc.WhileStatement;
+import org.teiid.query.sql.proc.*;
import org.teiid.query.sql.proc.Statement.Labeled;
-import org.teiid.query.sql.symbol.AggregateSymbol;
-import org.teiid.query.sql.symbol.AliasSymbol;
-import org.teiid.query.sql.symbol.CaseExpression;
-import org.teiid.query.sql.symbol.Constant;
-import org.teiid.query.sql.symbol.DerivedColumn;
-import org.teiid.query.sql.symbol.ElementSymbol;
-import org.teiid.query.sql.symbol.Expression;
-import org.teiid.query.sql.symbol.ExpressionSymbol;
-import org.teiid.query.sql.symbol.Function;
-import org.teiid.query.sql.symbol.GroupSymbol;
-import org.teiid.query.sql.symbol.MultipleElementSymbol;
-import org.teiid.query.sql.symbol.QueryString;
-import org.teiid.query.sql.symbol.Reference;
-import org.teiid.query.sql.symbol.ScalarSubquery;
-import org.teiid.query.sql.symbol.SearchedCaseExpression;
-import org.teiid.query.sql.symbol.SelectSymbol;
-import org.teiid.query.sql.symbol.SingleElementSymbol;
-import org.teiid.query.sql.symbol.TextLine;
-import org.teiid.query.sql.symbol.WindowFunction;
-import org.teiid.query.sql.symbol.WindowSpecification;
-import org.teiid.query.sql.symbol.XMLAttributes;
-import org.teiid.query.sql.symbol.XMLElement;
-import org.teiid.query.sql.symbol.XMLForest;
-import org.teiid.query.sql.symbol.XMLNamespaces;
-import org.teiid.query.sql.symbol.XMLParse;
-import org.teiid.query.sql.symbol.XMLQuery;
-import org.teiid.query.sql.symbol.XMLSerialize;
+import org.teiid.query.sql.symbol.*;
import org.teiid.query.sql.symbol.AggregateSymbol.Type;
import org.teiid.query.sql.symbol.XMLNamespaces.NamespaceItem;
import org.teiid.translator.SourceSystemFunctions;
@@ -1459,13 +1373,11 @@
append(";"); //$NON-NLS-1$
}
- public void visit( CreateUpdateProcedureCommand obj ) {
+ public void visit( CreateProcedureCommand obj ) {
append(CREATE);
append(SPACE);
- if (!obj.isUpdateProcedure()) {
- append(VIRTUAL);
- append(SPACE);
- }
+ append(VIRTUAL);
+ append(SPACE);
append(PROCEDURE);
append("\n"); //$NON-NLS-1$
addTabs(0);
Modified: trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2011-11-22
12:49:12 UTC (rev 3682)
+++ trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2011-11-22
12:55:13 UTC (rev 3683)
@@ -60,7 +60,7 @@
import org.teiid.query.sql.navigator.PreOrderNavigator;
import org.teiid.query.sql.proc.Block;
import org.teiid.query.sql.proc.BranchingStatement;
-import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
+import org.teiid.query.sql.proc.CreateProcedureCommand;
import org.teiid.query.sql.proc.LoopStatement;
import org.teiid.query.sql.proc.WhileStatement;
import org.teiid.query.sql.proc.BranchingStatement.BranchingMode;
@@ -367,15 +367,10 @@
}
}
- public void visit(CreateUpdateProcedureCommand obj) {
- if(!obj.isUpdateProcedure()){
-
- //check that the procedure does not contain references to itself
- if
(GroupCollectorVisitor.getGroups(obj,true).contains(obj.getVirtualGroup())) {
-
handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.Procedure_has_group_self_reference"),obj);
//$NON-NLS-1$
- }
-
- return;
+ public void visit(CreateProcedureCommand obj) {
+ //check that the procedure does not contain references to itself
+ if (GroupCollectorVisitor.getGroups(obj,true).contains(obj.getVirtualGroup())) {
+
handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.Procedure_has_group_self_reference"),obj);
//$NON-NLS-1$
}
}
Modified: trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj
===================================================================
--- trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj 2011-11-22 12:49:12
UTC (rev 3682)
+++ trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj 2011-11-22 12:55:13
UTC (rev 3683)
@@ -1066,10 +1066,7 @@
Statement stmt = null;
}
{
- <CREATE> [<VIRTUAL> {updateProcCmd.setUpdateProcedure(false);}]
- [<UPDATE>]
- <PROCEDURE>
-
+ <CREATE> [<VIRTUAL>] <PROCEDURE>
stmt = statement(info)
{
updateProcCmd.setBlock(asBlock(stmt));
Modified:
trunk/engine/src/test/java/org/teiid/query/optimizer/proc/TestProcedurePlanner.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/optimizer/proc/TestProcedurePlanner.java 2011-11-22
12:49:12 UTC (rev 3682)
+++
trunk/engine/src/test/java/org/teiid/query/optimizer/proc/TestProcedurePlanner.java 2011-11-22
12:55:13 UTC (rev 3683)
@@ -40,7 +40,7 @@
import org.teiid.query.resolver.QueryResolver;
import org.teiid.query.rewriter.QueryRewriter;
import org.teiid.query.sql.lang.Command;
-import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
+import org.teiid.query.sql.proc.CreateProcedureCommand;
import org.teiid.query.sql.symbol.GroupSymbol;
import org.teiid.query.unittest.RealMetadataFactory;
import org.teiid.query.validator.Validator;
@@ -61,10 +61,10 @@
QueryParser parser = QueryParser.getQueryParser();
Command userCommand = userQuery != null ? parser.parseCommand(userQuery) :
parser.parseCommand(procedure);
- if (userCommand instanceof CreateUpdateProcedureCommand) {
+ if (userCommand instanceof CreateProcedureCommand) {
GroupSymbol gs = new GroupSymbol("proc");
gs.setMetadataID(new TempMetadataID("proc", Collections.EMPTY_LIST));
- ((CreateUpdateProcedureCommand)userCommand).setVirtualGroup(gs);
+ ((CreateProcedureCommand)userCommand).setVirtualGroup(gs);
}
QueryResolver.resolveCommand(userCommand, metadata);
Modified: trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java 2011-11-22 12:49:12
UTC (rev 3682)
+++ trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java 2011-11-22 12:55:13
UTC (rev 3683)
@@ -3888,7 +3888,7 @@
CommandStatement cmdStmt = new CommandStatement(query);
block.addStatement(cmdStmt);
- CreateUpdateProcedureCommand virtualProcedureCommand = new
CreateUpdateProcedureCommand();
+ CreateProcedureCommand virtualProcedureCommand = new CreateProcedureCommand();
virtualProcedureCommand.setBlock(block);
virtualProcedureCommand.setUpdateProcedure(false);
@@ -4913,8 +4913,8 @@
}
@Test public void testIfElseWithoutBeginEnd() {
- String sql = "CREATE PROCEDURE BEGIN IF (x > 1) select 1; IF (x > 1)
select 1; ELSE select 1; END"; //$NON-NLS-1$
- String expected = "CREATE PROCEDURE\nBEGIN\nIF(x > 1)\nBEGIN\nSELECT
1;\nEND\nIF(x > 1)\nBEGIN\nSELECT 1;\nEND\nELSE\nBEGIN\nSELECT 1;\nEND\nEND";
//$NON-NLS-1$
+ String sql = "CREATE VIRTUAL PROCEDURE BEGIN IF (x > 1) select 1; IF (x
> 1) select 1; ELSE select 1; END"; //$NON-NLS-1$
+ String expected = "CREATE VIRTUAL PROCEDURE\nBEGIN\nIF(x >
1)\nBEGIN\nSELECT 1;\nEND\nIF(x > 1)\nBEGIN\nSELECT 1;\nEND\nELSE\nBEGIN\nSELECT
1;\nEND\nEND"; //$NON-NLS-1$
Query query = new Query();
query.setSelect(new Select(Arrays.asList(new ExpressionSymbol("expr",
new Constant(1))))); //$NON-NLS-1$
@@ -4930,7 +4930,7 @@
Block block3 = new Block();
block3.addStatement(ifStmt);
block3.addStatement(ifStmt1);
- CreateUpdateProcedureCommand command = new CreateUpdateProcedureCommand(block3);
+ CreateProcedureCommand command = new CreateProcedureCommand(block3);
helpTest(sql, expected, command);
}
Modified:
trunk/engine/src/test/java/org/teiid/query/processor/TestInherintlyUpdatableViews.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/processor/TestInherintlyUpdatableViews.java 2011-11-22
12:49:12 UTC (rev 3682)
+++
trunk/engine/src/test/java/org/teiid/query/processor/TestInherintlyUpdatableViews.java 2011-11-22
12:55:13 UTC (rev 3683)
@@ -60,8 +60,8 @@
CommandContext context = createCommandContext();
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
caps.setFunctionSupport(SourceSystemFunctions.CONVERT, true);
- ProcessorPlan plan = helpGetPlan(command, metadata, new
DefaultCapabilitiesFinder(caps), context);
- List[] expected = new List[] {Arrays.asList(1)};
+ ProcessorPlan plan = helpGetPlan(helpParse(userSql), metadata, new
DefaultCapabilitiesFinder(caps), context);
+ List<?>[] expected = new List[] {Arrays.asList(1)};
helpProcess(plan, context, dm, expected);
}
@@ -116,7 +116,7 @@
dm.addData("SELECT g_1.e2, g_1.e2 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 WHERE
(g_0.e1 = g_1.e1) AND (g_1.e3 IS NULL)", new List[] {Arrays.asList(1, 1)});
dm.addData("UPDATE pm1.g2 SET e1 = pm1.g2.e2 WHERE pm1.g2.e2 = 1", new
List[] {Arrays.asList(1)});
- helpTest(userSql, viewSql, "CREATE PROCEDURE\nBEGIN\nLOOP ON (SELECT pm1.g2.e2 AS
s_0, pm1.g2.e2 AS s_1 FROM pm1.g1 INNER JOIN pm1.g2 ON g1.e1 = g2.e1 WHERE pm1.g2.e3 IS
NULL) AS X\nBEGIN\nUPDATE pm1.g2 SET e1 = pm1.g2.e2 WHERE pm1.g2.e2 =
X.s_1;\nVARIABLES.ROWS_UPDATED = (VARIABLES.ROWS_UPDATED + 1);\nEND\nEND",
+ helpTest(userSql, viewSql, "CREATE VIRTUAL PROCEDURE\nBEGIN ATOMIC\nDECLARE
integer VARIABLES.ROWS_UPDATED = 0;\nLOOP ON (SELECT pm1.g2.e2 AS s_0, pm1.g2.e2 AS s_1
FROM pm1.g1 INNER JOIN pm1.g2 ON g1.e1 = g2.e1 WHERE pm1.g2.e3 IS NULL) AS
X\nBEGIN\nUPDATE pm1.g2 SET e1 = pm1.g2.e2 WHERE pm1.g2.e2 =
X.s_1;\nVARIABLES.ROWS_UPDATED = (VARIABLES.ROWS_UPDATED + 1);\nEND\nSELECT
VARIABLES.ROWS_UPDATED;\nEND",
dm);
}
@@ -128,7 +128,7 @@
dm.addData("SELECT g_1.e2 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 WHERE (g_0.e1 =
g_1.e1) AND (g_1.e2 < 10)", new List[] {Arrays.asList(2)});
dm.addData("DELETE FROM pm1.g2 WHERE pm1.g2.e2 = 2", new List[]
{Arrays.asList(1)});
- helpTest(userSql, viewSql, "CREATE PROCEDURE\nBEGIN\nLOOP ON (SELECT pm1.g2.e2 AS
s_0 FROM pm1.g1 INNER JOIN pm1.g2 ON g1.e1 = g2.e1 WHERE pm1.g2.e2 < 10) AS
X\nBEGIN\nDELETE FROM pm1.g2 WHERE pm1.g2.e2 = X.s_0;\nVARIABLES.ROWS_UPDATED =
(VARIABLES.ROWS_UPDATED + 1);\nEND\nEND",
+ helpTest(userSql, viewSql, "CREATE VIRTUAL PROCEDURE\nBEGIN ATOMIC\nDECLARE
integer VARIABLES.ROWS_UPDATED = 0;\nLOOP ON (SELECT pm1.g2.e2 AS s_0 FROM pm1.g1 INNER
JOIN pm1.g2 ON g1.e1 = g2.e1 WHERE pm1.g2.e2 < 10) AS X\nBEGIN\nDELETE FROM pm1.g2
WHERE pm1.g2.e2 = X.s_0;\nVARIABLES.ROWS_UPDATED = (VARIABLES.ROWS_UPDATED +
1);\nEND\nSELECT VARIABLES.ROWS_UPDATED;\nEND",
dm);
}
Modified:
trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java 2011-11-22
12:49:12 UTC (rev 3682)
+++
trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java 2011-11-22
12:55:13 UTC (rev 3683)
@@ -44,7 +44,6 @@
import org.teiid.metadata.Procedure;
import org.teiid.metadata.ProcedureParameter;
import org.teiid.metadata.Schema;
-import org.teiid.metadata.Table;
import org.teiid.query.analysis.AnalysisRecord;
import org.teiid.query.mapping.relational.QueryNode;
import org.teiid.query.metadata.QueryMetadataInterface;
@@ -124,10 +123,6 @@
}
}
- private void helpTestProcess(ProcessorPlan procPlan, int expectedRows,
FakeDataManager dataMgr, QueryMetadataInterface metadata) throws Exception {
- helpTestProcess(procPlan, new List[] {Arrays.asList(expectedRows)}, dataMgr,
metadata);
- }
-
private FakeDataManager exampleDataManager(QueryMetadataInterface metadata) throws
TeiidException {
FakeDataManager dataMgr = new FakeDataManager();
@@ -202,147 +197,6 @@
return dataMgr;
}
- // procedure does nothing returns zero update count
- @Test public void testProcedureProcessor1() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1 = 0;\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED = ROWS_UPDATED + var1;\n";
//$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'";
//$NON-NLS-1$
-
- QueryMetadataInterface metadata =
RealMetadataFactory.exampleUpdateProc(Table.TriggerEvent.UPDATE, procedure);
-
- FakeDataManager dataMgr = exampleDataManager(metadata);
-
- ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
-
- helpTestProcess(plan, 0, dataMgr, metadata);
- }
-
- // testing if statement
- @Test public void testProcedureProcessor2() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "var1 = Select pm1.g1.e2 from pm1.g1 where
e2=5;\n"; //$NON-NLS-1$
- procedure = procedure + "if(var1 = 5)\n"; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED = ROWS_UPDATED + var1;\n";
//$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
- procedure = procedure + "END"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'";
//$NON-NLS-1$
-
- QueryMetadataInterface metadata =
RealMetadataFactory.exampleUpdateProc(Table.TriggerEvent.UPDATE, procedure);
-
- FakeDataManager dataMgr = exampleDataManager(metadata);
-
- ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
-
- helpTestProcess(plan, 5, dataMgr, metadata);
- }
-
- // testing if statement
- @Test public void testProcedureProcessor2WithBlockedException() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "var1 = Select pm1.g1.e2 from pm1.g1 where
e2=5;\n"; //$NON-NLS-1$
- procedure = procedure + "if(var1 = 5)\n"; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED = ROWS_UPDATED + var1;\n";
//$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
- procedure = procedure + "END"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'";
//$NON-NLS-1$
-
- QueryMetadataInterface metadata =
RealMetadataFactory.exampleUpdateProc(Table.TriggerEvent.UPDATE, procedure);
-
- FakeDataManager dataMgr = exampleDataManager(metadata);
- dataMgr.setBlockOnce();
-
- ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
-
- helpTestProcess(plan, 5, dataMgr, metadata);
- }
-
- // more rows than expected
- @Test public void testProcedureProcessor6() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from
pm1.g1;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'";
//$NON-NLS-1$
-
- QueryMetadataInterface metadata =
RealMetadataFactory.exampleUpdateProc(Table.TriggerEvent.UPDATE, procedure);
-
- FakeDataManager dataMgr = exampleDataManager(metadata);
-
- ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
-
- helpTestProcessFailure(plan, dataMgr, "Error Code:ERR.015.006.0058
Message:Unable to evaluate (SELECT pm1.g1.e2 FROM pm1.g1 LIMIT 2): Error
Code:ERR.015.006.0058 Message:The command of this scalar subquery returned more than one
value: SELECT pm1.g1.e2 FROM pm1.g1 LIMIT 2", metadata); //$NON-NLS-1$
- }
-
- // error statement
- @Test public void testProcedureProcessor7() throws Exception {
- String errorValue = "'MY ERROR'"; //$NON-NLS-1$
- helpTestErrorStatment(errorValue, "MY ERROR"); //$NON-NLS-1$
- }
-
- @Test public void testProcedureProcessor8() throws Exception {
- String errorValue = "var1"; //$NON-NLS-1$
- helpTestErrorStatment(errorValue, "5"); //$NON-NLS-1$
- }
-
- @Test public void testProcedureProcessor9() throws Exception {
- String errorValue = "var1||'MY ERROR'"; //$NON-NLS-1$
- helpTestErrorStatment(errorValue, "5MY ERROR"); //$NON-NLS-1$
- }
-
- @Test public void testProcedureProcessor10() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "loop on (Select pm1.g1.e2 from pm1.g1 where e2 = 5)
as mycursor\n"; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "ERROR (mycursor.e2||'MY ERROR');\n";
//$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED = 0;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'";
//$NON-NLS-1$
-
- QueryMetadataInterface metadata =
RealMetadataFactory.exampleUpdateProc(Table.TriggerEvent.UPDATE, procedure);
-
- FakeDataManager dataMgr = exampleDataManager(metadata);
-
- ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
-
- helpTestProcessFailure(plan, dataMgr, ErrorInstruction.ERROR_PREFIX + "5MY
ERROR", metadata); //$NON-NLS-1$
- }
-
- private void helpTestErrorStatment(String errorValue, String expected) throws
Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "var1 = 5;\n"; //$NON-NLS-1$
- procedure = procedure + "ERROR "+errorValue+";\n";
//$NON-NLS-1$ //$NON-NLS-2$
- procedure = procedure + "ROWS_UPDATED = 0;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'";
//$NON-NLS-1$
-
- QueryMetadataInterface metadata =
RealMetadataFactory.exampleUpdateProc(Table.TriggerEvent.UPDATE, procedure);
-
- FakeDataManager dataMgr = exampleDataManager(metadata);
-
- ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
-
- helpTestProcessFailure(plan, dataMgr, ErrorInstruction.ERROR_PREFIX + expected,
metadata);
- }
-
@Test public void testVirtualProcedure() throws Exception {
String userUpdateStr = "EXEC pm1.vsp2()"; //$NON-NLS-1$
@@ -1891,58 +1745,6 @@
helpTestProcess(plan, expected, dataMgr, metadata);
}
- @Test public void testDefect8693() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "var1 = Select pm1.g1.e2 from pm1.g1 where e2 =
5;\n"; //$NON-NLS-1$
- procedure = procedure + "if (5 in (select 5 from pm1.g1))\n";
//$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED = ROWS_UPDATED + var1;\n";
//$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
- procedure = procedure + "END"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'";
//$NON-NLS-1$
-
- QueryMetadataInterface metadata =
RealMetadataFactory.exampleUpdateProc(Table.TriggerEvent.UPDATE, procedure);
- FakeDataManager dataMgr = exampleDataManager(metadata);
- ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
- helpTestProcess(plan, 5, dataMgr, metadata);
- }
-
- @Test public void testWhileWithSubquery() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1 = 2;\n"; //$NON-NLS-1$
- procedure = procedure + "WHILE (5 in (select var1 from pm1.g1))\n";
//$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED = ROWS_UPDATED + var1;\n";
//$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
- procedure = procedure + "END"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'";
//$NON-NLS-1$
-
- QueryMetadataInterface metadata =
RealMetadataFactory.exampleUpdateProc(Table.TriggerEvent.UPDATE, procedure);
- FakeDataManager dataMgr = exampleDataManager(metadata);
- ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
- helpTestProcess(plan, 0, dataMgr, metadata);
- }
-
- @Test public void testDefect18404() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1 = 5 + (select count(e2) from
pm1.g1);\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED = ROWS_UPDATED + var1;\n";
//$NON-NLS-1$
- procedure = procedure + "END"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'";
//$NON-NLS-1$
-
- QueryMetadataInterface metadata =
RealMetadataFactory.exampleUpdateProc(Table.TriggerEvent.UPDATE, procedure);
- FakeDataManager dataMgr = exampleDataManager(metadata);
- ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
- helpTestProcess(plan, 8, dataMgr, metadata);
- }
-
/**
* Test the use of a procedure variable in the criteria of a LEFT OUTER
* JOIN which will be optimized out as non-JOIN criteria.
Modified: trunk/engine/src/test/java/org/teiid/query/resolver/TestProcedureResolving.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/resolver/TestProcedureResolving.java 2011-11-22
12:49:12 UTC (rev 3682)
+++
trunk/engine/src/test/java/org/teiid/query/resolver/TestProcedureResolving.java 2011-11-22
12:55:13 UTC (rev 3683)
@@ -44,7 +44,7 @@
import org.teiid.query.sql.proc.AssignmentStatement;
import org.teiid.query.sql.proc.Block;
import org.teiid.query.sql.proc.CommandStatement;
-import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
+import org.teiid.query.sql.proc.CreateProcedureCommand;
import org.teiid.query.sql.proc.LoopStatement;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
@@ -109,19 +109,19 @@
assertNull(tempIDs.get("LOOPCURSOR2")); //$NON-NLS-1$
}
- private CreateUpdateProcedureCommand helpResolveUpdateProcedure(String procedure, String
userUpdateStr, Table.TriggerEvent procedureType) throws QueryParserException,
QueryResolverException, TeiidComponentException {
+ private CreateProcedureCommand helpResolveUpdateProcedure(String procedure, String
userUpdateStr, Table.TriggerEvent procedureType) throws QueryParserException,
QueryResolverException, TeiidComponentException {
QueryMetadataInterface metadata =
RealMetadataFactory.exampleUpdateProc(procedureType, procedure);
return resolveProcedure(userUpdateStr, metadata);
}
- private CreateUpdateProcedureCommand resolveProcedure(String userUpdateStr,
+ private CreateProcedureCommand resolveProcedure(String userUpdateStr,
QueryMetadataInterface metadata) throws QueryParserException,
QueryResolverException, TeiidComponentException,
QueryMetadataException {
ProcedureContainer userCommand =
(ProcedureContainer)QueryParser.getQueryParser().parseCommand(userUpdateStr);
QueryResolver.resolveCommand(userCommand, metadata);
metadata = new TempMetadataAdapter(metadata, new
TempMetadataStore(userCommand.getTemporaryMetadata()));
- return (CreateUpdateProcedureCommand)QueryResolver.expandCommand(userCommand,
metadata, null);
+ return (CreateProcedureCommand)QueryResolver.expandCommand(userCommand, metadata,
null);
}
private void helpResolveException(String userUpdateStr, QueryMetadataInterface metadata,
String msg) throws QueryParserException, TeiidComponentException {
@@ -133,7 +133,7 @@
}
}
- private CreateUpdateProcedureCommand helpResolve(String userUpdateStr,
QueryMetadataInterface metadata) throws QueryParserException, QueryResolverException,
TeiidComponentException {
+ private CreateProcedureCommand helpResolve(String userUpdateStr, QueryMetadataInterface
metadata) throws QueryParserException, QueryResolverException, TeiidComponentException {
return resolveProcedure(userUpdateStr, metadata);
}
@@ -141,7 +141,7 @@
* Constants will now auto resolve if they are consistently representable in the
target type
*/
@Test public void testDefect23257() throws Exception{
- CreateUpdateProcedureCommand command = helpResolve("EXEC pm6.vsp59()",
RealMetadataFactory.example1Cached()); //$NON-NLS-1$
+ CreateProcedureCommand command = helpResolve("EXEC pm6.vsp59()",
RealMetadataFactory.example1Cached()); //$NON-NLS-1$
CommandStatement cs =
(CommandStatement)command.getBlock().getStatements().get(1);
@@ -165,7 +165,7 @@
String userUpdateStr = "UPDATE vm1.g1 SET e1='x'";
//$NON-NLS-1$
- CreateUpdateProcedureCommand command =
helpResolveUpdateProcedure(proc.toString(), userUpdateStr,
+ CreateProcedureCommand command = helpResolveUpdateProcedure(proc.toString(),
userUpdateStr,
Table.TriggerEvent.UPDATE);
Block block = command.getBlock();
@@ -494,7 +494,6 @@
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE string var1;\n"; //$NON-NLS-1$
procedure = procedure + "var1 = 1+1;"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
@@ -503,22 +502,6 @@
Table.TriggerEvent.UPDATE);
}
- // resolving AssignmentStatement, variable type and assigned type
- // do not match, but implicit conversion available
- @Test public void testCreateUpdateProcedure55() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE string var1;\n"; //$NON-NLS-1$
- procedure = procedure + "var1 = 1+ROWS_UPDATED;"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
- helpResolveUpdateProcedure(procedure, userUpdateStr,
- Table.TriggerEvent.UPDATE);
- }
-
@Test public void
testDefect14912_CreateUpdateProcedure57_FunctionWithElementParamInAssignmentStatement() {
// Tests that the function params are resolved before the function for assignment
statements
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
@@ -538,7 +521,6 @@
@Test public void testCase4624() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "VARIABLES.ROWS_UPDATED = 0;\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE boolean var1;\n"; //$NON-NLS-1$
procedure = procedure + "var1 = {b'false'};\n"; //$NON-NLS-1$
procedure = procedure + "IF(var1 = {b 'true'})\n";
//$NON-NLS-1$
@@ -617,7 +599,6 @@
.append("BEGIN\n") //$NON-NLS-1$
.append("execute string 'SELECT e1, e2, e3, e4
FROM pm1.g2' as e1 string, e2 string, e3 string, e4 string INTO #myTempTable;\n")
//$NON-NLS-1$
.append("select e1 from #myTempTable;\n")
//$NON-NLS-1$
- .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
.append("END\n"); //$NON-NLS-1$
helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
Table.TriggerEvent.UPDATE);
@@ -629,7 +610,6 @@
StringBuffer procedure = new StringBuffer("CREATE PROCEDURE ")
//$NON-NLS-1$
.append("BEGIN\n") //$NON-NLS-1$
.append("execute string 'SELECT e1, e2, e3, e4
FROM pm1.g2';\n") //$NON-NLS-1$
- .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
.append("END\n"); //$NON-NLS-1$
helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
Table.TriggerEvent.UPDATE);
@@ -682,7 +662,6 @@
StringBuffer procedure = new StringBuffer("CREATE PROCEDURE ")
//$NON-NLS-1$
.append("BEGIN\n") //$NON-NLS-1$
.append("SELECT e1, e2, e3, e4 INTO
pm1.g1 FROM pm1.g2;\n") //$NON-NLS-1$
- .append("ROWS_UPDATED =0;\n")
//$NON-NLS-1$
.append("END\n"); //$NON-NLS-1$
String userUpdateStr = "UPDATE vm1.g1 SET e1='x'";
//$NON-NLS-1$
@@ -693,7 +672,6 @@
procedure = new StringBuffer("CREATE PROCEDURE ") //$NON-NLS-1$
.append("BEGIN\n") //$NON-NLS-1$
.append("SELECT e1, e2, e3, e4 INTO #myTempTable
FROM pm1.g2;\n") //$NON-NLS-1$
- .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
.append("END\n"); //$NON-NLS-1$
helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
Table.TriggerEvent.UPDATE);
@@ -703,7 +681,6 @@
StringBuffer procedure = new StringBuffer("CREATE PROCEDURE ")
//$NON-NLS-1$
.append("BEGIN\n") //$NON-NLS-1$
.append("SELECT 'a', 19,
{b'true'}, 13.999 INTO pm1.g1;\n") //$NON-NLS-1$
- .append("ROWS_UPDATED =0;\n")
//$NON-NLS-1$
.append("END\n"); //$NON-NLS-1$
String userUpdateStr = "UPDATE vm1.g1 SET e1='x'";
//$NON-NLS-1$
@@ -714,56 +691,11 @@
procedure = new StringBuffer("CREATE PROCEDURE ") //$NON-NLS-1$
.append("BEGIN\n") //$NON-NLS-1$
.append("SELECT 'a', 19, {b'true'},
13.999 INTO #myTempTable;\n") //$NON-NLS-1$
- .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
.append("END\n"); //$NON-NLS-1$
helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
Table.TriggerEvent.UPDATE);
}
- /*@Test public void testCommandUpdating3() throws Exception{
- StringBuffer procedure = new StringBuffer("CREATE PROCEDURE ")
//$NON-NLS-1$
- .append("BEGIN\n") //$NON-NLS-1$
- .append("INSERT INTO pm1.g1 (e1) VALUES (INPUTS.e1);\n") //$NON-NLS-1$
- .append("ROWS_UPDATED = INSERT INTO pm1.g2 (e1) VALUES (INPUTS.e1);\n")
//$NON-NLS-1$
- .append("END\n"); //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'";
//$NON-NLS-1$
-
- Command command = helpResolveUpdateProcedure(procedure.toString(),
userUpdateStr,
- Table.TriggerEvent.UPDATE);
- assertEquals(2, command.updatingModelCount(metadata));
- }*/
-
- /*@Test public void testCommandUpdatingCount6() throws Exception{
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "if(INPUTS.e1 = 10)\n"; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "INSERT INTO pm1.g1 (e2) VALUES
(INPUTS.e2);\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "INSERT into vm1.g1 (e1) values('x')";
//$NON-NLS-1$
-
- Command command = helpResolveUpdateProcedure(procedure, userUpdateStr,
- Table.TriggerEvent.INSERT);
- assertEquals(2, command.updatingModelCount(metadata));
- }*/
-
- // variable declared is of special type ROWS_RETURNED
- @Test public void testDeclareRowsUpdated() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer rows_updated;\n";
//$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
-
- String userUpdateStr = "UPDATE vm1.g1 SET e1='x'";
//$NON-NLS-1$
-
- helpFailUpdateProcedure(procedure, userUpdateStr,
- Table.TriggerEvent.UPDATE, "Variable
rows_updated was previously declared."); //$NON-NLS-1$
- }
-
// validating INPUT element assigned
@Test public void testAssignInput() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
@@ -796,7 +728,7 @@
// variables cannot be used among insert elements
@Test public void testVariableInInsert() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ String procedure = "CREATE VIRTUAL PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
procedure = procedure + "Insert into pm1.g1 (pm1.g1.e2, var1) values (1,
2);\n"; //$NON-NLS-1$
@@ -811,7 +743,7 @@
// variables cannot be used among insert elements
@Test public void testVariableInInsert2() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ String procedure = "CREATE VIRTUAL PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
procedure = procedure + "Insert into pm1.g1 (pm1.g1.e2, INPUTS.x) values (1,
2);\n"; //$NON-NLS-1$
@@ -826,11 +758,10 @@
//should resolve first to the table's column
@Test public void testVariableInInsert3() throws Exception {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ String procedure = "CREATE VIRTUAL PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer e2;\n"; //$NON-NLS-1$
procedure = procedure + "Insert into pm1.g1 (e2) values (1);\n";
//$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
String userQuery = "UPDATE vm1.g3 SET x='x' where e3= 1";
//$NON-NLS-1$
@@ -852,7 +783,7 @@
}
@Test public void testLoopRedefinition() {
- StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+ StringBuffer proc = new StringBuffer("CREATE VIRTUAL PROCEDURE")
//$NON-NLS-1$
.append("\nBEGIN") //$NON-NLS-1$
.append("\n declare string var1;") //$NON-NLS-1$
.append("\n LOOP ON (SELECT pm1.g1.e1 FROM pm1.g1) AS loopCursor")
//$NON-NLS-1$
@@ -871,7 +802,7 @@
}
@Test public void testTempGroupElementShouldNotBeResolable() {
- StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+ StringBuffer proc = new StringBuffer("CREATE VIRTUAL PROCEDURE")
//$NON-NLS-1$
.append("\nBEGIN") //$NON-NLS-1$
.append("\n select 1 as a into #temp;") //$NON-NLS-1$
.append("\n select #temp.a from pm1.g1;") //$NON-NLS-1$
@@ -884,7 +815,7 @@
}
@Test public void testTempGroupElementShouldNotBeResolable1() {
- StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+ StringBuffer proc = new StringBuffer("CREATE VIRTUAL PROCEDURE")
//$NON-NLS-1$
.append("\nBEGIN") //$NON-NLS-1$
.append("\n select 1 as a into #temp;") //$NON-NLS-1$
.append("\n insert into #temp (a) values (#temp.a);") //$NON-NLS-1$
@@ -897,7 +828,7 @@
}
@Test public void testProcedureCreate() throws Exception {
- StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+ StringBuffer proc = new StringBuffer("CREATE VIRTUAL PROCEDURE")
//$NON-NLS-1$
.append("\nBEGIN") //$NON-NLS-1$
.append("\n create local temporary table t1 (e1 string);")
//$NON-NLS-1$
.append("\n select e1 from t1;") //$NON-NLS-1$
@@ -914,7 +845,7 @@
* it is not ok to redefine the loopCursor
*/
@Test public void testProcedureCreate1() {
- StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+ StringBuffer proc = new StringBuffer("CREATE VIRTUAL PROCEDURE")
//$NON-NLS-1$
.append("\nBEGIN") //$NON-NLS-1$
.append("\n LOOP ON (SELECT pm1.g1.e1 FROM pm1.g1) AS loopCursor")
//$NON-NLS-1$
.append("\n BEGIN") //$NON-NLS-1$
@@ -928,7 +859,7 @@
}
@Test public void testProcedureCreateDrop() {
- StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+ StringBuffer proc = new StringBuffer("CREATE VIRTUAL PROCEDURE")
//$NON-NLS-1$
.append("\nBEGIN") //$NON-NLS-1$
.append("\n drop table t1;") //$NON-NLS-1$
.append("\n create local temporary table t1 (e1 string);")
//$NON-NLS-1$
@@ -940,7 +871,7 @@
}
@Test public void testProcedureCreateDrop1() throws Exception {
- StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+ StringBuffer proc = new StringBuffer("CREATE VIRTUAL PROCEDURE")
//$NON-NLS-1$
.append("\nBEGIN") //$NON-NLS-1$
.append("\n create local temporary table t1 (e1 string);")
//$NON-NLS-1$
.append("\n drop table t1;") //$NON-NLS-1$
@@ -952,7 +883,7 @@
}
@Test public void testCreateAfterImplicitTempTable() throws Exception {
- StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+ StringBuffer proc = new StringBuffer("CREATE VIRTUAL PROCEDURE")
//$NON-NLS-1$
.append("\nBEGIN") //$NON-NLS-1$
.append("\n select e1 into #temp from pm1.g1;") //$NON-NLS-1$
.append("\n create local temporary table #temp (e1 string);")
//$NON-NLS-1$
@@ -979,16 +910,15 @@
* delete procedures should not reference input or changing vars.
*/
@Test public void testDefect16451() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure += "BEGIN\n"; //$NON-NLS-1$
- procedure += "Select pm1.g1.e2 from pm1.g1 where e1 = INPUTS.e1;\n";
//$NON-NLS-1$
- procedure += "ROWS_UPDATED = 0;"; //$NON-NLS-1$
+ String procedure = "FOR EACH ROW "; //$NON-NLS-1$
+ procedure += "BEGIN ATOMIC\n"; //$NON-NLS-1$
+ procedure += "Select pm1.g1.e2 from pm1.g1 where e1 = NEW.e1;\n";
//$NON-NLS-1$
procedure += "END\n"; //$NON-NLS-1$
String userUpdateStr = "delete from vm1.g1 where e1='x'";
//$NON-NLS-1$
helpFailUpdateProcedure(procedure, userUpdateStr,
- Table.TriggerEvent.DELETE, "Symbol INPUTS.e1 is specified with an unknown
group context"); //$NON-NLS-1$
+ Table.TriggerEvent.DELETE, "Symbol \"NEW\".e1 is specified with
an unknown group context"); //$NON-NLS-1$
}
@Test public void testInvalidVirtualProcedure3() throws Exception {
Modified: trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java 2011-11-22
12:49:12 UTC (rev 3682)
+++ trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java 2011-11-22
12:55:13 UTC (rev 3683)
@@ -70,7 +70,7 @@
import org.teiid.query.sql.lang.*;
import org.teiid.query.sql.navigator.DeepPreOrderNavigator;
import org.teiid.query.sql.proc.CommandStatement;
-import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
+import org.teiid.query.sql.proc.CreateProcedureCommand;
import org.teiid.query.sql.symbol.Constant;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
@@ -2407,7 +2407,7 @@
+"select * from xmltest.doc1 where node1 = x; " //$NON-NLS-1$
+"end "; //$NON-NLS-1$
- CreateUpdateProcedureCommand command = (CreateUpdateProcedureCommand)
helpResolve(sql);
+ CreateProcedureCommand command = (CreateProcedureCommand) helpResolve(sql);
CommandStatement cmdStmt =
(CommandStatement)command.getBlock().getStatements().get(1);
@@ -2887,7 +2887,7 @@
helpResolveUpdateProcedure(procedure, userUpdateStr);
}
- CreateUpdateProcedureCommand helpResolveUpdateProcedure(String procedure,
+ CreateProcedureCommand helpResolveUpdateProcedure(String procedure,
String userUpdateStr) throws QueryParserException,
QueryResolverException, TeiidComponentException,
QueryMetadataException {
@@ -2896,7 +2896,7 @@
ProcedureContainer userCommand =
(ProcedureContainer)QueryParser.getQueryParser().parseCommand(userUpdateStr);
QueryResolver.resolveCommand(userCommand, metadata);
- return (CreateUpdateProcedureCommand)QueryResolver.expandCommand(userCommand,
metadata, AnalysisRecord.createNonRecordingRecord());
+ return (CreateProcedureCommand)QueryResolver.expandCommand(userCommand, metadata,
AnalysisRecord.createNonRecordingRecord());
}
// validating AssignmentStatement, variable type and assigned type
Modified: trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java 2011-11-22
12:49:12 UTC (rev 3682)
+++ trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java 2011-11-22
12:55:13 UTC (rev 3683)
@@ -1143,7 +1143,7 @@
String userQuery = "Insert into vm1.g1 (e1, e2) values ('String',
1)"; //$NON-NLS-1$
- String rewritProc = "CREATE PROCEDURE\n"; //$NON-NLS-1$
+ String rewritProc = "CREATE VIRTUAL PROCEDURE\n"; //$NON-NLS-1$
rewritProc = rewritProc + "BEGIN\n"; //$NON-NLS-1$
rewritProc = rewritProc + "END"; //$NON-NLS-1$
@@ -1165,7 +1165,7 @@
String userQuery = "Insert into vm1.g1 (e1, e2) values ('String',
1)"; //$NON-NLS-1$
- String rewritProc = "CREATE PROCEDURE\n"; //$NON-NLS-1$
+ String rewritProc = "CREATE VIRTUAL PROCEDURE\n"; //$NON-NLS-1$
rewritProc = rewritProc + "BEGIN\n"; //$NON-NLS-1$
rewritProc = rewritProc + "SELECT COUNT(*) FROM pm1.g1;\n";
//$NON-NLS-1$
rewritProc = rewritProc + "END"; //$NON-NLS-1$
Modified:
trunk/engine/src/test/java/org/teiid/query/sql/proc/TestCreateUpdateProcedureCommand.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/sql/proc/TestCreateUpdateProcedureCommand.java 2011-11-22
12:49:12 UTC (rev 3682)
+++
trunk/engine/src/test/java/org/teiid/query/sql/proc/TestCreateUpdateProcedureCommand.java 2011-11-22
12:55:13 UTC (rev 3683)
@@ -22,20 +22,11 @@
package org.teiid.query.sql.proc;
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-
import junit.framework.TestCase;
import org.teiid.core.util.UnitTestUtil;
import org.teiid.query.resolver.TestResolver;
-import org.teiid.query.sql.lang.Command;
-import org.teiid.query.sql.lang.Option;
-import org.teiid.query.sql.lang.Query;
import org.teiid.query.sql.lang.StoredProcedure;
-import org.teiid.query.sql.symbol.GroupSymbol;
import org.teiid.query.unittest.RealMetadataFactory;
@@ -54,151 +45,62 @@
// ################################## TEST HELPERS ################################
- public static final CreateUpdateProcedureCommand sample1() {
- return new CreateUpdateProcedureCommand(TestBlock.sample1());
+ public static final CreateProcedureCommand sample1() {
+ return new CreateProcedureCommand(TestBlock.sample1());
}
- public static final CreateUpdateProcedureCommand sample2() {
- return new CreateUpdateProcedureCommand(TestBlock.sample2());
+ public static final CreateProcedureCommand sample2() {
+ return new CreateProcedureCommand(TestBlock.sample2());
}
- public static final CreateUpdateProcedureCommand sample3() {
- return new CreateUpdateProcedureCommand(TestBlock.sample1());
+ public static final CreateProcedureCommand sample3() {
+ return new CreateProcedureCommand(TestBlock.sample1());
}
// ################################## ACTUAL TESTS ################################
public void testGetBlock() {
- CreateUpdateProcedureCommand b1 = sample1();
+ CreateProcedureCommand b1 = sample1();
assertTrue("Incorrect Block on command",
b1.getBlock().equals(TestBlock.sample1())); //$NON-NLS-1$
}
public void testSetBlock() {
- CreateUpdateProcedureCommand b1 = (CreateUpdateProcedureCommand)sample1().clone();
+ CreateProcedureCommand b1 = (CreateProcedureCommand)sample1().clone();
b1.setBlock(TestBlock.sample2());
assertTrue("Incorrect Block on command",
b1.getBlock().equals(TestBlock.sample2())); //$NON-NLS-1$
}
public void testSelfEquivalence(){
- CreateUpdateProcedureCommand s1 = sample1();
+ CreateProcedureCommand s1 = sample1();
int equals = 0;
UnitTestUtil.helpTestEquivalence(equals, s1, s1);
}
public void testEquivalence(){
- CreateUpdateProcedureCommand s1 = sample1();
- CreateUpdateProcedureCommand s1a = sample1();
+ CreateProcedureCommand s1 = sample1();
+ CreateProcedureCommand s1a = sample1();
int equals = 0;
UnitTestUtil.helpTestEquivalence(equals, s1, s1a);
}
public void testNonEquivalence(){
- CreateUpdateProcedureCommand s1 = sample1();
- CreateUpdateProcedureCommand s2 = sample2();
+ CreateProcedureCommand s1 = sample1();
+ CreateProcedureCommand s2 = sample2();
int equals = -1;
UnitTestUtil.helpTestEquivalence(equals, s1, s2);
}
/**
- * We've had some defects in the past with state added to
- * CreateUpdateProcedureCommand but not added to the clone
- * method. We don't currently have any unit tests that exercise
- * the clone method very well. So this method simply asserts
- * that the number of fields that this test class thinks is in
- * CreateUpdateProcedureCommand is still current. I.e., if someone
- * adds state to CreateUpdateProcedureCommand but doesn't update
- * this test, the test will fail. The failure message is a reminder
- * to update the clone() method. So this isn't really a test of the
- * clone() method, per se.
- * see defect 14018
- * @since 4.2
- */
- public void testCloneMethod() {
- Field[] fields = CreateUpdateProcedureCommand.class.getDeclaredFields();
-
- final int EXPECTED_NUMBER_OF_FIELDS = 7; //<---update me if necessary!
- int actualNumberOfFields = fields.length;
-
- // Workaround for Java bug 4546736 and 4407429 (same bug) -
- // the Class literal "synthetic" field can be returned from the call
- // to getDeclaredFields(), it seems to show up as the last entry in the
- // Field array, and has a dollar sign "$" in it's name.
- if (fields[fields.length-1].getType().equals(Class.class) &&
- fields[fields.length-1].getName().indexOf("$") != -1) {
//$NON-NLS-1$
-
- actualNumberOfFields--;
- }
-
- assertEquals("New state has been added to the class
CreateUpdateProcedureCommand; please update this test, and update the clone() method if
necessary.", EXPECTED_NUMBER_OF_FIELDS, actualNumberOfFields); //$NON-NLS-1$
- }
-
- /**
- * tests that a CreateUpdateProcedureCommand with non-null variables for all of its
- * state produces a clone that has non-null variables for all of its state.
- */
- public void testCloneMethod2() throws Exception{
- CreateUpdateProcedureCommand s1 = sample1();
-
- //Command class state
- s1.addExternalGroupsToContext(new HashSet());
- s1.setIsResolved(true);
- s1.setOption(new Option());
- s1.setTemporaryMetadata(new HashMap());
-
- //CreateUpdateProcedure class state
- s1.setProjectedSymbols(new ArrayList());
- s1.setResultsCommand(new Query());
- s1.setSymbolMap(new HashMap());
- s1.setUpdateProcedure(true);
- s1.setVirtualGroup(new GroupSymbol("x")); //$NON-NLS-1$
- s1.setUserCommand(new Query());
-
- CreateUpdateProcedureCommand cloned = (CreateUpdateProcedureCommand)s1.clone();
-
- Class clazz = CreateUpdateProcedureCommand.class;
- Class superClazz = Command.class;
-
- Field field = null;
- //Command class state
- field = superClazz.getDeclaredField("tempGroupIDs"); //$NON-NLS-1$
- field.setAccessible( true );
- assertNotNull(field.get(cloned));
- field = superClazz.getDeclaredField("externalGroups"); //$NON-NLS-1$
- field.setAccessible( true );
- assertNotNull(field.get(cloned));
- field = superClazz.getDeclaredField("isResolved"); //$NON-NLS-1$
- field.setAccessible( true );
- assertTrue(((Boolean)field.get(cloned)).booleanValue());
- field = superClazz.getDeclaredField("option"); //$NON-NLS-1$
- field.setAccessible( true );
- assertNotNull(field.get(cloned));
-
- //CreateUpdateProcedure class state
- field = clazz.getDeclaredField("block"); //$NON-NLS-1$
- field.setAccessible( true );
- assertNotNull(field.get(cloned));
- field = clazz.getDeclaredField("symbolMap"); //$NON-NLS-1$
- field.setAccessible( true );
- assertNotNull(field.get(cloned));
- field = clazz.getDeclaredField("isUpdateProcedure"); //$NON-NLS-1$
- field.setAccessible( true );
- assertTrue(((Boolean)field.get(cloned)).booleanValue());
- field = clazz.getDeclaredField("projectedSymbols"); //$NON-NLS-1$
- field.setAccessible( true );
- assertNotNull(field.get(cloned));
- }
-
- /**
* Test cloning obj with mostly null state, test for NPE
*/
public void testCloneMethod3() {
- CreateUpdateProcedureCommand s1 = new CreateUpdateProcedureCommand();
- CreateUpdateProcedureCommand s2 = (CreateUpdateProcedureCommand)s1.clone();
+ CreateProcedureCommand s1 = new CreateProcedureCommand();
+ CreateProcedureCommand s2 = (CreateProcedureCommand)s1.clone();
UnitTestUtil.helpTestEquivalence(0, s1, s2);
}
public void testProjectedSymbols() {
- CreateUpdateProcedureCommand cupc = new CreateUpdateProcedureCommand();
+ CreateProcedureCommand cupc = new CreateProcedureCommand();
cupc.setUpdateProcedure(false);
StoredProcedure sp = (StoredProcedure)TestResolver.helpResolve("call
TEIIDSP9(p1=>1, p2=>?)", RealMetadataFactory.exampleBQTCached());
sp.setCallableStatement(true);
Modified:
trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java 2011-11-22
12:49:12 UTC (rev 3682)
+++
trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java 2011-11-22
12:55:13 UTC (rev 3683)
@@ -37,58 +37,15 @@
import org.teiid.query.parser.QueryParser;
import org.teiid.query.resolver.QueryResolver;
import org.teiid.query.sql.LanguageObject;
-import org.teiid.query.sql.lang.BetweenCriteria;
-import org.teiid.query.sql.lang.Command;
-import org.teiid.query.sql.lang.CompareCriteria;
-import org.teiid.query.sql.lang.CompoundCriteria;
-import org.teiid.query.sql.lang.Criteria;
-import org.teiid.query.sql.lang.Delete;
-import org.teiid.query.sql.lang.DynamicCommand;
-import org.teiid.query.sql.lang.ExistsCriteria;
-import org.teiid.query.sql.lang.From;
-import org.teiid.query.sql.lang.GroupBy;
-import org.teiid.query.sql.lang.Insert;
-import org.teiid.query.sql.lang.IsNullCriteria;
-import org.teiid.query.sql.lang.JoinPredicate;
-import org.teiid.query.sql.lang.JoinType;
-import org.teiid.query.sql.lang.Limit;
-import org.teiid.query.sql.lang.MatchCriteria;
-import org.teiid.query.sql.lang.NotCriteria;
-import org.teiid.query.sql.lang.Option;
-import org.teiid.query.sql.lang.OrderBy;
-import org.teiid.query.sql.lang.Query;
-import org.teiid.query.sql.lang.SPParameter;
-import org.teiid.query.sql.lang.Select;
-import org.teiid.query.sql.lang.SetCriteria;
-import org.teiid.query.sql.lang.SetQuery;
-import org.teiid.query.sql.lang.StoredProcedure;
-import org.teiid.query.sql.lang.SubqueryCompareCriteria;
-import org.teiid.query.sql.lang.SubqueryFromClause;
-import org.teiid.query.sql.lang.SubquerySetCriteria;
-import org.teiid.query.sql.lang.UnaryFromClause;
-import org.teiid.query.sql.lang.Update;
+import org.teiid.query.sql.lang.*;
import org.teiid.query.sql.lang.SetQuery.Operation;
import org.teiid.query.sql.proc.AssignmentStatement;
import org.teiid.query.sql.proc.Block;
import org.teiid.query.sql.proc.CommandStatement;
-import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
+import org.teiid.query.sql.proc.CreateProcedureCommand;
import org.teiid.query.sql.proc.DeclareStatement;
import org.teiid.query.sql.proc.RaiseErrorStatement;
-import org.teiid.query.sql.symbol.AggregateSymbol;
-import org.teiid.query.sql.symbol.AliasSymbol;
-import org.teiid.query.sql.symbol.CaseExpression;
-import org.teiid.query.sql.symbol.Constant;
-import org.teiid.query.sql.symbol.ElementSymbol;
-import org.teiid.query.sql.symbol.Expression;
-import org.teiid.query.sql.symbol.ExpressionSymbol;
-import org.teiid.query.sql.symbol.Function;
-import org.teiid.query.sql.symbol.GroupSymbol;
-import org.teiid.query.sql.symbol.MultipleElementSymbol;
-import org.teiid.query.sql.symbol.Reference;
-import org.teiid.query.sql.symbol.ScalarSubquery;
-import org.teiid.query.sql.symbol.SearchedCaseExpression;
-import org.teiid.query.sql.symbol.TestCaseExpression;
-import org.teiid.query.sql.symbol.TestSearchedCaseExpression;
+import org.teiid.query.sql.symbol.*;
import org.teiid.query.unittest.RealMetadataFactory;
@SuppressWarnings("nls")
@@ -1453,8 +1410,8 @@
b.addStatement(cmdStmt);
b.addStatement(assigStmt);
b.addStatement(errStmt);
- CreateUpdateProcedureCommand cup = new CreateUpdateProcedureCommand(b);
- helpTest(cup, "CREATE PROCEDURE\nBEGIN\nDELETE FROM g;\na = 1;\nERROR 'My
Error';\nEND"); //$NON-NLS-1$
+ CreateProcedureCommand cup = new CreateProcedureCommand(b);
+ helpTest(cup, "CREATE VIRTUAL PROCEDURE\nBEGIN\nDELETE FROM g;\na = 1;\nERROR
'My Error';\nEND"); //$NON-NLS-1$
}
@Test public void testCreateUpdateProcedure2() {
@@ -1467,8 +1424,8 @@
b.addStatement(cmdStmt);
b.addStatement(assigStmt);
b.addStatement(errStmt);
- CreateUpdateProcedureCommand cup = new CreateUpdateProcedureCommand(b);
- helpTest(cup, "CREATE PROCEDURE\nBEGIN\nDELETE FROM g;\na = 1;\nERROR 'My
Error';\nEND"); //$NON-NLS-1$
+ CreateProcedureCommand cup = new CreateProcedureCommand(b);
+ helpTest(cup, "CREATE VIRTUAL PROCEDURE\nBEGIN\nDELETE FROM g;\na = 1;\nERROR
'My Error';\nEND"); //$NON-NLS-1$
}
@Test public void testCreateUpdateProcedure3() {
@@ -1481,8 +1438,8 @@
b.addStatement(cmdStmt);
b.addStatement(assigStmt);
b.addStatement(errStmt);
- CreateUpdateProcedureCommand cup = new CreateUpdateProcedureCommand(b);
- helpTest(cup, "CREATE PROCEDURE\nBEGIN\nDELETE FROM g;\na = 1;\nERROR 'My
Error';\nEND"); //$NON-NLS-1$
+ CreateProcedureCommand cup = new CreateProcedureCommand(b);
+ helpTest(cup, "CREATE VIRTUAL PROCEDURE\nBEGIN\nDELETE FROM g;\na = 1;\nERROR
'My Error';\nEND"); //$NON-NLS-1$
}
@Test public void testSubqueryCompareCriteria1() {
Modified: trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java 2011-11-22
12:49:12 UTC (rev 3682)
+++ trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java 2011-11-22
12:55:13 UTC (rev 3683)
@@ -916,7 +916,6 @@
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
String userUpdateStr = "UPDATE vm1.g1 SET e1='x'";
//$NON-NLS-1$
@@ -932,7 +931,6 @@
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
procedure = procedure + "var1 = Select pm1.g1.e2, pm1.g1.e1 from
pm1.g1;\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
String userUpdateStr = "UPDATE vm1.g1 SET e1='x'";
//$NON-NLS-1$
@@ -948,7 +946,6 @@
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
procedure = procedure + "var1 = Select pm1.g1.e2, pm1.g1.e1 from
pm1.g1;\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
String userUpdateStr = "UPDATE vm1.g1 SET e1='x'";
//$NON-NLS-1$
@@ -963,7 +960,6 @@
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE string MaxTran;\n"; //$NON-NLS-1$
procedure = procedure + "MaxTran = SELECT MAX(e1) FROM pm1.g1;\n";
//$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
String userQuery = "UPDATE vm1.g3 SET x='x' where y = 1";
//$NON-NLS-1$
@@ -978,7 +974,6 @@
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE string var;\n"; //$NON-NLS-1$
procedure = procedure + "var = null;\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
String userQuery = "UPDATE vm1.g3 SET x='x' where y = 1";
//$NON-NLS-1$
@@ -995,7 +990,6 @@
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "var1 = SELECT COUNT(*) FROM myCursor;\n";
//$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED = 0;\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
String userQuery = "UPDATE vm1.g3 SET x='x' where y = 1";
//$NON-NLS-1$
@@ -1028,10 +1022,10 @@
}
@Test public void testSelectIntoTempGroup() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+ String procedure = "CREATE VIRTUAL PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "SELECT e1, e2, e3, e4 INTO #myTempTable FROM
pm1.g2;\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED = SELECT COUNT(*) FROM
#myTempTable;\n"; //$NON-NLS-1$
+ procedure = procedure + "SELECT COUNT(*) FROM #myTempTable;\n";
//$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
String userQuery = "UPDATE vm1.g3 SET x='x' where y = 1";
//$NON-NLS-1$
@@ -1048,7 +1042,7 @@
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "SELECT e1, e2, e3, e4 INTO #myTempTable FROM
pm1.g2;\n"; //$NON-NLS-1$
procedure = procedure + "SELECT e1, e2, e3 INTO #myTempTable FROM
pm1.g2;\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED = SELECT COUNT(*) FROM
#myTempTable;\n"; //$NON-NLS-1$
+ procedure = procedure + "SELECT COUNT(*) FROM #myTempTable;\n";
//$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
String userQuery = "UPDATE vm1.g3 SET x='x' where y = 1";
//$NON-NLS-1$
@@ -1057,15 +1051,12 @@
Table.TriggerEvent.UPDATE);
}
- /**
- * Defect 24346 with type mismatch
- */
@Test public void testInvalidSelectIntoTempGroup1() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "create local temporary table #myTempTable (e1
integer);\n"; //$NON-NLS-1$
procedure = procedure + "SELECT e1 INTO #myTempTable FROM pm1.g2;\n";
//$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED = SELECT COUNT(*) FROM
#myTempTable;\n"; //$NON-NLS-1$
+ procedure = procedure + "SELECT COUNT(*) FROM #myTempTable;\n";
//$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
String userQuery = "UPDATE vm1.g3 SET x='x' where y = 1";
//$NON-NLS-1$
@@ -1081,7 +1072,6 @@
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "SELECT e1, e2, e3, e4 INTO pm1.g1 FROM
pm1.g2;\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED = 0;\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
String userQuery = "UPDATE vm1.g3 SET x='x' where y = 1";
//$NON-NLS-1$
@@ -1104,7 +1094,6 @@
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "SELECT e1, e2, e3, e4, 'val' INTO pm1.g1
FROM pm1.g2;\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED = 0;\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
String userQuery = "UPDATE vm1.g3 SET x='x' where y = 1";
//$NON-NLS-1$
@@ -1119,7 +1108,6 @@
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "SELECT e1, e2, e3 INTO pm1.g1 FROM pm1.g2;\n";
//$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED = 0;\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
String userQuery = "UPDATE vm1.g3 SET x='x' where y = 1";
//$NON-NLS-1$
@@ -1134,7 +1122,6 @@
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "SELECT e1, convert(e2, string), e3, e4 INTO pm1.g1
FROM pm1.g2;\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED = 0;\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
String userQuery = "UPDATE vm1.g3 SET x='x' where y = 1";
//$NON-NLS-1$
@@ -1153,7 +1140,6 @@
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "SELECT * INTO pm1.g1 FROM pm1.g2, pm1.g1;\n";
//$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED = 0;\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
String userQuery = "UPDATE vm1.g3 SET x='x' where y = 1";
//$NON-NLS-1$
@@ -1168,7 +1154,6 @@
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "SELECT e1, e2, e3, e4 INTO vm1.g1 FROM
pm1.g2;\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED = 0;\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
String userQuery = "UPDATE vm1.g3 SET x='x' where y = 1";
//$NON-NLS-1$