Author: shawkins
Date: 2009-09-23 16:31:14 -0400 (Wed, 23 Sep 2009)
New Revision: 1471
Modified:
trunk/engine/src/main/java/com/metamatrix/query/tempdata/TempTableStore.java
trunk/engine/src/main/java/com/metamatrix/query/tempdata/TempTableStoreImpl.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestTempTables.java
Log:
TEIID-162 handling for no criteria on delete
Modified: trunk/engine/src/main/java/com/metamatrix/query/tempdata/TempTableStore.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/query/tempdata/TempTableStore.java 2009-09-23
20:29:55 UTC (rev 1470)
+++
trunk/engine/src/main/java/com/metamatrix/query/tempdata/TempTableStore.java 2009-09-23
20:31:14 UTC (rev 1471)
@@ -36,8 +36,6 @@
*/
public interface TempTableStore {
- void removeTempTable(Command command) throws MetaMatrixComponentException;
-
void removeTempTables() throws MetaMatrixComponentException;
TempMetadataStore getMetadataStore();
Modified:
trunk/engine/src/main/java/com/metamatrix/query/tempdata/TempTableStoreImpl.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/query/tempdata/TempTableStoreImpl.java 2009-09-23
20:29:55 UTC (rev 1470)
+++
trunk/engine/src/main/java/com/metamatrix/query/tempdata/TempTableStoreImpl.java 2009-09-23
20:31:14 UTC (rev 1471)
@@ -180,13 +180,6 @@
groupToTupleSourceID.put(tempTableName, tsId);
}
- public void removeTempTable(Command command) throws MetaMatrixComponentException{
- if(command.getType() == Command.TYPE_DROP) {
- String tempTableName = ((Drop)command).getTable().getName().toUpperCase();
- removeTempTableByName(tempTableName);
- }
- }
-
public void removeTempTableByName(String tempTableName) throws
MetaMatrixComponentException {
tempMetadataStore.removeTempGroup(tempTableName);
TupleSourceID tsId = this.groupToTupleSourceID.remove(tempTableName);
@@ -250,6 +243,11 @@
if (command instanceof Delete) {
final Delete delete = (Delete)command;
final Criteria crit = delete.getCriteria();
+ if (crit == null) {
+ int rows = buffer.getRowCount(tsId);
+ addTempTable(groupKey, buffer.getTupleSchema(tsId), true);
+ return new UpdateCountTupleSource(rows);
+ }
return new UpdateTupleSource(groupKey, tsId, crit) {
@Override
protected void tuplePassed(List<?> tuple)
@@ -272,7 +270,8 @@
return new UpdateCountTupleSource(0);
}
if (command instanceof Drop) {
- removeTempTable(command);
+ String tempTableName = ((Drop)command).getTable().getName().toUpperCase();
+ removeTempTableByName(tempTableName);
return new UpdateCountTupleSource(0);
}
return null;
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestTempTables.java
===================================================================
---
trunk/engine/src/test/java/com/metamatrix/query/processor/TestTempTables.java 2009-09-23
20:29:55 UTC (rev 1470)
+++
trunk/engine/src/test/java/com/metamatrix/query/processor/TestTempTables.java 2009-09-23
20:31:14 UTC (rev 1471)
@@ -82,5 +82,12 @@
execute("delete from x where ascii(e1) > e2", new List[]
{Arrays.asList(5)}); //$NON-NLS-1$
execute("select e1 from x order by e1", new List[]
{Arrays.asList((String)null)}); //$NON-NLS-1$
}
+
+ @Test public void testDelete1() throws Exception {
+ execute("create local temporary table x (e1 string, e2 integer)", new List[]
{Arrays.asList(0)}); //$NON-NLS-1$
+ execute("select e1, e2 into x from pm1.g1", new List[] {Arrays.asList(6)});
//$NON-NLS-1$
+ execute("delete from x", new List[] {Arrays.asList(6)}); //$NON-NLS-1$
+ execute("select e1 from x order by e1", new List[] {}); //$NON-NLS-1$
+ }
}
Show replies by date