Skip to content

Commit

Permalink
TEIID-4405 addressing temp table issues
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Aug 23, 2016
1 parent d49ff1a commit 7a79be1
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
15 changes: 7 additions & 8 deletions engine/src/main/java/org/teiid/common/buffer/TupleBrowser.java
Expand Up @@ -279,17 +279,16 @@ public void update(List<?> tuple) throws TeiidComponentException {

/**
* Notify the browser that the last value was deleted.
* @throws TeiidComponentException
*/
public void removed() {
public void removed() throws TeiidComponentException {
index-=getOffset();
//check if the page has been removed
if (index == 0 && page != null && page.managedBatch == null && page.values == null) {
values = null;
if (direction) {
page = page.next;
} else {
page = page.prev;
}
if (page != null && page.managedBatch == null && page.values == null) {
//navigate to the current position
List<?> lowerBound = values.get(index);
values = null;
setPage(lowerBound);
}
}

Expand Down
Expand Up @@ -181,6 +181,9 @@ private void processCriteria(Criteria condition, boolean primary) {
}
} else if (criteria instanceof SetCriteria) {
SetCriteria setCriteria = (SetCriteria)criteria;
if (setCriteria.isNegated()) {
continue;
}
Object matchResult = table.matchesPkColumn(i, setCriteria.getExpression());
if (Boolean.FALSE.equals(matchResult)) {
continue;
Expand Down
Expand Up @@ -619,8 +619,9 @@ private void sampleTable() throws Exception {
for (int i = 0; i < 1277; i++) {
execute("insert into #tmp_dates select DATE '2016-05-01' as datum, 'somevalue' as somevalue", new List[] {Arrays.asList(1)});
}
execute("delete from #tmp_dates where datum > (select cast(endtime as date) from #tmp_params)", new List[] {Arrays.asList(1024)});
execute("delete from #tmp_dates where datum > (select cast(endtime as date) from #tmp_params)", new List[] {Arrays.asList(1278)});
execute("delete from #tmp_dates where datum < (select cast(starttime as date) from #tmp_params)", new List[] {Arrays.asList(1)});
execute("select count(*) from #tmp_dates", new List[] {Arrays.asList(1)});
}

@Test public void testImplicitResolvingWithoutColumns() throws Exception {
Expand All @@ -631,4 +632,23 @@ private void sampleTable() throws Exception {
execute("insert into #tmp_dates select DATE '2016-05-01', somevalue from #tmp_dates", new List[] {Arrays.asList(3)});
}

@Test public void testNotInPredicateDelete() throws Exception {
execute("create local temporary table x (e1 string, e2 integer, primary key (e1))", new List[] {Arrays.asList(0)}); //$NON-NLS-1$

for (int i = 0; i < 2048; i++) {
execute("insert into x (e2, e1) values ("+i+", '"+i+"')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
}

execute("delete from x where e1 not in ('2000', '1')", new List[] {Arrays.asList(2046)}); //$NON-NLS-1$

execute("drop table x", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$

for (int i = 0; i < 2048; i++) {
execute("insert into x (e2, e1) values ("+i+", '"+i+"')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
}

execute("delete from x where e1 not in ('2000', '1')", new List[] {Arrays.asList(2046)}); //$NON-NLS-1$
}

}

0 comments on commit 7a79be1

Please sign in to comment.